/* ==============================
   CLAYFER — CSS Principal
   ============================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #1a3a5c;
    --primary-light: #2563a8;
    --accent: #e05c1a;
    --success: #16a34a;
    --warning: #ca8a04;
    --danger: #dc2626;
    --info: #0891b2;
    --dark: #111827;
    --gray: #6b7280;
    --gray-light: #e5e7eb;
    --bg: #f3f4f6;
    --white: #ffffff;
    --sidebar-w: 240px;
    --header-h: 56px;
    --radius: 8px;
    --shadow: 0 1px 4px rgba(0,0,0,.12);
}

body { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px;
       background: var(--bg); color: var(--dark); }

/* ---- LOGIN ---- */
.login-page { display: flex; align-items: center; justify-content: center;
              min-height: 100vh; background: linear-gradient(135deg,var(--primary) 0%,#0f2540 100%); }
.login-wrap { width: 100%; max-width: 400px; padding: 16px; }
.login-box { background: var(--white); border-radius: 12px; padding: 40px 36px; box-shadow: 0 8px 32px rgba(0,0,0,.3); }
.login-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.logo-mark { width: 48px; height: 48px; background: var(--primary); color: var(--white);
             border-radius: 10px; display: flex; align-items: center; justify-content: center;
             font-size: 24px; font-weight: 700; }
.login-logo strong { display: block; font-size: 20px; color: var(--primary); }
.login-logo small { color: var(--gray); font-size: 12px; }
.login-foot { text-align: center; margin-top: 24px; color: var(--gray); font-size: 12px; }

/* ---- LAYOUT ADMIN ---- */
.admin-layout { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar { width: var(--sidebar-w); background: var(--primary); color: var(--white);
           display: flex; flex-direction: column; flex-shrink: 0; position: fixed;
           top: 0; left: 0; bottom: 0; z-index: 100; overflow-y: auto; }
.sidebar-logo { padding: 18px 20px; border-bottom: 1px solid rgba(255,255,255,.1);
                display: flex; align-items: center; gap: 10px; }
.sidebar-logo .logo-mark { width: 36px; height: 36px; font-size: 18px; background: var(--accent); }
.sidebar-logo span { font-size: 16px; font-weight: 700; letter-spacing: .5px; }
.sidebar-logo small { font-size: 10px; opacity: .7; display: block; }

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section { padding: 8px 20px 4px; font-size: 10px; text-transform: uppercase;
               letter-spacing: 1px; opacity: .5; }
.sidebar-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 20px;
                 color: rgba(255,255,255,.8); text-decoration: none; transition: all .15s; }
.sidebar-nav a:hover, .sidebar-nav a.active { background: rgba(255,255,255,.1); color: var(--white); }
.sidebar-nav a .icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-nav a .badge-count { background: var(--accent); color: var(--white); border-radius: 10px;
                               padding: 1px 6px; font-size: 11px; margin-left: auto; }

.sidebar-user { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.1);
                display: flex; align-items: center; gap: 10px; }
.sidebar-user .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent);
                         display: flex; align-items: center; justify-content: center;
                         font-weight: 700; font-size: 14px; flex-shrink: 0; }
.sidebar-user .info small { font-size: 11px; opacity: .6; display: block; }
.sidebar-user a { color: rgba(255,255,255,.6); font-size: 11px; text-decoration: none; }

/* MAIN */
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* TOPBAR */
.topbar { height: var(--header-h); background: var(--white); border-bottom: 1px solid var(--gray-light);
          display: flex; align-items: center; padding: 0 24px; gap: 16px;
          position: sticky; top: 0; z-index: 90; }
.topbar h1 { font-size: 16px; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.notif-btn { position: relative; background: none; border: none; cursor: pointer;
             color: var(--gray); font-size: 20px; padding: 4px; }
.notif-btn .badge-dot { position: absolute; top: 2px; right: 2px; width: 8px; height: 8px;
                         background: var(--danger); border-radius: 50%; border: 2px solid var(--white); }

/* INACTIVITY TOAST */
#inactivity-warning { display: none; position: fixed; bottom: 20px; right: 20px;
    background: var(--danger); color: var(--white); padding: 14px 20px; border-radius: var(--radius);
    z-index: 9999; font-weight: 600; box-shadow: 0 4px 20px rgba(0,0,0,.3); min-width: 280px; }
#inactivity-warning span { font-size: 22px; font-weight: 700; }

/* PAGE */
.page-body { padding: 24px; flex: 1; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h2 { font-size: 20px; font-weight: 700; }

/* ---- CARDS STATS ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(200px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--white); border-radius: var(--radius); padding: 20px;
             box-shadow: var(--shadow); display: flex; align-items: flex-start; gap: 14px; }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center;
             justify-content: center; font-size: 20px; flex-shrink: 0; }
.stat-icon.blue { background: #dbeafe; color: var(--primary-light); }
.stat-icon.green { background: #dcfce7; color: var(--success); }
.stat-icon.orange { background: #ffedd5; color: var(--accent); }
.stat-icon.red { background: #fee2e2; color: var(--danger); }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.teal { background: #ccfbf1; color: #0d9488; }
.stat-val { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--gray); margin-top: 2px; }

/* ---- CHARTS GRID ---- */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.charts-grid.three { grid-template-columns: 1fr 1fr 1fr; }
@media(max-width:900px){ .charts-grid,.charts-grid.three { grid-template-columns: 1fr; } }

.chart-card { background: var(--white); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.chart-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 14px; color: var(--dark); }

/* ---- TABLE ---- */
.table-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-card .table-header { padding: 16px 20px; border-bottom: 1px solid var(--gray-light);
                             display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.table-card .table-header h3 { font-size: 14px; font-weight: 600; }
table { width: 100%; border-collapse: collapse; }
thead th { background: #f9fafb; padding: 10px 16px; text-align: left; font-size: 12px;
           text-transform: uppercase; letter-spacing: .5px; color: var(--gray);
           border-bottom: 1px solid var(--gray-light); }
tbody tr { border-bottom: 1px solid var(--gray-light); transition: background .1s; }
tbody tr:hover { background: #f9fafb; }
tbody tr:last-child { border-bottom: none; }
td { padding: 10px 16px; font-size: 13px; }

/* ---- PROGRESS BAR ---- */
.progress-wrap { background: var(--gray-light); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 4px; background: var(--primary-light); }
.progress-bar.green { background: var(--success); }
.progress-bar.orange { background: var(--accent); }
.progress-bar.red { background: var(--danger); }
.progress-txt { font-size: 11px; color: var(--gray); margin-top: 2px; }

/* ---- ALERTS PANEL ---- */
.alerts-feed { display: flex; flex-direction: column; gap: 8px; }
.alert-item { display: flex; gap: 12px; padding: 12px 16px; border-radius: var(--radius); }
.alert-item.info { background: #eff6ff; border-left: 4px solid var(--info); }
.alert-item.aviso { background: #fefce8; border-left: 4px solid var(--warning); }
.alert-item.critico { background: #fef2f2; border-left: 4px solid var(--danger); }
.alert-item.bloqueante { background: #fdf2f8; border-left: 4px solid #a21caf; }
.alert-item .ai-icon { font-size: 18px; flex-shrink: 0; }
.alert-item .ai-body strong { display: block; font-size: 13px; }
.alert-item .ai-body span { font-size: 12px; color: var(--gray); }
.alert-item .ai-body small { color: var(--gray); font-size: 11px; }

/* ---- FORM ---- */
.card { background: var(--white); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.full { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--gray); text-transform: uppercase; letter-spacing: .4px; }
.form-control { border: 1px solid var(--gray-light); border-radius: 6px; padding: 8px 12px;
                font-size: 13px; width: 100%; transition: border-color .15s; }
.form-control:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(37,99,168,.12); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

/* ---- BUTTONS ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 6px;
       font-size: 13px; font-weight: 500; cursor: pointer; border: none; text-decoration: none; transition: all .15s; }
.btn-primary { background: var(--primary-light); color: var(--white); }
.btn-primary:hover { background: var(--primary); }
.btn-success { background: var(--success); color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-warning { background: var(--warning); color: var(--white); }
.btn-outline { background: transparent; border: 1px solid var(--gray-light); color: var(--dark); }
.btn-outline:hover { background: var(--gray-light); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: 11px; }
.btn-icon { padding: 6px; border-radius: 6px; background: transparent; border: 1px solid var(--gray-light); cursor: pointer; }
.btn-icon:hover { background: var(--gray-light); }

/* ---- BADGES ---- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-primary { background: #dbeafe; color: #1d4ed8; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-warning { background: #fef9c3; color: #a16207; }
.badge-info { background: #cffafe; color: #0e7490; }
.badge-secondary { background: #f3f4f6; color: #6b7280; }
.badge-dark { background: #e5e7eb; color: #374151; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-purple { background: #ede9fe; color: #6d28d9; }

/* ---- ALERTS ---- */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-warning { background: #fef9c3; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ---- TIMELINE ---- */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 9px; top: 0; bottom: 0;
                    width: 2px; background: var(--gray-light); }
.tl-item { position: relative; margin-bottom: 16px; }
.tl-item::before { content: ''; position: absolute; left: -22px; top: 4px; width: 10px; height: 10px;
                   border-radius: 50%; background: var(--primary-light); border: 2px solid var(--white); box-shadow: var(--shadow); }
.tl-item.danger::before { background: var(--danger); }
.tl-item.success::before { background: var(--success); }
.tl-item.warning::before { background: var(--warning); }
.tl-date { font-size: 11px; color: var(--gray); }
.tl-text { font-size: 13px; margin-top: 2px; }

/* ---- ESCALAMENTO ---- */
.esc-levels { display: flex; flex-direction: column; gap: 6px; }
.esc-level { display: flex; align-items: center; gap: 12px; padding: 10px 14px;
             border-radius: var(--radius); background: #f9fafb; border: 1px solid var(--gray-light); }
.esc-level .lvl-badge { width: 28px; height: 28px; border-radius: 50%; background: var(--primary);
                         color: var(--white); display: flex; align-items: center; justify-content: center;
                         font-size: 12px; font-weight: 700; flex-shrink: 0; }
.esc-level.active { background: #fef9c3; border-color: var(--warning); }
.esc-level.done { background: #dcfce7; border-color: var(--success); }

/* ---- HORAS / TIMESHEET ---- */
.hours-week { display: grid; grid-template-columns: repeat(7,1fr); gap: 4px; }
.hours-day { text-align: center; }
.hours-day .day-label { font-size: 10px; color: var(--gray); text-transform: uppercase; }
.hours-day .day-bar-wrap { height: 60px; display: flex; align-items: flex-end; justify-content: center; margin: 4px 0; }
.hours-day .day-bar { width: 20px; border-radius: 3px 3px 0 0; background: var(--primary-light);
                       min-height: 2px; transition: height .3s; }
.hours-day .day-val { font-size: 11px; font-weight: 600; color: var(--dark); }

/* ---- MISC ---- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--gray); }
.empty-state .emoji { font-size: 40px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; }
.gap-8 { display: flex; gap: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--gray); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.fw-bold { font-weight: 700; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }

/* CLIENTE PORTAL */
.client-layout { background: var(--bg); min-height: 100vh; }
.client-header { background: var(--primary); color: var(--white); padding: 0 24px;
                 height: 56px; display: flex; align-items: center; justify-content: space-between; }
.client-header .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.client-header .brand .logo-mark { width: 32px; height: 32px; font-size: 16px; background: var(--accent); }
.client-header a { color: rgba(255,255,255,.7); text-decoration: none; font-size: 13px; }
.client-header a:hover { color: var(--white); }
.client-body { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }
.client-proj-card { background: var(--white); border-radius: var(--radius); padding: 20px;
                    box-shadow: var(--shadow); margin-bottom: 16px; display: flex; gap: 16px; }
.client-proj-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.client-proj-main { flex: 1; }
.client-proj-meta { display: flex; gap: 16px; margin-top: 8px; flex-wrap: wrap; }
.client-proj-meta span { font-size: 12px; color: var(--gray); }

/* PORTAL CLIENTE */
.portal-body { background: #f3f4f6; min-height: 100vh; }
.portal-header { background: var(--primary); color: var(--white); padding: 0 24px;
                 height: 56px; display: flex; align-items: center; justify-content: space-between;
                 position: sticky; top: 0; z-index: 90; }
.portal-logo { display: flex; align-items: center; gap: 10px; }
.portal-content { max-width: 1000px; margin: 0 auto; padding: 28px 20px; }

/* FILTER BAR */
.filter-bar { display: flex; align-items: center; justify-content: space-between;
              gap: 12px; flex-wrap: wrap; margin-bottom: 0; }

/* ESCALATION */
.escalation-levels { display: flex; flex-direction: column; gap: 10px; }
.esc-level { display: flex; align-items: center; gap: 12px; padding: 12px 16px;
             border-radius: var(--radius); background: #f9fafb;
             border-left: 4px solid var(--gray-light); }
.esc-badge { width: 32px; height: 32px; border-radius: 50%; color: #fff;
             display: flex; align-items: center; justify-content: center;
             font-size: 13px; font-weight: 700; flex-shrink: 0; }
.esc-info strong { display: block; font-size: 13px; }
.esc-info span { font-size: 12px; color: var(--gray); }

/* FLASH / FEEDBACK ALERTS */
.alert-flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px;
               font-size: 13px; font-weight: 500; }
.alert-flash.success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-flash.danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* UTILS EXTRA */
.ml-4  { margin-left: 4px; }
.ml-6  { margin-left: 6px; }
.mt-20 { margin-top: 20px; }
.opacity-50 { opacity: .5; }
.form-control-sm { padding: 5px 8px; font-size: 12px; }
code { font-family: 'Courier New', monospace; }

/* Scroll */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-light); border-radius: 3px; }
