/* ============================================================
   CRM Pushfy — Design System v1
   Paleta: Azul escuro #0A2540 + branco
   Light & Dark themes via [data-theme]
   ============================================================ */

/* ---------- Tema: variáveis CSS ---------- */
:root,
[data-theme="light"] {
    /* Marca */
    --brand:           #0A2540;
    --brand-hover:     #0d2f54;
    --brand-soft:      #E8EEF6;
    --brand-on:        #FFFFFF;

    /* Superfícies */
    --bg:              #F4F6F9;
    --surface:         #FFFFFF;
    --surface-2:       #F8FAFC;
    --surface-hover:   #F1F4F8;

    /* Texto */
    --text:            #1A2332;
    --text-2:          #4B5563;
    --text-muted:      #8A95A5;
    --text-faint:      #B5BDC9;

    /* Borda */
    --border:          #E4E9F0;
    --border-strong:   #D0D7E2;

    /* Estados */
    --success:         #10B981;
    --success-soft:    #D1FAE5;
    --warning:         #F59E0B;
    --warning-soft:    #FEF3C7;
    --danger:          #EF4444;
    --danger-soft:     #FEE2E2;
    --info:            #3B82F6;
    --info-soft:       #DBEAFE;

    /* Sombras */
    --shadow-sm:       0 1px 2px rgba(10, 37, 64, 0.06);
    --shadow:          0 2px 8px rgba(10, 37, 64, 0.06), 0 1px 2px rgba(10, 37, 64, 0.04);
    --shadow-lg:       0 8px 24px rgba(10, 37, 64, 0.08), 0 2px 4px rgba(10, 37, 64, 0.04);

    /* Layout */
    --sidebar-w:       260px;
    --topbar-h:        62px;
    --radius:          10px;
    --radius-sm:       6px;
    --radius-lg:       14px;
}

[data-theme="dark"] {
    --brand:           #3B82F6;
    --brand-hover:     #60A5FA;
    --brand-soft:      rgba(59, 130, 246, 0.12);
    --brand-on:        #FFFFFF;

    --bg:              #0E1420;
    --surface:         #161E2E;
    --surface-2:       #1B2438;
    --surface-hover:   #1F2942;

    --text:            #E4E9F2;
    --text-2:          #B0BAC9;
    --text-muted:      #8590A3;
    --text-faint:      #5A6478;

    --border:          #1F2937;
    --border-strong:   #2A3548;

    --success-soft:    rgba(16, 185, 129, 0.15);
    --warning-soft:    rgba(245, 158, 11, 0.15);
    --danger-soft:     rgba(239, 68, 68, 0.15);
    --info-soft:       rgba(59, 130, 246, 0.15);

    --shadow-sm:       0 1px 2px rgba(0, 0, 0, 0.30);
    --shadow:          0 2px 8px rgba(0, 0, 0, 0.30), 0 1px 2px rgba(0, 0, 0, 0.20);
    --shadow-lg:       0 8px 24px rgba(0, 0, 0, 0.40);
}

/* ---------- Base ---------- */
* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--brand);
    text-decoration: none;
    transition: color .15s ease;
}
a:hover {
    color: var(--brand-hover);
    text-decoration: none;
}

::selection {
    background: var(--brand-soft);
    color: var(--brand);
}

/* Bootstrap overrides — text utilities */
.text-muted { color: var(--text-muted) !important; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0; /* permite shrink em flex */
    transition: margin-left .25s ease;
}

@media (max-width: 991.98px) {
    .app-main {
        margin-left: 0;
    }
}

.app-content {
    flex: 1;
    padding: 24px;
}

@media (max-width: 575.98px) {
    .app-content { padding: 16px; }
}

.app-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 12px;
    background: var(--surface);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform .25s ease;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }
    .app-sidebar.is-open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 37, 64, .5);
    z-index: 1035;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease;
}
.sidebar-overlay.is-open {
    opacity: 1;
    visibility: visible;
}
@media (min-width: 992px) {
    .sidebar-overlay { display: none !important; }
}

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    height: var(--topbar-h);
}
.brand-mark {
    width: 36px; height: 36px;
    background: var(--brand);
    color: var(--brand-on);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -.02em;
}
[data-theme="dark"] .brand-mark {
    background: var(--brand);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; font-size: 15px; color: var(--text); }
.brand-sub  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-group-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: 14px 12px 6px;
}
.nav-group-label:first-child { padding-top: 4px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-weight: 500;
    font-size: 13.5px;
    transition: all .12s ease;
    border-left: 2px solid transparent;
}
.nav-item:hover {
    background: var(--surface-hover);
    color: var(--text);
}
.nav-item i {
    font-size: 18px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.nav-item:hover i { color: var(--brand); }

.nav-item.active {
    background: var(--brand-soft);
    color: var(--brand);
    border-left-color: var(--brand);
    font-weight: 600;
}
.nav-item.active i { color: var(--brand); }
[data-theme="dark"] .nav-item.active { color: var(--brand-hover); }

/* Footer */
.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}
.env-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-muted);
}
.env-badge i { font-size: 6px; }
.env-production { color: var(--success); }
.env-development, .env-local { color: var(--warning); }

/* ============================================================
   TOPBAR
   ============================================================ */
.app-topbar {
    height: var(--topbar-h);
    padding: 0 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 1020;
}

@media (max-width: 575.98px) {
    .app-topbar { padding: 0 14px; }
}

.topbar-toggle {
    display: none;
    background: none;
    border: none;
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 22px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}
.topbar-toggle:hover { background: var(--surface-hover); }
@media (max-width: 991.98px) {
    .topbar-toggle { display: inline-flex; }
}

.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-divider {
    width: 1px; height: 24px;
    background: var(--border);
    margin: 0 4px;
}

.btn-icon {
    background: none;
    border: none;
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 16px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .12s;
}
.btn-icon:hover { background: var(--surface-hover); color: var(--text); }

/* User dropdown */
.topbar-user .user-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 4px 4px;
    background: none;
    border: 1px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    color: var(--text);
}
.topbar-user .user-button:hover {
    background: var(--surface-hover);
    border-color: var(--border);
}
.topbar-user .user-button::after { display: none; } /* remover seta padrão Bootstrap */

.user-avatar {
    width: 30px; height: 30px;
    background: var(--brand);
    color: var(--brand-on);
    border-radius: 50%;
    font-weight: 600;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.user-info { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.user-name  { font-size: 13px; font-weight: 600; }
.user-email { font-size: 11px; color: var(--text-muted); }

.user-dropdown {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius);
    padding: 6px;
    min-width: 220px;
}
.user-dropdown .dropdown-header {
    color: var(--text);
    font-weight: 600;
    padding: 8px 10px 2px;
    font-size: 13px;
}
.user-dropdown .dropdown-item-text { padding: 0 10px 6px; }
.user-dropdown .dropdown-item {
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    color: var(--text-2);
    font-size: 13.5px;
}
.user-dropdown .dropdown-item:hover {
    background: var(--surface-hover);
    color: var(--text);
}
.user-dropdown .dropdown-divider { border-color: var(--border); }

/* ============================================================
   PÁGINAS
   ============================================================ */
.page-intro {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.page-title {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.01em;
}
.page-sub {
    margin: 0;
    color: var(--text-muted);
    font-size: 13.5px;
    max-width: 720px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    color: var(--text);
}
.card .card-body { padding: 18px 20px; }
.card .card-title { color: var(--text); font-weight: 600; }

/* Health card */
.health-card .health-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.health-name {
    font-weight: 600;
    font-size: 13.5px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.health-card.health-ok    .health-name i { color: var(--success); }
.health-card.health-fail  .health-name i { color: var(--danger); }
.health-card.health-fail  { border-color: var(--danger); }
.health-latency {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--surface-2);
    padding: 2px 8px;
    border-radius: 999px;
}
.health-msg {
    color: var(--text-2);
    font-size: 12.5px;
    word-break: break-word;
}

/* Roadmap list */
.roadmap-list {
    list-style: none;
    counter-reset: rl;
    padding: 0;
    margin: 0;
}
.roadmap-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    color: var(--text-2);
    font-size: 13.5px;
}
.roadmap-list li:last-child { border-bottom: none; }
.roadmap-list li.done { color: var(--text-muted); text-decoration: line-through; }
.roadmap-list .step-num {
    flex-shrink: 0;
    width: 26px; height: 26px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-2);
    border-radius: 50%;
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.roadmap-list li.done .step-num {
    background: var(--success-soft);
    color: var(--success);
    border-color: transparent;
}
.roadmap-list .badge { margin-left: auto; }

/* ============================================================
   BOTÕES
   ============================================================ */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 13.5px;
    padding: 8px 14px;
    transition: all .12s;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-sm { font-size: 12.5px; padding: 6px 11px; }

.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--brand-on);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--brand-hover);
    border-color: var(--brand-hover);
    color: var(--brand-on);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
.btn-outline-primary {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text);
}
.btn-outline-primary:hover {
    background: var(--brand-soft);
    border-color: var(--brand);
    color: var(--brand);
}

/* ============================================================
   AUTH
   ============================================================ */
.auth-body {
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.auth-shell {
    width: 100%;
    max-width: 420px;
}

/* ============================================================
   ERROR PAGES
   ============================================================ */
.error-page {
    text-align: center;
    padding: 60px 20px;
    max-width: 480px;
    margin: 0 auto;
}
.error-code {
    font-size: 88px;
    font-weight: 800;
    color: var(--brand);
    line-height: 1;
    margin-bottom: 16px;
    letter-spacing: -.04em;
}
.error-code-danger  { color: var(--danger); }
.error-code-warning { color: var(--warning); }
.error-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}
.error-sub {
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    font-weight: 500;
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 999px;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-info    { background: var(--info-soft);    color: var(--info); }

/* ============================================================
   SCROLLBAR (suave)
   ============================================================ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
    border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ============================================================
   Etapa 2 — Tela de Login
   ============================================================ */

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    box-shadow: var(--shadow-lg);
    width: 100%;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}
.login-brand-mark {
    width: 44px;
    height: 44px;
    font-size: 22px;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 4px;
    letter-spacing: -.01em;
}
.login-sub {
    color: var(--text-muted);
    margin: 0 0 22px;
    font-size: 13.5px;
}

.login-card .form-group label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 6px;
}

.login-card .form-control {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    transition: border-color .12s, box-shadow .12s;
}
.login-card .form-control:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
    background: var(--surface);
    color: var(--text);
}
.login-card .form-control::placeholder {
    color: var(--text-faint);
}

.password-wrap {
    position: relative;
}
.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.password-toggle:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.login-card .custom-control-label {
    color: var(--text-2);
    font-size: 13.5px;
    cursor: pointer;
    padding-top: 1px;
}

.login-card .custom-control-input:checked ~ .custom-control-label::before {
    background: var(--brand);
    border-color: var(--brand);
}
.login-card .custom-control-input:focus ~ .custom-control-label::before {
    box-shadow: 0 0 0 3px var(--brand-soft);
}

.login-submit {
    margin-top: 6px;
    font-weight: 600;
    padding: 12px;
    font-size: 14px;
    justify-content: center;
}

.login-footer {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.login-card .alert {
    border-radius: var(--radius-sm);
    border: none;
    padding: 10px 14px;
    font-size: 13px;
}
.login-card .alert-danger {
    background: var(--danger-soft);
    color: var(--danger);
}
.login-card .alert-info {
    background: var(--info-soft);
    color: var(--info);
}

/* ============================================================
   Etapa 2B — Auditoria
   ============================================================ */

.audit-filters-card .form-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 4px;
    display: block;
}
.audit-filters-card .form-control-sm {
    font-size: 13px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
}
.audit-filters-card .form-control-sm:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

.audit-table {
    color: var(--text);
    font-size: 13px;
}
.audit-table thead th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
    border-top: none;
    padding: 12px 14px;
}
.audit-table tbody td {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    vertical-align: middle;
}
.audit-table tbody tr:hover {
    background: var(--surface-hover);
}
.audit-table .col-date {
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.3;
    white-space: nowrap;
}
.audit-table .col-ip {
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
    font-size: 12px;
    color: var(--text-2);
}

.action-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}
.action-success  { background: var(--success-soft); color: var(--success); }
.action-danger   { background: var(--danger-soft);  color: var(--danger); }
.action-warning  { background: var(--warning-soft); color: var(--warning); }
.action-info     { background: var(--info-soft);    color: var(--info); }
.action-secondary{ background: var(--surface-2);    color: var(--text-2); }

/* DataTables overrides */
.dataTables_wrapper {
    color: var(--text);
    padding: 16px;
}
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate { color: var(--text-muted); font-size: 12.5px; }
.dataTables_wrapper .dataTables_length select {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    color: var(--text-2) !important;
    border: 1px solid var(--border) !important;
    background: var(--surface) !important;
    border-radius: var(--radius-sm) !important;
    margin: 0 2px;
    padding: 4px 10px !important;
    font-size: 12.5px;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--brand) !important;
    border-color: var(--brand) !important;
    color: var(--brand-on) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--surface-hover) !important;
    border-color: var(--brand) !important;
    color: var(--brand) !important;
}
.dataTables_processing {
    background: var(--surface) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

/* Modal de detalhes */
#audit-detail-modal .modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
}
#audit-detail-modal .modal-header,
#audit-detail-modal .modal-footer {
    border-color: var(--border);
}
#audit-detail-modal .close { color: var(--text); opacity: .7; }

.audit-detail-list {
    margin: 0;
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 8px 14px;
    font-size: 13.5px;
}
.audit-detail-list dt {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    align-self: start;
}
.audit-detail-list dd { margin: 0; word-break: break-word; }
.audit-meta {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 12px;
    margin: 0;
    max-height: 280px;
    overflow: auto;
}
