/* ============================================
   Df Caixa Gilgal — Design System
   Mobile-first • Dark Theme • Glassmorphism
   ============================================ */

/* === RESET & VARIABLES === */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: rgba(30, 30, 60, 0.6);
    --bg-card-sm: rgba(30, 30, 60, 0.4);
    --bg-input: rgba(255, 255, 255, 0.06);
    --bg-hover: rgba(255, 255, 255, 0.08);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-primary: #7c3aed;
    --accent-secondary: #a78bfa;
    --accent-glow: rgba(124, 58, 237, 0.3);

    --green: #34d399;
    --green-bg: rgba(52, 211, 153, 0.12);
    --red: #f87171;
    --red-bg: rgba(248, 113, 113, 0.12);
    --blue: #60a5fa;
    --orange: #fb923c;
    --pink: #f472b6;
    --yellow: #fbbf24;

    --gradient-primary: linear-gradient(135deg, #7c3aed, #a78bfa);
    --gradient-success: linear-gradient(135deg, #059669, #34d399);
    --gradient-danger: linear-gradient(135deg, #dc2626, #f87171);
    --gradient-accent: linear-gradient(135deg, #7c3aed, #ec4899);
    --gradient-bg: linear-gradient(180deg, #0f0f1a 0%, #1a1a2e 100%);

    --border-glass: 1px solid rgba(255, 255, 255, 0.08);
    --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px var(--accent-glow);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 50%;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --header-h: 60px;
    --nav-h: 70px;
    --z-header: 100;
    --z-nav: 100;
    --z-modal: 200;
    --z-toast: 300;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font);
    background: var(--gradient-bg);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* === TOAST === */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-120px);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    z-index: var(--z-toast);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(20px);
    max-width: 90vw;
    text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast-success { background: rgba(5, 150, 105, 0.9); color: #fff; }
.toast-error { background: rgba(220, 38, 38, 0.9); color: #fff; }
.toast-info { background: rgba(124, 58, 237, 0.9); color: #fff; }

/* === PAGES === */
.page { display: none; animation: fadeIn 0.3s ease; }
.page.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ===========================
   LOGIN
   =========================== */
.page-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.page-login::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    top: -100px;
    right: -100px;
    pointer-events: none;
}

.page-login::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.15) 0%, transparent 70%);
    bottom: -80px;
    left: -80px;
    pointer-events: none;
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.login-card {
    padding: 40px 30px;
    text-align: center;
    animation: slideUp 0.6s ease;
}

.login-logo { margin-bottom: 32px; }

.logo-icon {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 2rem;
    color: #fff;
    box-shadow: var(--shadow-glow);
    animation: pulse 3s ease infinite;
}

.login-card h1 {
    font-size: 1.8rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 4px;
}

#form-login { display: flex; flex-direction: column; gap: 16px; }

/* === GLASS CARDS === */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
}

.glass-card-sm {
    background: var(--bg-card-sm);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: var(--border-glass);
    border-radius: var(--radius-md);
}

/* === INPUTS === */
.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-group i {
    position: absolute;
    left: 16px;
    color: var(--text-muted);
    font-size: 0.9rem;
    z-index: 1;
}

.input-group input {
    width: 100%;
    padding: 14px 16px 14px 44px;
    background: var(--bg-input);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
}

.input-group input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-group input::placeholder { color: var(--text-muted); }

/* === FORM ELEMENTS === */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group label i {
    width: 18px;
    text-align: center;
    margin-right: 4px;
    font-size: 0.8rem;
}

.form-group input,
.form-group select {
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
    width: 100%;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group select { cursor: pointer; }
.form-group select option { background: var(--bg-secondary); color: var(--text-primary); }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-card {
    padding: 24px;
    margin-bottom: 20px;
}

.form-card form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.filter-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(255,255,255,0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.btn:hover::after { opacity: 1; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary { background: var(--gradient-primary); color: #fff; box-shadow: 0 4px 16px var(--accent-glow); }
.btn-success { background: var(--gradient-success); color: #fff; box-shadow: 0 4px 16px rgba(5, 150, 105, 0.3); }
.btn-danger { background: var(--gradient-danger); color: #fff; box-shadow: 0 4px 16px rgba(220, 38, 38, 0.3); }
.btn-accent { background: var(--gradient-accent); color: #fff; box-shadow: 0 4px 16px rgba(236, 72, 153, 0.3); }

.btn-full { width: 100%; }
.btn-large { padding: 16px 24px; font-size: 1.05rem; border-radius: var(--radius-md); }

.btn-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.1rem;
}

.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

/* === HEADER === */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    background: rgba(15, 15, 26, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: var(--z-header);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #fff;
}

.app-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* === MAIN === */
.app-main {
    padding: calc(var(--header-h) + 16px) 16px calc(var(--nav-h) + 16px);
    max-width: 800px;
    margin: 0 auto;
}

.page-header {
    margin-bottom: 20px;
}

.page-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

.page-header h2 i {
    margin-right: 8px;
    font-size: 1.2rem;
}

.section-title {
    margin: 24px 0 12px;
}

.section-title h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.section-title h3 i {
    margin-right: 6px;
    font-size: 0.9rem;
}

/* === STATS GRID === */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-card {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: var(--transition);
    animation: slideUp 0.5s ease both;
}

.stat-card:nth-child(1) { animation-delay: 0s; }
.stat-card:nth-child(2) { animation-delay: 0.05s; }
.stat-card:nth-child(3) { animation-delay: 0.1s; }
.stat-card:nth-child(4) { animation-delay: 0.15s; }
.stat-card:nth-child(5) { animation-delay: 0.2s; }

.stat-card:first-child {
    grid-column: 1 / -1;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.stat-total .stat-icon { background: rgba(124, 58, 237, 0.15); color: var(--accent-secondary); }
.stat-dinheiro .stat-icon { background: rgba(52, 211, 153, 0.15); color: var(--green); }
.stat-banco .stat-icon { background: rgba(96, 165, 250, 0.15); color: var(--blue); }
.stat-entradas .stat-icon { background: var(--green-bg); color: var(--green); }
.stat-saidas .stat-icon { background: var(--red-bg); color: var(--red); }

.stat-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === MOVIMENTAÇÕES LIST === */
.movimentacoes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mov-card {
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
    cursor: default;
}

.mov-card:hover { background: var(--bg-hover); }

.mov-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.mov-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mov-desc {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mov-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.mov-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.mov-valor {
    font-size: 0.9rem;
    font-weight: 700;
}

.valor-entrada { color: var(--green); }
.valor-saida { color: var(--red); }

.btn-cupom {
    background: rgba(124, 58, 237, 0.15);
    border: none;
    color: var(--accent-secondary);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font);
    transition: var(--transition);
}

.btn-cupom:hover { background: rgba(124, 58, 237, 0.3); }

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 12px;
    display: block;
    opacity: 0.4;
}

.empty-state p {
    font-size: 0.9rem;
}

/* === UPLOAD AREA === */
.upload-area {
    position: relative;
    border: 2px dashed rgba(255,255,255,0.12);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
    min-height: 120px;
}

.upload-area:hover { border-color: var(--accent-primary); }

.file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
    width: 100%;
    height: 100%;
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    gap: 8px;
    color: var(--text-muted);
    pointer-events: none;
}

.upload-placeholder i { font-size: 2rem; color: var(--accent-secondary); }
.upload-placeholder span { font-size: 0.9rem; font-weight: 500; }
.upload-placeholder small { font-size: 0.75rem; }

.upload-preview {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.upload-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--radius-sm);
    object-fit: contain;
}

.btn-remove-preview {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: rgba(220, 38, 38, 0.8);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    z-index: 3;
    transition: var(--transition);
}

.btn-remove-preview:hover { background: rgba(220, 38, 38, 1); transform: scale(1.1); }

/* === FILTRO RESUMO === */
.filtro-resumo {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.filtro-resumo span {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
}

.resumo-entradas { background: var(--green-bg); color: var(--green); }
.resumo-saidas { background: var(--red-bg); color: var(--red); }
.resumo-saldo { background: rgba(124, 58, 237, 0.12); color: var(--accent-secondary); }

/* === BOTTOM NAV === */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-h);
    background: rgba(15, 15, 26, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: var(--z-nav);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.65rem;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    position: relative;
}

.nav-item i { font-size: 1.2rem; transition: var(--transition); }

.nav-item.active {
    color: var(--accent-secondary);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: var(--gradient-primary);
    border-radius: 0 0 3px 3px;
}

.nav-item:hover { color: var(--text-secondary); }

/* === MODAL === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    position: relative;
    animation: slideUp 0.3s ease;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: rgba(255,255,255,0.1);
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.modal-close:hover { background: rgba(255,255,255,0.2); color: var(--text-primary); }

.modal-content h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.modal-cupom-img {
    width: 100%;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.modal-details p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.modal-details strong {
    color: var(--text-primary);
}

/* ===========================
   DESKTOP (>= 768px)
   =========================== */
@media (min-width: 768px) {
    .app-main {
        padding: calc(var(--header-h) + 24px) 24px 40px;
    }

    .bottom-nav {
        position: fixed;
        top: var(--header-h);
        left: 0;
        bottom: 0;
        right: auto;
        width: 220px;
        height: auto;
        flex-direction: column;
        justify-content: flex-start;
        padding: 20px 12px;
        gap: 4px;
        border-top: none;
        border-right: var(--border-glass);
    }

    .nav-item {
        flex-direction: row;
        width: 100%;
        justify-content: flex-start;
        gap: 12px;
        padding: 12px 16px;
        font-size: 0.85rem;
        border-radius: var(--radius-md);
    }

    .nav-item.active::before {
        top: 50%;
        left: -12px;
        transform: translateY(-50%);
        width: 3px;
        height: 24px;
        border-radius: 0 3px 3px 0;
    }

    .app-main {
        margin-left: 220px;
        max-width: 900px;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .stat-card:first-child {
        grid-column: 1 / 2;
    }

    .btn-group {
        flex-direction: row;
    }

    .login-card {
        padding: 48px 40px;
    }
}

/* ===========================
   LARGE DESKTOP (>= 1200px)
   =========================== */
@media (min-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .stat-card:first-child {
        grid-column: 1 / 2;
    }
}

.admin-login-link {
    position: absolute;
    bottom: 20px;
    right: 20px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    opacity: 0.5;
}

.admin-login-link:hover {
    color: var(--accent-secondary);
    opacity: 1;
}
/* === WATERMARK === */
.app-watermark {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100vw;
    height: 100vh;
    opacity: 0.03;
    pointer-events: none;
    z-index: 0;
    filter: grayscale(1);
    display: none;
}

.app-watermark img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Garante que a logo não distorça e preencha o máximo mantendo proporção */
}

/* === ADMIN UI === */
.page-admin-login {
    background: radial-gradient(circle at center, #1a1a2e 0%, #0f0f1a 100%) !important;
}

.admin-header-badge {
    background: var(--gradient-primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    color: white;
    margin-left: 8px;
    text-transform: uppercase;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}
