:root {
    /* Premium Dark Theme Colors aligned with PriceXP Brand */
    --bg-main: #0b0f19;
    --bg-sidebar: #131b2f;
    --bg-card: #1c263e;
    --bg-input: #0b0f19;
    
    --text-main: #f8fafc;
    --text-muted: #6b7280;
    
    --accent-blue: #1e3a8a;
    --accent-blue-hover: #1d4ed8;
    
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

body.light-theme {
    --bg-main: #f1f5f9;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f8fafc;
    
    --text-main: #0f172a;
    --text-muted: #6b7280;
    
    --border-color: #e2e8f0;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

body.light-theme .sidebar {
    border-right: 1px solid #e2e8f0;
}

body.light-theme .nav-links li {
    color: #475569;
}

body.light-theme .nav-links li:hover {
    background-color: #f1f5f9;
    color: #0f172a;
}

body.light-theme .nav-links li.active {
    background: linear-gradient(135deg, #1e3a8a 0%, #10b981 100%) !important;
    color: white !important;
}

body.light-theme .auth-card {
    background: rgba(255, 255, 255, 0.8) !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02) !important;
}

body.light-theme .auth-card input {
    background-color: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
}

body.light-theme .auth-card input::placeholder {
    color: #94a3b8 !important;
}

body.light-theme .btn-secondary {
    background-color: #e2e8f0;
    color: #0f172a;
    border: 1px solid #cbd5e1;
}

body.light-theme .btn-secondary:hover {
    background-color: #cbd5e1 !important;
    color: #0f172a !important;
}

body.light-theme .tx-item {
    background-color: #f8fafc;
    border-color: #e2e8f0;
}

body.light-theme input, body.light-theme select, body.light-theme textarea {
    background-color: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
    color-scheme: light;
}

body.light-theme input:focus, body.light-theme select:focus, body.light-theme textarea:focus {
    border-color: #10b981;
    background-color: #ffffff;
}

body.light-theme .modal-content {
    background-color: #ffffff !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15) !important;
}

body.light-theme #details-modal-title {
    color: #0f172a !important;
}

body.light-theme #details-modal-body > div {
    background: #f8fafc !important;
    border-color: #e2e8f0 !important;
}

body.light-theme #details-modal-body > div span {
    color: #0f172a !important;
}

body.light-theme #details-modal-body > div span:last-child {
    font-weight: 700 !important;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Typography Utilities */
h1, h2, h3, h4 { font-weight: 600; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-accent { color: var(--success); }

/* Layout */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 2rem 0;
    height: 100vh;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.5rem;
    margin-bottom: 3rem;
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.logo i {
    color: #60a5fa;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0 1rem;
}

.nav-links li {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-links li:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-links li.active {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 3rem;
    overflow-y: auto;
    min-width: 0;
    height: 100vh;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}
.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.top-header {
    margin-bottom: 2rem;
}
.top-header h2 {
    font-size: 1.75rem;
}
.top-header p {
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Cards */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
}

/* Dashboard Tab */
.summary-cards {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: transform 0.2s;
}
.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.stat-icon i {
    width: 1.75rem;
    height: 1.75rem;
}

.receitas-icon { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.despesas-icon { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.saldo-icon { background: rgba(59, 130, 246, 0.1); color: var(--accent-blue); }

.stat-info h3 {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}
.stat-info p {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}
.chart-container h3 {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    color: var(--text-muted);
}
.canvas-wrapper {
    position: relative;
    height: 300px;
    width: 100%;
}
.full-width {
    grid-column: 1 / -1;
}

/* Lançamentos Tab */
.transactions-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}
.form-group.row {
    display: flex;
    gap: 1rem;
}
.col { flex: 1; }

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

input[type="text"], input[type="number"], input[type="date"], input[type="month"], input[type="email"], input[type="password"], select {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-main);
    color-scheme: dark;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

input:focus, select:focus {
    border-color: var(--accent-blue);
}

.type-selector {
    display: flex;
    gap: 1rem;
}
.radio-card {
    flex: 1;
    position: relative;
    cursor: pointer;
}
.radio-card input {
    position: absolute;
    opacity: 0;
}
.card-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    transition: all 0.2s;
}
.radio-card input:checked + .card-content {
    border-color: var(--success);
    background-color: rgba(16, 185, 129, 0.1);
}

button {
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: 0.5rem;
    padding: 0.75rem 1.5rem;
    transition: all 0.2s;
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, #1e3a8a 0%, #10b981 100%);
    color: white;
}
.btn-primary:hover {
    filter: brightness(1.15);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.btn-danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.btn-danger:hover {
    background-color: rgba(239, 68, 68, 0.2);
}

/* List Recentes */
.transaction-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
    max-height: 400px;
    overflow-y: auto;
}
/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 10px; }

.tx-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background-color: var(--bg-input);
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}
.tx-left {
    display: flex;
    flex-direction: column;
}
.tx-desc {
    font-weight: 500;
}
.tx-cat-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}
.tx-amount {
    font-weight: 600;
}
.tx-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem;
    cursor: pointer;
}
.tx-delete:hover {
    color: var(--danger);
}
.tx-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Config Tab */
.backup-container {
    max-width: 800px;
}
.backup-info {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 2rem;
}
.shield-icon {
    width: 3rem;
    height: 3rem;
    color: var(--success);
}
.backup-info p {
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.backup-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}
.action-card {
    background: var(--bg-input);
    padding: 1.5rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}
.action-card h4 { margin-bottom: 0.5rem; }
.action-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}
.danger-zone {
    border-color: rgba(239, 68, 68, 0.3);
}

@media (max-width: 1024px) {
    .transactions-layout, .charts-grid {
        grid-template-columns: 1fr;
    }
}

/* Auth Styles */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-main); /* Fallback */
    overflow: hidden;
    position: relative;
}
.auth-card {
    background: rgba(30, 41, 59, 0.7); /* Semi-transparent */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 1.5rem 2rem;
    border-radius: 1rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.auth-card .form-group {
    margin-bottom: 1rem !important;
}
.auth-card h2 {
    text-align: center;
    margin-bottom: 0.5rem;
}
.auth-card .logo {
    justify-content: center;
    margin-bottom: 2rem;
}
.text-center { text-align: center; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1.5rem; }
.justify-center { justify-content: center; }
.logout-container { margin-top: auto; padding: 1rem; }


/* New Profile and Captcha Styles */
.file-upload-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}
.file-upload-wrapper input[type="file"] {
    font-size: 100px;
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    cursor: pointer;
    height: 100%;
}
.file-upload-preview {
    border: 2px dashed var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.file-upload-wrapper:hover .file-upload-preview {
    border-color: var(--accent-color);
    color: var(--accent-color);
}
.captcha-box {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--bg-main);
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}
#captcha-question {
    font-weight: 600;
    font-size: 1.1rem;
}
.profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-color);
}
.user-details {
    display: flex;
    flex-direction: column;
}
.user-name {
    font-weight: 600;
    font-size: 0.95rem;
}
.user-email {
    font-size: 0.75rem;
    color: var(--text-muted);
}


/* Auth Styles */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-main);
}
.auth-card {
    background-color: var(--bg-card);
    padding: 2.5rem;
    border-radius: 1rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
}
.auth-card .logo {
    justify-content: center;
    margin-bottom: 2rem;
}
.text-center { text-align: center; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1.5rem; }
.justify-center { justify-content: center; }
.logout-container { margin-top: auto; padding: 1rem; }

/* New Profile and Captcha Styles */
.file-upload-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}
.file-upload-wrapper input[type="file"] {
    font-size: 100px;
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    cursor: pointer;
    height: 100%;
}
.file-upload-preview {
    border: 2px dashed var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.file-upload-wrapper:hover .file-upload-preview {
    border-color: var(--accent-color);
    color: var(--accent-color);
}
.captcha-box {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--bg-main);
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}
#captcha-question {
    font-weight: 600;
    font-size: 1.1rem;
}
.profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-color);
}
.user-details {
    display: flex;
    flex-direction: column;
}
.user-name {
    font-weight: 600;
    font-size: 0.95rem;
}
.user-email {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Profile Settings Specific Styles */
.file-upload-overlay {
    opacity: 0;
    transition: opacity 0.3s ease;
}
.file-upload-wrapper:hover .file-upload-overlay {
    opacity: 1;
}
.text-danger {
    color: var(--danger-color);
}
.btn-secondary:hover {
    background-color: var(--danger-color) !important;
    color: white !important;
}

.sidebar .user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    margin-bottom: 2rem;
}

.mobile-logout-card {
    display: none;
}

/* ==========================================================================
   MOBILE RESPONSIVENESS (SMARTPHONES)
   ========================================================================== */
@media (max-width: 768px) {
    .mobile-logout-card {
        display: block !important;
    }

    /* 1. App Layout Changes */
    .app-container {
        flex-direction: column;
        padding-bottom: 70px; /* Space for bottom nav */
    }

    .main-content {
        padding: 1.5rem 1rem;
        height: auto;
    }

    .top-header h2 {
        font-size: 1.5rem;
    }

    /* 2. Transform Sidebar to Bottom Navigation */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 70px;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border-color);
        padding: 0;
        background-color: var(--bg-sidebar);
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
    }

    /* Hide Desktop Elements from Sidebar */
    .sidebar .logo, 
    .sidebar .user-info,
    .sidebar .logout-container {
        display: none !important;
    }

    /* Restyle Nav Links for Bottom Bar */
    .nav-links {
        flex-direction: row;
        width: 100%;
        justify-content: space-around;
        padding: 0;
        margin: 0;
    }

    .nav-links li {
        flex-direction: column;
        gap: 0.2rem;
        padding: 0.5rem;
        font-size: 0.75rem;
        border-radius: 0;
        text-align: center;
        flex: 1;
        justify-content: center;
    }

    .nav-links li i {
        margin: 0 auto;
    }

    /* 3. Dashboard Adjustments */
    .summary-cards {
        flex-direction: column;
        gap: 1rem;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    /* 4. Auth Screen Adjustments */
    .auth-card {
        padding: 1.5rem;
        margin: 1rem;
    }

    .form-group.row {
        flex-direction: column;
        gap: 0;
    }

    /* Modal de Detalhes no Mobile */
    .modal-content {
        padding: 1.25rem !important;
        width: 95% !important;
        max-height: 85vh !important;
    }
    
    #btn-add-category {
        font-size: 0.8rem !important;
    }
    
    .dashboard-logo {
        height: 70px !important;
        margin-bottom: 0.5rem !important;
    }
    
    .top-header {
        text-align: center;
        justify-content: center !important;
        flex-direction: column;
        gap: 1.25rem !important;
        width: 100%;
    }
    
    .top-header > div:first-child {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
    }
    
    .top-header p {
        text-align: center;
    }
}

/* Premium Credit Card Element */
.credit-card-item {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}
.credit-card-item h4 {
    color: #ffffff !important;
}
.credit-card-item .card-label {
    color: #94a3b8 !important;
}
.credit-card-item .card-value-danger {
    color: #ef4444 !important;
}
.credit-card-item .card-value-success {
    color: #10b981 !important;
}

/* Light Theme Card Overrides */
body.light-theme .credit-card-item {
    background: linear-gradient(135deg, #1e3a8a 0%, #10b981 100%) !important;
    border: none !important;
    box-shadow: 0 10px 20px rgba(30, 58, 138, 0.15) !important;
}
body.light-theme .credit-card-item .card-label {
    color: rgba(255, 255, 255, 0.7) !important;
}
body.light-theme .credit-card-item .card-value-danger {
    color: #ffffff !important;
}
body.light-theme .credit-card-item .card-value-success {
    color: #ffffff !important;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .dashboard-logo {
        height: 60px !important;
        margin-bottom: 0.25rem !important;
    }
}
