/* HORUS / SEIP — paleta + componentes base. */

:root {
    --dark:    #0D1F35;
    --navy:    #1A3A5C;
    --navy2:   #234b73;
    --gold:    #C9A227;
    --gold-lt: #E8C35A;
    --gold-bg: #FDF6E3;
    --bg:      #F4F6F9;
    --bg-2:    #EDF0F4;
    --white:   #FFFFFF;
    --text:    #1C2B3A;
    --text-2:  #5A6A7A;
    --text-3:  #7A8A9A;
    --border:  #DDE3EA;
    --success: #27AE60;
    --warning: #E67E22;
    --danger:  #C0392B;
    --info:    #2980B9;

    --radius: 10px;
    --shadow-sm: 0 1px 2px rgba(13,31,53,.06);
    --shadow: 0 4px 16px rgba(13,31,53,.08);
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }
.muted { color: var(--text-2); }
.tiny  { font-size: 12px; color: var(--text-3); }

/* ============== Auth shell ============== */
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--dark) 0%, var(--navy) 60%, var(--navy2) 100%);
    padding: 24px;
}
.auth-card {
    background: var(--white);
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 28px;
}
.auth-card .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 18px;
    letter-spacing: .3px;
}
.auth-card .brand-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-bg);
}
.auth-card h1 {
    font-size: 22px;
    margin: 0 0 6px;
    color: var(--text);
}
.auth-card .sub {
    margin: 0 0 18px;
    color: var(--text-2);
    font-size: 14px;
}
.auth-card .helper {
    margin-top: 14px;
    font-size: 12px;
    color: var(--text-3);
    text-align: center;
}

/* ============== Forms ============== */
.field { display: block; margin-bottom: 12px; }
.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}
.field input, .field select, .field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    color: var(--text);
    background: var(--white);
    outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(201,162,39,.18);
}

/* ============== Buttons ============== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    background: var(--bg-2);
    color: var(--text);
}
.btn:hover { background: var(--border); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover { background: var(--navy2); }
.btn-gold { background: var(--gold); color: var(--dark); }
.btn-gold:hover { background: var(--gold-lt); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 13px; }

/* ============== Alerts ============== */
.alert {
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 14px;
    border: 1px solid;
}
.alert-error   { background: #FBEAEA; color: #8C1F1F; border-color: #F0C4C4; }
.alert-success { background: #E7F6EC; color: #1E6B3A; border-color: #BFE5CC; }
.alert-info    { background: #E5F0FA; color: #1B5A8A; border-color: #BDD8EE; }

/* ============== Loader ============== */
.loader {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============== App shell ============== */
.app-shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.topbar {
    background: var(--dark);
    color: var(--white);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--gold);
}
.topbar .brand { font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; gap: 10px; }
.topbar .brand .brand-dot { background: var(--gold); width: 10px; height: 10px; border-radius: 50%; }

/* ============== Layout com sidebar (body.has-sidebar) ============== */
body.has-sidebar {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}
body.has-sidebar > .app-shell {
    grid-column: 2;
    min-width: 0;
}
body.has-sidebar .topbar { padding-left: 24px; }

/* Sidebar */
.sidebar {
    grid-column: 1;
    background: var(--dark);
    color: rgba(255,255,255,.85);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,.06);
    position: sticky;
    top: 0;
    height: 100vh;
}
.side-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px 14px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    color: white;
}
.side-brand .brand-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 0 3px rgba(201,162,39,.18);
    flex-shrink: 0;
}
.side-brand-title { font-weight: 700; letter-spacing: 1px; font-size: 16px; }
.side-brand-sub { font-size: 11px; color: rgba(255,255,255,.45); letter-spacing: .4px; }

.side-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0 16px;
}
.side-nav::-webkit-scrollbar { width: 6px; }
.side-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }

.side-group { padding: 6px 0; }
.side-group h4 {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,.42);
    padding: 14px 20px 6px;
    margin: 0;
    font-weight: 700;
}

.side-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 20px 9px 17px;
    color: rgba(255,255,255,.78);
    text-decoration: none;
    font-size: 13.5px;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
}
.side-item:hover {
    background: rgba(255,255,255,.05);
    color: white;
    text-decoration: none;
}
.side-item.active {
    background: rgba(201,162,39,.10);
    color: var(--gold-lt);
    border-left-color: var(--gold);
}
.side-item.disabled {
    color: rgba(255,255,255,.32);
    cursor: not-allowed;
    pointer-events: none;
}
.side-item .soon-badge {
    margin-left: auto;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: .5px;
    background: rgba(255,255,255,.08);
    color: rgba(255,255,255,.5);
    padding: 1px 6px;
    border-radius: 8px;
}

.side-foot {
    padding: 14px 18px;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 10px;
}
.side-user { flex: 1; min-width: 0; }
.side-user-name {
    color: white;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.side-user-role {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(201,162,39,.85);
}
.side-foot .btn {
    background: rgba(255,255,255,.08);
    color: white;
    border: 1px solid rgba(255,255,255,.12);
}
.side-foot .btn:hover { background: rgba(255,255,255,.14); }

/* Toggle mobile */
.side-toggle-open,
.side-toggle-close {
    display: none;
    background: var(--dark);
    color: white;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
}
.side-toggle-open {
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 60;
    box-shadow: var(--shadow);
}
.side-toggle-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    color: rgba(255,255,255,.7);
    font-size: 24px;
}

/* Responsivo: <900px sidebar vira drawer */
@media (max-width: 900px) {
    body.has-sidebar { grid-template-columns: 1fr; }
    body.has-sidebar > .app-shell { grid-column: 1; }
    body.has-sidebar .topbar { padding-left: 64px; }

    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        width: 240px;
        z-index: 80;
        transition: left .25s ease;
        box-shadow: 4px 0 30px rgba(0,0,0,.3);
    }
    body.sidebar-open .sidebar { left: 0; }
    body.sidebar-open::after {
        content: '';
        position: fixed; inset: 0;
        background: rgba(0,0,0,.45);
        z-index: 70;
    }

    .side-toggle-open { display: inline-flex; }
    .side-toggle-close { display: inline-flex; }
}
.topbar .user {
    display: flex; align-items: center; gap: 12px; font-size: 14px;
}
.topbar .badge {
    background: var(--gold); color: var(--dark); border-radius: 4px;
    padding: 2px 8px; font-size: 12px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .5px;
}

.app-main { padding: 24px; max-width: 1200px; margin: 0 auto; width: 100%; }

/* ============== Cards / panels ============== */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card h2 { margin: 0 0 12px; font-size: 18px; color: var(--navy); }

/* ============== Tables ============== */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table th { background: var(--bg-2); color: var(--text-2); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.table tbody tr:hover { background: var(--bg); }

/* ============== Permissions matrix (admin/usuarios) ============== */
.perm-group {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
}
.perm-group-header {
    background: var(--bg-2);
    padding: 10px 14px;
    font-weight: 600;
    color: var(--navy);
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.perm-group-body { padding: 12px 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.perm-item { display: flex; align-items: center; gap: 8px; }
.perm-item label { font-size: 13px; color: var(--text); cursor: pointer; }
.perm-item select { padding: 4px 6px; font-size: 12px; border: 1px solid var(--border); border-radius: 4px; background: var(--white); }
.perm-state-default { color: var(--text-3); font-size: 11px; }
.perm-state-allow { color: var(--success); font-weight: 600; }
.perm-state-deny  { color: var(--danger); font-weight: 600; }

.role-pill {
    display: inline-block; padding: 2px 8px; border-radius: 10px;
    font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px;
}
.role-admin    { background: var(--gold-bg); color: #7a5e10; }
.role-user     { background: #E5F0FA; color: #1B5A8A; }

.status-pill { font-size: 11px; padding: 1px 6px; border-radius: 4px; font-weight: 600; }
.status-active    { background: var(--success); color: white; }
.status-suspended { background: var(--danger);  color: white; }
.status-pending   { background: var(--warning); color: white; }

/* Linha destacada quando a campanha está ativa no contexto */
.row-ativa { background: linear-gradient(90deg, rgba(201,162,39,.08), transparent); }
.row-ativa td:first-child { border-left: 3px solid var(--gold); }

/* Seletor de campanha na topbar */
.campanha-switcher {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(255,255,255,.08);
    padding: 4px 10px; border-radius: 6px;
    color: white; font-size: 13px;
    cursor: pointer; border: 1px solid rgba(255,255,255,.15);
}
.campanha-switcher:hover { background: rgba(255,255,255,.14); }
.campanha-switcher select {
    background: transparent; color: white; border: none;
    font: inherit; cursor: pointer; outline: none;
    padding-right: 16px;
}
.campanha-switcher select option { color: var(--text); background: var(--white); }
.campanha-empty {
    color: rgba(255,255,255,.7); font-size: 13px; font-style: italic;
}
