/* ============================================
   FINANCE TRACKER - Dark Theme
   Modern banking app inspired design
   ============================================ */

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-input: #0f172a;
    --border: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --info: #3b82f6;
    --income: #10b981;
    --expense: #ef4444;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --radius: 16px;
    --radius-sm: 10px;
    --nav-height: 70px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ============ LAYOUT ============ */

.app-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
}

.main-content {
    padding: 0 16px 100px;
    min-height: 100vh;
}

/* ============ TOP BAR ============ */

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    margin-bottom: 8px;
}

.top-bar h1 {
    font-size: 20px;
    font-weight: 600;
}

.top-bar .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.top-bar .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

/* ============ BALANCE CARD ============ */

.balance-card {
    background: linear-gradient(135deg, #4f46e5, #6366f1, #818cf8);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.balance-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

.balance-card .label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 4px;
}

.balance-card .amount {
    font-size: 32px;
    font-weight: 700;
    color: white;
    margin-bottom: 16px;
}

.balance-card .wallets-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.balance-card .wallet-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    color: white;
    white-space: nowrap;
}

.balance-card .wallet-chip .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* ============ SUMMARY CARDS ============ */

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.summary-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 16px;
    border: 1px solid var(--border);
}

.summary-card .icon-wrap {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    font-size: 16px;
}

.summary-card .icon-wrap.income {
    background: var(--success-bg);
    color: var(--success);
}

.summary-card .icon-wrap.expense {
    background: var(--danger-bg);
    color: var(--danger);
}

.summary-card .label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.summary-card .value {
    font-size: 18px;
    font-weight: 600;
}

.summary-card .value.income { color: var(--success); }
.summary-card .value.expense { color: var(--danger); }

/* ============ SECTION ============ */

.section {
    margin-bottom: 24px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.section-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.section-header a {
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
}

/* ============ TRANSACTION LIST ============ */

.transaction-list {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

.transaction-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}

.transaction-item:last-child {
    border-bottom: none;
}

.transaction-item:active {
    background: rgba(255, 255, 255, 0.03);
}

.transaction-item .icon-circle {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.transaction-item .icon-circle svg {
    width: 18px;
    height: 18px;
}

.transaction-item .info {
    flex: 1;
    min-width: 0;
}

.transaction-item .info .name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.transaction-item .info .meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.transaction-item .amount {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.transaction-item .amount.income { color: var(--success); }
.transaction-item .amount.expense { color: var(--danger); }

/* ============ CHART ============ */

.chart-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 16px;
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.chart-card h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 120px;
    padding-top: 10px;
}

.chart-bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.chart-bar .bar {
    width: 100%;
    max-width: 32px;
    border-radius: 6px 6px 2px 2px;
    background: var(--accent);
    min-height: 4px;
    transition: height 0.3s ease;
}

.chart-bar .bar.empty {
    background: var(--border);
}

.chart-bar .day-label {
    font-size: 10px;
    color: var(--text-muted);
}

.chart-bar .date-label {
    font-size: 9px;
    color: var(--text-muted);
    opacity: 0.6;
}

/* ============ CARDS ============ */

.card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 16px;
    border: 1px solid var(--border);
    margin-bottom: 12px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

/* ============ FORMS ============ */

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ============ BUTTONS ============ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn svg {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-block {
    width: 100%;
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 8px;
}

/* ============ TYPE TOGGLE ============ */

.type-toggle {
    display: flex;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 4px;
    border: 1px solid var(--border);
}

.type-toggle input {
    display: none;
}

.type-toggle label {
    flex: 1;
    padding: 10px;
    text-align: center;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.type-toggle input:checked + label.income-label {
    background: var(--success-bg);
    color: var(--success);
}

.type-toggle input:checked + label.expense-label {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ============ FILTER BAR ============ */

.filter-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 16px;
}

.filter-bar .filter-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.filter-bar .filter-chip.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* ============ EMPTY STATE ============ */

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

.empty-state .lucide, .empty-state svg[data-lucide] {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 13px;
    margin-bottom: 20px;
}

/* ============ BOTTOM NAV ============ */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: var(--nav-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 8px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 10px;
    transition: color 0.2s;
}

.nav-item .lucide, .nav-item svg[data-lucide] {
    width: 20px;
    height: 20px;
}

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

.nav-item.add-btn {
    background: var(--accent);
    color: white;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    margin-top: -20px;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.nav-item.add-btn .lucide, .nav-item.add-btn svg[data-lucide] {
    width: 24px;
    height: 24px;
}

/* ============ AUTH PAGES ============ */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

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

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header .logo {
    width: 56px;
    height: 56px;
    background: var(--accent);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 24px;
}

.auth-header h1 {
    font-size: 24px;
    margin-bottom: 4px;
}

.auth-header p {
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-secondary);
}

.auth-footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

/* ============ WALLET GRID ============ */

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

.wallet-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 16px;
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.wallet-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.wallet-card .wallet-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    margin-bottom: 12px;
}

.wallet-card .wallet-name {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.wallet-card .wallet-balance {
    font-size: 16px;
    font-weight: 600;
}

.wallet-card .wallet-actions {
    display: flex;
    gap: 4px;
    margin-top: 10px;
}

/* ============ CATEGORY GRID ============ */

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

.category-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.category-item .cat-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.category-item .cat-info {
    flex: 1;
    min-width: 0;
}

.category-item .cat-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-item .cat-type {
    font-size: 11px;
    color: var(--text-muted);
}

/* ============ PAGINATION ============ */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}

.pagination a, .pagination span {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    text-decoration: none;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.pagination a:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.pagination span.current {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.pagination a svg {
    width: 14px;
    height: 14px;
}

/* ============ FLASH MESSAGES ============ */

.flash-messages {
    margin-bottom: 16px;
}

.flash {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 8px;
    animation: slideIn 0.3s ease;
}

.flash svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.flash.success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.flash.error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

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

/* ============ MODAL ============ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 24px;
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

/* ============ SEARCH ============ */

.search-bar {
    position: relative;
    margin-bottom: 16px;
}

.search-bar input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
}

.search-bar [data-lucide="search"] {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

/* ============ COLOR PICKER ============ */

.color-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.color-option.active, .color-option:hover {
    border-color: white;
}

/* ============ SCROLLBAR ============ */

::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* ============ RESPONSIVE ============ */

@media (min-width: 768px) {
    .app-container {
        max-width: 480px;
        margin: 0 auto;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
}
