/* ============================================ */
/* COLOR PALETTE - EASY TO CUSTOMIZE */
/* ============================================ */
:root {
    --c-bg: #FFFFFF;
    --c-surface: #f0e7d84d;
    --c-surface-2: #e8ddd083;
    --c-border: #e7dcd0;
    --c-accent: #18435A;
    --c-accent-text: #FFFFFF;
    --c-muted: #f6eeec;
    --c-text: #1A1A1A;
    --c-text-secondary: #6B5E58;
    --c-green: #B6DC76;
    --c-red: #A54657;
    --c-green-text: #3D5A1A;
    --c-red-text: #FFFFFF;
    --c-shadow: rgba(0,0,0,0.08);
}

[data-theme="dark"] {
    --c-bg: #090909;
    --c-surface: #141414;
    --c-surface-2: #503047;
    --c-border: #2A2A2A;
    --c-accent: #7E846B;
    --c-accent-text: #F0E7D8;
    --c-muted: #7E846B;
    --c-text: #F0E7D8;
    --c-text-secondary: #AB9B96;
    --c-green: #B6DC76;
    --c-red: #A54657;
    --c-green-text: #090909;
    --c-red-text: #F0E7D8;
    --c-shadow: rgba(0,0,0,0.4);
}

/* ============================================ */
/* LAYOUT */
/* ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--c-bg);
    color: var(--c-text);
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s, color 0.3s;
}

.app-header {
    display: none;
    height: 56px;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    align-items: center;
    padding: 0 16px;
    padding-top: max(0, env(safe-area-inset-top));
    position: relative;
    z-index: 100;
}

.hamburger {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--c-text);
    padding: 8px;
    margin: -8px 8px -8px -8px;
}

.header-title {
    flex: 1;
    text-align: center;
    font-weight: 600;
    font-size: 18px;
}

.drawer-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 98;
}

.drawer-overlay.open {
    display: block;
}

.drawer {
    position: fixed;
    left: -280px;
    top: 0;
    width: 280px;
    height: 100%;
    background: var(--c-surface);
    z-index: 99;
    transition: left 0.3s ease;
    overflow-y: auto;
    padding-top: env(safe-area-inset-top);
}

.drawer.open {
    left: 0;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 16px;
    border-bottom: 1px solid var(--c-border);
}

.drawer-header h1 {
    font-size: 20px;
    font-weight: 700;
}

.drawer-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--c-text);
    padding: 8px;
    margin: -8px -8px -8px 8px;
}

.drawer .nav {
    list-style: none;
}

.drawer .nav li {
    border-bottom: 1px solid var(--c-border);
}

.drawer .nav button {
    width: 100%;
    padding: 16px;
    background: none;
    border: none;
    text-align: left;
    font-size: 16px;
    cursor: pointer;
    color: var(--c-text);
    transition: background-color 0.2s;
}

.drawer .nav button:active,
.drawer .nav button.active {
    background: var(--c-surface-2);
}

.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ============================================ */
/* DESKTOP LAYOUT */
/* ============================================ */
@media (min-width: 769px) {
    body {
        flex-direction: row;
    }

    .app-header {
        display: none !important;
    }

    .drawer-overlay {
        display: none !important;
    }

    .drawer {
        position: static;
        left: auto;
        width: 250px;
        height: auto;
        border-right: 1px solid var(--c-border);
        padding-top: 20px;
    }

    .drawer-header {
        padding: 20px;
    }

    .drawer-header h1 {
        font-size: 24px;
    }

    .drawer-close {
        display: none;
    }

    .main-content {
        flex: 1;
        padding: 40px;
    }
}

/* ============================================ */
/* MOBILE LAYOUT */
/* ============================================ */
@media (max-width: 768px) {
    .app-header {
        display: flex;
    }

    .main-content {
        padding: 16px;
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}

/* ============================================ */
/* TYPOGRAPHY & COMMON */
/* ============================================ */
h2 {
    font-size: 20px;
    margin-bottom: 16px;
    font-weight: 700;
    color: var(--c-text);
}

h3 {
    font-size: 16px;
    margin-bottom: 12px;
    font-weight: 600;
    color: var(--c-text);
}

p {
    font-size: 14px;
    color: var(--c-text-secondary);
    line-height: 1.5;
}

input, select {
    font-size: 16px;
    font-family: inherit;
    color: var(--c-text);
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    padding: 10px 12px;
    border-radius: 6px;
    transition: border-color 0.2s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--c-accent);
    box-shadow: 0 0 0 3px rgba(24, 67, 90, 0.1);
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus {
    box-shadow: 0 0 0 3px rgba(126, 132, 107, 0.2);
}

button {
    font-size: 16px;
    font-weight: 600;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--c-accent);
    color: var(--c-accent-text);
    width: 100%;
}

.btn-primary:active {
    opacity: 0.9;
}

/* ============================================ */
/* FORM */
/* ============================================ */
.form-container {
    max-width: 400px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 16px;
}

.type-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 24px;
}

.toggle-btn {
    padding: 12px;
    border: 2px solid var(--c-border);
    background: var(--c-surface);
    color: var(--c-text);
    border-radius: 6px;
    font-weight: 600;
    width: 100%;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn.active {
    border-color: var(--c-accent);
    background: var(--c-accent);
    color: var(--c-accent-text);
}

.amount-input-container {
    text-align: center;
    margin: 32px 0;
}

#amount {
    font-size: 36px;
    font-weight: 700;
    text-align: center;
    border: none;
    background: none;
    padding: 16px 0;
    width: 100%;
}

#amount::placeholder {
    color: var(--c-muted);
}

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

/* ============================================ */
/* DASHBOARD */
/* ============================================ */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.month-picker {
    display: flex;
    align-items: center;
    gap: 12px;
}

.month-picker button {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    background: var(--c-accent);
    color: var(--c-accent-text);
    font-size: 18px;
    font-weight: bold;
}

.month-picker button:active {
    opacity: 0.9;
}

#monthLabel {
    min-width: 120px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
}

.stats {
    display: grid;
    gap: 12px;
    margin-bottom: 24px;
}

@media (max-width: 768px) {
    .stats {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 769px) {
    .stats {
        grid-template-columns: repeat(4, 1fr);
    }
}

.stat-card {
    background: var(--c-surface);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--c-border);
    text-align: center;
}

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--c-text-secondary);
    margin-bottom: 8px;
    font-weight: 600;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--c-text);
}

.stat-card.income-card .stat-value {
    color: var(--c-green);
}

.stat-card.expense-card .stat-value {
    color: var(--c-red);
}

.top-categories {
    background: var(--c-surface);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--c-border);
    margin-bottom: 24px;
}

.category-ranking {
    display: flex;
    align-items: center;
    padding: 12px;
    background: var(--c-bg);
    margin-bottom: 8px;
    border-radius: 6px;
    border: 1px solid var(--c-border);
    gap: 12px;
}

.category-rank {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--c-accent);
    color: var(--c-accent-text);
    border-radius: 50%;
    font-weight: 700;
    flex-shrink: 0;
}

.category-ranking-name {
    flex: 1;
    font-weight: 600;
    color: var(--c-text);
}

.category-ranking-amount {
    font-weight: 700;
    color: var(--c-red);
}

.expenses-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.expense-item {
    background: var(--c-surface);
    padding: 12px;
    border-radius: 6px;
    border: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.expense-info {
    flex: 1;
}

.expense-description {
    font-weight: 600;
    color: var(--c-text);
    margin-bottom: 4px;
}

.expense-date {
    font-size: 12px;
    color: var(--c-text-secondary);
}

.transaction-type-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    margin-right: 4px;
}

.transaction-type-badge.expense {
    background: var(--c-red);
    color: var(--c-red-text);
}

.transaction-type-badge.income {
    background: var(--c-green);
    color: var(--c-green-text);
}

.expense-category {
    display: inline-block;
    background: var(--c-muted);
    color: var(--c-bg);
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    margin-left: 8px;
}

.transaction-amount {
    font-weight: 700;
    color: var(--c-red);
    white-space: nowrap;
}

.transaction-amount.income {
    color: var(--c-green);
}

.delete-btn {
    background: var(--c-red);
    color: var(--c-red-text);
    padding: 6px 12px;
    font-size: 12px;
    flex-shrink: 0;
}

.delete-btn:active {
    opacity: 0.9;
}

.empty-state {
    text-align: center;
    padding: 24px;
    color: var(--c-text-secondary);
}

/* ============================================ */
/* SETTINGS */
/* ============================================ */
.settings-grid {
    display: grid;
    gap: 16px;
}

@media (min-width: 769px) {
    .settings-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.settings-section {
    background: var(--c-surface);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--c-border);
}

.category-list {
    margin-bottom: 12px;
    min-height: 50px;
}

.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--c-bg);
    padding: 10px;
    margin-bottom: 6px;
    border-radius: 5px;
    border: 1px solid var(--c-border);
    gap: 8px;
}

.category-item-name {
    flex: 1;
    font-size: 14px;
}

.category-remove-btn {
    background: var(--c-red);
    color: var(--c-red-text);
    padding: 4px 8px;
    font-size: 12px;
    flex-shrink: 0;
}

.category-remove-btn:active {
    opacity: 0.9;
}

.add-category {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.add-category input,
.add-category select {
    min-width: 0;
}

.add-category button {
    background: var(--c-accent);
    color: var(--c-accent-text);
    padding: 10px 16px;
    width: auto;
}

.add-category button:active {
    opacity: 0.9;
}
