/* ============================================================
   FinMaçon — Sistema de Controle Financeiro Maçônico
   CSS Principal v1.0
   ============================================================ */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --topbar-height: 60px;
    --transition: .25s ease;

    /* ---- Design tokens: "Ledger & Seal" ---- */
    --ink:          #16223A;   /* tinta — cor primária */
    --ink-2:        #0E1728;   /* tinta profunda (gradientes/sombra) */
    --paper:        #E9E7DD;   /* papel-pedra, base fria */
    --paper-2:      #F5F4EF;   /* papel claro (cartões sobre papel) */
    --brass:        #A9812E;   /* latão antigo — acento */
    --brass-light:  #C9A857;
    --oxblood:      #7A2E2E;   /* tinta vermelha de lançamento (débito) */
    --verdigris:    #3F6F63;   /* pátina de bronze (quitado/sucesso) */
    --slate:        #3E4247;   /* texto de corpo sobre papel */

    --font-display: 'Fraunces', 'Georgia', serif;
    --font-body:    'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono:    'IBM Plex Mono', 'Courier New', monospace;

    /* Compatibilidade com nomes antigos usados no restante do CSS */
    --primary: var(--ink);
    --primary-light: #E4E7EE;
    --sidebar-bg: var(--ink);
    --sidebar-text: rgba(255,255,255,.82);
    --sidebar-active-bg: rgba(255,255,255,.12);

    /* ---- Retema o Bootstrap 5.3 via variáveis nativas ---- */
    --bs-primary: var(--ink);
    --bs-primary-rgb: 22,34,58;
    --bs-success: var(--verdigris);
    --bs-success-rgb: 63,111,99;
    --bs-danger: var(--oxblood);
    --bs-danger-rgb: 122,46,46;
    --bs-warning: var(--brass);
    --bs-warning-rgb: 169,129,46;
    --bs-body-font-family: var(--font-body);
    --bs-border-radius: .3rem;
    --bs-border-radius-lg: .4rem;
    --bs-border-radius-sm: .25rem;
}

.btn-primary { --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff; }
.btn-warning, .btn-outline-warning:hover { --bs-btn-color: #fff; --bs-btn-hover-color: #fff; }

/* ============================================================
   Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--font-body);
    font-size: .9rem;
    color: var(--slate);
}

h1, h2, h3, .sidebar-brand, .auth-wordmark, .auth-form-title {
    font-family: var(--font-display);
}

/* ============================================================
   Admin Layout
   ============================================================ */
.admin-layout .wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    background: linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 100%);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    transition: width var(--transition), transform var(--transition);
    overflow: hidden;
}

.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
    min-height: 70px;
    display: flex;
    align-items: center;
}

.sidebar-brand {
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-logo {
    max-height: 44px;
    max-width: 100%;
    filter: brightness(10);
}

.sidebar-nav {
    list-style: none;
    padding: .5rem 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 2px; }

.nav-section-title {
    color: rgba(255,255,255,.45);
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: .75rem 1.25rem .25rem;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item .nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 0;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
}

.nav-item .nav-link i {
    font-size: 1.1rem;
    flex-shrink: 0;
    width: 1.25rem;
    text-align: center;
}

.nav-item .nav-link span { font-size: .88rem; flex: 1; }

.nav-item .nav-link:hover,
.nav-item.active .nav-link {
    background: var(--sidebar-active-bg);
    color: white;
}

.nav-item.active .nav-link {
    border-left: 3px solid var(--brass-light);
}

.sidebar-footer {
    padding: .75rem 1.25rem 1rem;
    border-top: 1px solid rgba(255,255,255,.1);
}

.sidebar-footer .nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .5rem;
    text-decoration: none;
}

/* Overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1039;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition);
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-border-color);
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 2px 4px rgba(0,0,0,.04);
}

.sidebar-toggle {
    padding: .25rem .5rem;
    color: inherit;
    text-decoration: none;
}

/* Page content */
.page-content {
    padding: 1.5rem;
    flex: 1;
}

/* ============================================================
   Stat Cards
   ============================================================ */
.stat-card {
    border-radius: 12px;
    transition: transform .2s, box-shadow .2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,.12) !important;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

/* Soft color backgrounds */
.bg-primary-soft   { background: rgba(22,34,58,.10) !important; }
.bg-success-soft   { background: rgba(63,111,99,.14) !important; }
.bg-warning-soft   { background: rgba(169,129,46,.14) !important; }
.bg-danger-soft    { background: rgba(122,46,46,.12) !important; }
.bg-info-soft      { background: rgba(63,111,99,.14) !important; }
.bg-secondary-soft { background: rgba(62,66,71,.10) !important; }

/* ============================================================
   Login Page (legado — usado pela tela de instalação)
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--ink) 0%, var(--ink-2) 100%);
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 1rem;
}

.login-card {
    border-radius: 10px;
    border: none;
}

.login-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(169,129,46,.15);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   Auth Shell — tela de login (split "Livro & Selo")
   ============================================================ */
.auth-body {
    min-height: 100vh;
    background: var(--paper);
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
}

@media (max-width: 860px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-aside { min-height: 260px; }
}

/* --- Painel esquerdo: identidade --- */
.auth-aside {
    position: relative;
    background: linear-gradient(160deg, var(--ink) 0%, var(--ink-2) 100%);
    color: rgba(255,255,255,.92);
    display: flex;
    align-items: center;
    padding: 3.5rem 3rem;
    overflow: hidden;
}

.auth-aside::before {
    /* piso em mosaico — textura discreta, referência ao pavimento da loja */
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(45deg, rgba(255,255,255,.05) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.05) 75%),
        linear-gradient(45deg, rgba(255,255,255,.05) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.05) 75%);
    background-size: 56px 56px;
    background-position: 0 0, 28px 28px;
    opacity: .5;
    pointer-events: none;
}

.auth-aside-inner { position: relative; z-index: 1; max-width: 380px; }

.compass-mark { width: 88px; height: 88px; margin-bottom: 1.75rem; overflow: visible; }
.compass-mark path, .compass-mark line, .compass-mark circle {
    fill: none;
    stroke: var(--brass-light);
    stroke-width: 2.25;
    stroke-linecap: round;
}
.compass-mark circle.hinge { fill: var(--brass-light); stroke: none; }
.compass-mark .draw {
    stroke-dasharray: 160;
    stroke-dashoffset: 160;
    animation: draw-in 1.1s ease-out forwards;
}
.compass-mark .draw:nth-of-type(1) { animation-delay: .05s; }
.compass-mark .draw:nth-of-type(2) { animation-delay: .35s; }
.compass-mark .draw:nth-of-type(3) { animation-delay: .65s; }

@keyframes draw-in { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
    .compass-mark .draw { animation: none; stroke-dashoffset: 0; }
}

.auth-eyebrow {
    font-family: var(--font-mono);
    font-size: .72rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--brass-light);
    margin-bottom: .6rem;
}

.auth-wordmark {
    font-size: 2.1rem;
    font-weight: 600;
    line-height: 1.15;
    margin-bottom: .85rem;
    color: #fff;
}

.auth-tagline {
    color: rgba(255,255,255,.68);
    font-size: .95rem;
    line-height: 1.55;
    margin-bottom: 0;
}

/* --- Painel direito: formulário --- */
.auth-form-panel {
    background: var(--paper);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
}

.auth-form-card { width: 100%; max-width: 360px; }

.auth-logo { max-height: 56px; margin-bottom: 1.5rem; }

.auth-form-eyebrow {
    font-family: var(--font-mono);
    font-size: .72rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--brass);
    margin-bottom: .35rem;
}

.auth-form-title {
    font-size: 1.9rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 1.75rem;
}

.auth-field { margin-bottom: 1.25rem; }

.auth-field label {
    display: block;
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .02em;
    color: var(--slate);
    margin-bottom: .4rem;
}

.auth-input-group {
    display: flex;
    align-items: center;
    gap: .6rem;
    border: none;
    border-bottom: 1.5px solid rgba(22,34,58,.25);
    background: transparent;
    padding: .55rem .1rem;
    transition: border-color var(--transition);
}

.auth-input-group:focus-within { border-bottom-color: var(--brass); }

.auth-input-group i { color: var(--brass); font-size: 1rem; flex-shrink: 0; }

.auth-input-group input {
    border: none;
    background: transparent;
    outline: none;
    flex: 1;
    font-family: var(--font-body);
    font-size: .95rem;
    color: var(--ink);
    padding: 0;
}

.auth-input-group button {
    border: none;
    background: transparent;
    color: var(--slate);
    padding: 0;
    line-height: 1;
}

.auth-submit {
    width: 100%;
    background: var(--ink);
    color: #fff;
    border: none;
    border-radius: 3px;
    padding: .7rem 1rem;
    font-weight: 600;
    font-size: .95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    transition: background var(--transition);
}

.auth-submit:hover { background: var(--ink-2); color: #fff; }

.auth-note {
    border-left: 3px solid;
    padding: .6rem .85rem;
    font-size: .85rem;
    margin-bottom: 1.25rem;
    border-radius: 2px;
    display: flex;
    align-items: flex-start;
    gap: .5rem;
}

.auth-note.is-error  { background: rgba(122,46,46,.08); border-color: var(--oxblood); color: var(--oxblood); }
.auth-note.is-success{ background: rgba(63,111,99,.08); border-color: var(--verdigris); color: var(--verdigris); }

.auth-footer-note {
    text-align: center;
    color: rgba(62,66,71,.6);
    font-size: .78rem;
    margin-top: 1.75rem;
}

/* ============================================================
   Avatar
   ============================================================ */
.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: .75rem;
}

/* ============================================================
   Tables
   ============================================================ */
.table th {
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--bs-secondary-color);
}

/* ============================================================
   Dark mode adjustments
   ============================================================ */
[data-bs-theme="dark"] .topbar {
    border-color: rgba(255,255,255,.1);
}

[data-bs-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #0d1117 0%, #1a237e 100%);
}

[data-bs-theme="dark"] .card {
    border-color: rgba(255,255,255,.08);
}

/* ============================================================
   Sidebar collapsed (mobile)
   ============================================================ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

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

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

    .main-content {
        margin-left: 0;
    }

    .page-content {
        padding: 1rem;
    }
}

/* ============================================================
   Print
   ============================================================ */
@media print {
    .sidebar, .topbar, .no-print, .btn, .alert { display: none !important; }
    .main-content { margin: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ============================================================
   Utils
   ============================================================ */
.cursor-pointer { cursor: pointer; }
.fs-tiny { font-size: .75rem; }
.border-start-4 { border-left-width: 4px !important; }

/* Badge utils */
.badge { font-weight: 600; }

/* Card hover */
.card-hover:hover { box-shadow: 0 8px 30px rgba(0,0,0,.1) !important; }
