/*
 * KOUBA FINANCE TRACKER - Premium Design System
 * Inspired by Copilot Money, Mint, YNAB
 * 2024 Modern Finance App UI/UX
 */

/* ========================================
   DESIGN TOKENS
   ======================================== */
:root {
    /* Background Colors */
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-card: #161616;
    --bg-card-hover: #1f1f1f;
    --bg-elevated: #1a1a1a;
    --bg-input: #0d0d0d;

    /* Accent Colors */
    --accent-primary: #22c55e;
    /* Green - Money/Positive */
    --accent-primary-dim: rgba(34, 197, 94, 0.15);
    --accent-secondary: #a78bfa;
    /* Purple - Secondary */
    --accent-secondary-dim: rgba(167, 139, 250, 0.15);
    --accent-warning: #f59e0b;
    /* Amber - Warning */
    --accent-warning-dim: rgba(245, 158, 11, 0.15);
    --accent-danger: #ef4444;
    /* Red - Negative/Delete */
    --accent-danger-dim: rgba(239, 68, 68, 0.15);
    --accent-info: #3b82f6;
    /* Blue - Info */
    --accent-info-dim: rgba(59, 130, 246, 0.15);

    /* Text Colors */
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #52525b;
    --text-inverse: #0a0a0a;

    /* Border & Shadows */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.15);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
    --shadow-glow-green: 0 0 20px rgba(34, 197, 94, 0.3);

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Typography */
    --font-sans: 'Inter', 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Space Mono', monospace;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
}

/* ========================================
   APP LAYOUT (Sidebar + Main)
   ======================================== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

@media (max-width: 900px) {
    .app-layout {
        flex-direction: column;
    }

    .app-sidebar {
        display: none;
        /* TODO: Add mobile hamburger menu */
    }
}

/* ========================================
   SIDEBAR
   ======================================== */
.app-sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: 220px;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-sidebar__header {
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--border-subtle);
}

.app-sidebar__nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
}

.app-sidebar__footer {
    padding: var(--space-md);
    border-top: 1px solid var(--border-subtle);
}

/* Nav Sections */
.nav-section {
    margin-bottom: var(--space-lg);
}

.nav-section__label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-xs);
}

/* Nav Items */
.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
}

.nav-item:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

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

.nav-item__icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* User Menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    cursor: pointer;
}

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

.user-menu__avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-menu__avatar svg {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.user-menu__info {
    display: flex;
    flex-direction: column;
}

.user-menu__name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.user-menu__label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ========================================
   MAIN CONTENT
   ======================================== */
.app-main {
    flex: 1;
    padding: var(--space-xl);
    min-height: 100vh;
    background: var(--bg-primary);
    overflow-x: auto;
}

@media (max-width: 900px) {
    .app-main {
        padding: var(--space-md);
    }
}

/* Page Header */
.page-header {
    margin-bottom: var(--space-xl);
}

.page-header h1 {
    margin-bottom: var(--space-xs);
}

.page-header__subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ========================================
   RESET & BASE
   ======================================== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ========================================
   LAYOUT
   ======================================== */
.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: var(--space-lg);
}

/* ========================================
   NAVBAR
   ======================================== */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    padding: var(--space-md) var(--space-xl);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-xl);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-md);
}

.logo {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary) 0%, #4ade80 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.nav-links {
    display: flex;
    gap: var(--space-sm);
    background: var(--bg-secondary);
    padding: var(--space-xs);
    border-radius: var(--radius-md);
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

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

.nav-btn.active {
    color: var(--text-primary);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

/* ========================================
   DASHBOARD - METRIC CARDS (Bento Grid)
   ======================================== */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

@media (max-width: 1200px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-primary), transparent);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.metric-card:hover {
    border-color: var(--border-default);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.metric-card:hover::before {
    opacity: 1;
}

.metric-card__label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.metric-card__value {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.metric-card__change {
    font-size: 0.8rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.metric-card__change--positive {
    color: var(--accent-primary);
    background: var(--accent-primary-dim);
}

.metric-card__change--negative {
    color: var(--accent-danger);
    background: var(--accent-danger-dim);
}

/* ========================================
   CHARTS GRID
   ======================================== */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

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

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: all var(--transition-normal);
}

.chart-card:hover {
    border-color: var(--border-default);
}

.chart-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.chart-card h3::before {
    content: '';
    width: 4px;
    height: 16px;
    background: var(--accent-primary);
    border-radius: var(--radius-full);
}

.chart-card.large {
    grid-column: 1 / -1;
    min-height: 400px;
}

/* ========================================
   SIDEBAR LAYOUT
   ======================================== */
.layout-split {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: var(--space-xl);
    min-height: calc(100vh - 180px);
}

@media (max-width: 900px) {
    .layout-split {
        grid-template-columns: 1fr;
    }
}

.sidebar {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: var(--space-md);
    margin-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-item {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    margin-bottom: var(--space-sm);
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.sidebar-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-subtle);
}

.sidebar-item.active {
    background: var(--accent-primary-dim);
    border-color: var(--accent-primary);
}

.sidebar-item h4 {
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.sidebar-item span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.content-area {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    overflow-y: auto;
}

.placeholder-msg {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 1rem;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.btn--primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--text-inverse);
}

.btn--primary:hover {
    background: #16a34a;
    border-color: #16a34a;
    box-shadow: var(--shadow-glow-green);
}

.btn--danger {
    background: var(--accent-danger-dim);
    border-color: var(--accent-danger);
    color: var(--accent-danger);
}

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

.btn-small {
    padding: var(--space-xs) var(--space-md);
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--accent-primary);
    color: var(--text-inverse);
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-glow-green);
}

/* ========================================
   FORM ELEMENTS
   ======================================== */
.input-field {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    font-size: 0.9rem;
    font-family: var(--font-sans);
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.input-field:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-dim);
}

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

select.input-field {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a1a1aa' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ========================================
   TABLES
   ======================================== */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead {
    background: var(--bg-secondary);
}

th {
    padding: var(--space-md);
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-default);
}

td {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    transition: background var(--transition-fast);
}

tr:hover td {
    background: var(--bg-card-hover);
}

td.amount {
    font-family: var(--font-mono);
    text-align: right;
    font-weight: 500;
}

td.amount.positive {
    color: var(--accent-primary);
}

td.amount.negative {
    color: var(--accent-danger);
}

/* Matrix Table */
.matrix-table {
    font-size: 0.8rem;
}

.matrix-table th,
.matrix-table td {
    padding: var(--space-sm) var(--space-md);
    text-align: center;
}

.matrix-table th:first-child,
.matrix-table td:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    background: var(--bg-card);
    z-index: 1;
}

/* ========================================
   UPLOAD ZONE
   ======================================== */
.upload-zone {
    border: 2px dashed var(--border-default);
    padding: var(--space-2xl);
    text-align: center;
    border-radius: var(--radius-lg);
    background: var(--bg-input);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.upload-zone:hover {
    border-color: var(--accent-primary);
    background: var(--accent-primary-dim);
}

.upload-zone p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.upload-zone.dragover {
    border-color: var(--accent-primary);
    background: var(--accent-primary-dim);
    transform: scale(1.02);
}

/* ========================================
   LOADER
   ======================================== */
.loader {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--accent-primary);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
    margin: var(--space-lg) auto;
    display: none;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   BADGES / TAGS
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-full);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.badge--category {
    background: var(--accent-secondary-dim);
    color: var(--accent-secondary);
    border-color: transparent;
}

.badge--bank {
    background: var(--accent-info-dim);
    color: var(--accent-info);
    border-color: transparent;
}

/* ========================================
   SECTION HEADERS
   ======================================== */
h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
}

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

/* ========================================
   ANIMATIONS
   ======================================== */
.app-section {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.text-muted {
    color: var(--text-muted);
}

.text-success {
    color: var(--accent-primary);
}

.text-danger {
    color: var(--accent-danger);
}

.text-warning {
    color: var(--accent-warning);
}

.mt-sm {
    margin-top: var(--space-sm);
}

.mt-md {
    margin-top: var(--space-md);
}

.mt-lg {
    margin-top: var(--space-lg);
}

.mt-xl {
    margin-top: var(--space-xl);
}

.mb-sm {
    margin-bottom: var(--space-sm);
}

.mb-md {
    margin-bottom: var(--space-md);
}

.mb-lg {
    margin-bottom: var(--space-lg);
}

.mb-xl {
    margin-bottom: var(--space-xl);
}

.flex {
    display: flex;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.gap-sm {
    gap: var(--space-sm);
}

.gap-md {
    gap: var(--space-md);
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    .container {
        padding: var(--space-md);
    }

    .navbar {
        flex-direction: column;
        gap: var(--space-md);
        padding: var(--space-md);
    }

    .nav-links {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .metrics-grid {
        grid-template-columns: 1fr 1fr;
    }

    h1 {
        font-size: 1.5rem;
    }
}

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