/* ============================================================
   SSTDOC — Design System
   Tokens → Reset → Base → Layout → Componentes
   ============================================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── 1. TOKENS (CSS Custom Properties) ── */
:root {
    /* Neutros */
    --bg:      #F7F8FA;
    --surface: #FFFFFF;
    --ink:     #1A1D21;
    --muted:   #5B6470;
    --line:    #E3E7ED;

    /* Marca */
    --brand:      #22303C;
    --accent:     #0D9488;
    --accent-600: #0B7A77;

    /* Severidade/classificação */
    --sev-baixo:  #15803D;
    --sev-medio:  #B45309;
    --sev-alto:   #C2410C;
    --sev-critico:#B91C1C;

    /* Estados utilitários */
    --ok:     #15803D;
    --warn:   #B45309;
    --danger: #B91C1C;
    --info:   #1D4ED8;

    /* Tipografia */
    --font-display: 'Sora', system-ui, sans-serif;
    --font-body:    'Inter', system-ui, sans-serif;
    --font-mono:    'JetBrains Mono', 'Courier New', monospace;

    /* Escala de tamanho (rem) */
    --text-xs:   0.75rem;
    --text-sm:   0.875rem;
    --text-base: 1rem;
    --text-lg:   1.125rem;
    --text-xl:   1.25rem;
    --text-2xl:  1.5rem;
    --text-3xl:  1.875rem;
    --text-4xl:  2.25rem;

    /* Espaçamento (base 4px) */
    --s-1: 0.25rem;
    --s-2: 0.5rem;
    --s-3: 0.75rem;
    --s-4: 1rem;
    --s-6: 1.5rem;
    --s-8: 2rem;
    --s-12: 3rem;
    --s-16: 4rem;

    /* Raio */
    --r-sm: 6px;
    --r:    8px;

    /* Sombra */
    --shadow: 0 1px 2px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.08);

    /* Layout */
    --sidebar-w: 240px;
    --topbar-h:  56px;
}

/* ── 2. RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-600); }

/* ── 3. TIPOGRAFIA ── */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-body);
    font-weight: 600;
    line-height: 1.2;
    color: var(--ink);
}
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

.display { font-family: var(--font-display); }
.mono { font-family: var(--font-mono); }
.text-muted { color: var(--muted); }

/* ── 4. SHELL — Sidebar + Topbar + Content ── */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--brand);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform .25s ease;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-4) var(--s-6);
    height: var(--topbar-h);
    border-bottom: 1px solid rgba(255,255,255,.08);
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 700;
    color: #fff;
    text-decoration: none;
}

.sidebar-logo .logo-dot {
    width: 8px; height: 8px;
    background: var(--accent);
    border-radius: 50%;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--s-4) 0;
}

.sidebar-section {
    padding: var(--s-2) var(--s-6) var(--s-1);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: rgba(255,255,255,.4);
    margin-top: var(--s-4);
}

.sidebar-section:first-child { margin-top: 0; }

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-2) var(--s-6);
    color: rgba(255,255,255,.75);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: 500;
    border-radius: 0;
    transition: background .15s, color .15s;
    position: relative;
}

.nav-item:hover {
    background: rgba(255,255,255,.07);
    color: #fff;
    text-decoration: none;
}

.nav-item.active {
    background: rgba(13,148,136,.18);
    color: #fff;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

.nav-item svg { flex-shrink: 0; opacity: .7; }
.nav-item.active svg, .nav-item:hover svg { opacity: 1; }

/* Topbar */
.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: var(--s-4);
    padding: 0 var(--s-6);
    z-index: 90;
}

.topbar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--ink);
    padding: var(--s-2);
    border-radius: var(--r-sm);
}

.topbar-toggle:hover { background: var(--bg); }

.empresa-selector {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    font-size: var(--text-sm);
    color: var(--muted);
}

.empresa-selector select {
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: var(--s-1) var(--s-3);
    font-size: var(--text-sm);
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--surface);
    cursor: pointer;
    min-width: 200px;
}

.empresa-selector select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.topbar-spacer { flex: 1; }

/* Conteúdo principal */
.main-content {
    margin-left: var(--sidebar-w);
    margin-top: var(--topbar-h);
    min-height: calc(100vh - var(--topbar-h));
    padding: var(--s-8);
}

.page-header {
    margin-bottom: var(--s-6);
}

.page-title {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--ink);
}

.page-subtitle {
    color: var(--muted);
    font-size: var(--text-sm);
    margin-top: var(--s-1);
}

/* ── 5. COMPONENTES ── */

/* Botões */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    padding: .5rem 1rem;
    font-size: var(--text-sm);
    font-family: var(--font-body);
    font-weight: 500;
    border-radius: var(--r);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s;
    line-height: 1.4;
}

.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-600); border-color: var(--accent-600); color: #fff; }

.btn-secondary {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--line);
}
.btn-secondary:hover { background: var(--bg); color: var(--ink); }

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border-color: transparent;
}
.btn-ghost:hover { background: var(--bg); color: var(--ink); }

.btn-danger {
    background: var(--surface);
    color: var(--danger);
    border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: .35rem .75rem; font-size: var(--text-xs); }
.btn-lg { padding: .7rem 1.4rem; font-size: var(--text-base); }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow);
}

.card-header {
    padding: var(--s-4) var(--s-6);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: var(--s-3);
    justify-content: space-between;
}

.card-title {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--ink);
}

.card-body { padding: var(--s-6); }
.card-footer {
    padding: var(--s-4) var(--s-6);
    border-top: 1px solid var(--line);
    background: var(--bg);
    border-radius: 0 0 var(--r) var(--r);
}

/* Tabela de dados */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.data-table th {
    text-align: left;
    padding: var(--s-3) var(--s-4);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    background: var(--bg);
}

.data-table td {
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg); }

/* Campos de formulário */
.form-group { margin-bottom: var(--s-4); }

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--ink);
    margin-bottom: var(--s-1);
}

.form-label .required { color: var(--danger); margin-left: 2px; }

.form-control {
    width: 100%;
    padding: .5rem var(--s-3);
    font-size: var(--text-sm);
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    transition: border-color .15s, box-shadow .15s;
    line-height: 1.5;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(13,148,136,.12);
}

.form-control.is-invalid {
    border-color: var(--danger);
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(185,28,28,.12);
}

.form-help {
    font-size: var(--text-xs);
    color: var(--muted);
    margin-top: var(--s-1);
}

.form-error {
    font-size: var(--text-xs);
    color: var(--danger);
    margin-top: var(--s-1);
}

textarea.form-control { resize: vertical; min-height: 100px; }

/* Badges de classificação/severidade */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px var(--s-2);
    font-size: var(--text-xs);
    font-weight: 600;
    border-radius: 999px;
    white-space: nowrap;
}

.badge-baixo  { background: rgba(21,128,61,.12);  color: var(--sev-baixo); }
.badge-medio  { background: rgba(180,83,9,.12);   color: var(--sev-medio); }
.badge-alto   { background: rgba(194,65,12,.12);  color: var(--sev-alto); }
.badge-critico{ background: rgba(185,28,28,.12);  color: var(--sev-critico); }
.badge-info   { background: rgba(29,78,216,.10);  color: var(--info); }

/* Estado vazio */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--s-16) var(--s-8);
    text-align: center;
}

.empty-state-icon { font-size: 3rem; margin-bottom: var(--s-4); opacity: .3; }
.empty-state-title { font-size: var(--text-lg); font-weight: 600; color: var(--ink); margin-bottom: var(--s-2); }
.empty-state-desc  { color: var(--muted); font-size: var(--text-sm); margin-bottom: var(--s-6); max-width: 320px; }

/* Toast */
.toast-container {
    position: fixed;
    bottom: var(--s-6);
    right: var(--s-6);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
    font-size: var(--text-sm);
    min-width: 260px;
    animation: slideInRight .25s ease;
}

.toast-ok     { border-left: 3px solid var(--ok); }
.toast-warn   { border-left: 3px solid var(--warn); }
.toast-danger { border-left: 3px solid var(--danger); }

@keyframes slideInRight {
    from { transform: translateX(120%); opacity: 0; }
    to   { transform: translateX(0);   opacity: 1; }
}

/* Modal */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 500;
    padding: var(--s-4);
}

.modal {
    background: var(--surface);
    border-radius: var(--r);
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    max-width: 480px; width: 100%;
}

.modal-header {
    padding: var(--s-4) var(--s-6);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between;
}

.modal-title { font-weight: 600; }

.modal-body { padding: var(--s-6); }

.modal-footer {
    padding: var(--s-4) var(--s-6);
    border-top: 1px solid var(--line);
    display: flex; gap: var(--s-3); justify-content: flex-end;
}

/* Paginação */
.pagination {
    display: flex;
    gap: var(--s-1);
    align-items: center;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    font-size: var(--text-sm);
    color: var(--muted);
    text-decoration: none;
    transition: all .15s;
}

.page-link:hover { background: var(--bg); color: var(--ink); }
.page-link.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── 6. QUADRO DE RISCO ── */
.risk-box {
    border-radius: var(--r);
    border: 1px solid var(--line);
    overflow: hidden;
    box-shadow: var(--shadow);
    font-size: var(--text-sm);
}

.risk-box-header {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-4);
    color: #fff;
    font-weight: 600;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.risk-box-body {
    background: var(--surface);
    padding: var(--s-4);
}

.risk-box-row {
    display: flex;
    gap: var(--s-2);
    margin-bottom: var(--s-2);
}

.risk-box-row:last-child { margin-bottom: 0; }

.risk-box-label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--muted);
    min-width: 110px;
    flex-shrink: 0;
}

.risk-box-value { color: var(--ink); }

/* ── 7. UTILITÁRIOS ── */
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2       { gap: var(--s-2); }
.gap-3       { gap: var(--s-3); }
.gap-4       { gap: var(--s-4); }
.mt-4        { margin-top: var(--s-4); }
.mt-6        { margin-top: var(--s-6); }
.mb-4        { margin-bottom: var(--s-4); }
.mb-6        { margin-bottom: var(--s-6); }
.w-full      { width: 100%; }

/* Bootstrap override — elimina o azul padrão */
.btn-primary.bs { background: var(--accent); border-color: var(--accent); }
.btn-primary.bs:hover { background: var(--accent-600); border-color: var(--accent-600); }

/* ── 8. RESPONSIVIDADE ── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .topbar {
        left: 0;
    }

    .topbar-toggle {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding: var(--s-4);
    }

    .sidebar-overlay {
        display: none;
        position: fixed; inset: 0;
        background: rgba(0,0,0,.4);
        z-index: 99;
    }

    .sidebar-overlay.active { display: block; }
}

/* Movimento reduzido */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}
