/* moneycoach/static/css/main.css */

/* 1. VARIABLES & THEME */
:root {
    /* Brand Colors */
    --primary-teal: #00cea6;
    --primary-teal-dark: #00b593;

    /* Functional Colors */
    --danger: #e53e3e;
    --success: #38a169;
    --warning: #d69e2e;

    /* Backgrounds */
    --bg-body: #e2e8f0;  /* The darker cool gray we agreed on */
    --bg-card: #ffffff;

    /* Text */
    --text-dark: #1a202c;
    --text-medium: #4a5568;
    --text-light: #a0aec0;

    /* Dimensions & Shapes */
    --card-radius: 20px;
    --btn-radius: 12px;
    --shadow-soft: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 5px 10px -5px rgba(0, 0, 0, 0.02);
}

/* 2. BASE RESET */
body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-medium);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

/* 3. LAYOUT */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* 4. NAVBAR */
.navbar {
    background: var(--bg-card);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    position: relative;
    z-index: 50;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-brand::before {
     content: '';
     display: inline-block;
     width: 12px;
     height: 12px;
     background: var(--primary-teal);
     border-radius: 50%;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-item {
    text-decoration: none;
    color: var(--text-medium);
    font-weight: 500;
    font-size: 0.95rem;
    padding-bottom: 4px;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.nav-item:hover, .nav-item.active {
    color: var(--text-dark);
    border-bottom-color: var(--primary-teal);
}

/* 5. PROFILE DROPDOWN */
.nav-profile-container {
    position: relative;
    cursor: pointer;
    padding-bottom: 10px;
}

.nav-profile {
    width: 40px;
    height: 40px;
    background: #e2e8f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--text-medium);
    border: 2px solid transparent;
    transition: all 0.2s;
}

.nav-profile:hover {
    border-color: var(--primary-teal);
}

.profile-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    width: 160px;
    padding: 0.5rem 0;
    display: none;
    z-index: 100;
    border: 1px solid #f0f0f0;
}

.nav-profile-container:hover .profile-dropdown {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    color: var(--text-dark);
    font-size: 0.9rem;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: #f7fafc;
    color: var(--primary-teal);
}

/* 6. CARDS (The core of "Executive Glass") */
.card {
    background: var(--bg-card);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-soft);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: none;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 1rem;
    margin-top: 0;
}

/* 7. BUTTONS */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: var(--btn-radius);
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
    border: none;
    font-size: 0.9rem;
    transition: background 0.2s, transform 0.1s;
    font-family: inherit;
}

.btn:active {
    transform: scale(0.98);
}

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

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

/* 8. TABLES */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    color: var(--text-medium);
    font-weight: 500;
    padding: 1rem 0.5rem;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.9rem;
}

td {
    padding: 1rem 0.5rem;
    color: var(--text-dark);
    border-bottom: 1px solid #f7fafc;
}

/* 9. UTILITIES (Common styling helpers) */
.text-teal { color: var(--primary-teal); }
.text-teal-dark { color: var(--primary-teal-dark); }
.text-dark { color: var(--text-dark); }
.text-medium { color: var(--text-medium); }
.text-light { color: var(--text-light); }

.font-bold { font-weight: 700; }

.flex { display: flex; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-4 { gap: 1rem; }
.gap-2 { gap: 0.5rem; }

.mb-4 { margin-bottom: 1rem; }
.mt-4 { margin-top: 1rem; }
.mt-8 { margin-top: 2rem; }




/* =========================================
   MOBILE RESPONSIVE OVERRIDES
   ========================================= */

/* 1. UTILITY CLASSES FOR HIDING */
.desktop-only { display: flex; }
.mobile-only { display: none; }

/* 2. BOTTOM NAVIGATION (Hidden by default) */
.bottom-nav {
    display: none; /* Hidden on desktop */
    position: fixed;
    bottom: 0; left: 0; width: 100%;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    padding: 8px 0 24px 0; /* Extra padding for iPhone Home bar */
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.03);
}

.b-item {
    text-decoration: none;
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 500;
    gap: 4px;
    width: 20%;
}

.b-item i { font-size: 1.5rem; margin-bottom: 2px; }
.b-item.active { color: var(--primary-teal); }

/* The Center "Add" Button */
.b-item.b-add .add-circle {
    width: 48px; height: 48px;
    background: var(--text-dark);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white;
    margin-top: -20px; /* Popped up effect */
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: transform 0.1s;
}
.b-item.b-add:active .add-circle { transform: scale(0.95); }


/* =========================================
   ASSETS PAGE (Portfolio) — page-scoped styles
   ========================================= */

.assets-page .assets-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.assets-page .assets-title {
    margin: 0;
}

.assets-page .assets-total {
    text-align: right;
}

.assets-page .assets-total-label {
    font-size: 0.85rem;
}

.assets-page .assets-total-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-teal);
}

.assets-page .assets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 2rem;
}

/* Cards */
.assets-page .asset-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.assets-page .asset-card--crypto {
    border-top: 4px solid #805ad5;
}

.assets-page .asset-card--stock {
    border-top: 4px solid #3182ce;
}

.assets-page .asset-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.assets-page .asset-card-title {
    margin: 0;
}

.assets-page .asset-card-title--crypto {
    color: #553c9a;
}

.assets-page .asset-card-title--stock {
    color: #2c5282;
}

.assets-page .asset-card-sub {
    font-size: 0.9rem;
}

/* Add buttons */
.assets-page .asset-add-btn {
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
}

.assets-page .asset-add-btn--crypto {
    background: #f3e8ff;
    color: #553c9a;
}

.assets-page .asset-add-btn--stock {
    background: #ebf8ff;
    color: #2c5282;
}

/* Tables */
.assets-page .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.assets-page .asset-table {
    font-size: 0.9rem;
}

.assets-page .asset-table--crypto th {
    border-bottom: 1px solid #f3e8ff;
}

.assets-page .asset-table--stock th {
    border-bottom: 1px solid #ebf8ff;
}

.assets-page .asset-th-first,
.assets-page .asset-td-first {
    padding-left: 0;
}

.assets-page .asset-th-last,
.assets-page .asset-td-last {
    padding-right: 0;
}

.assets-page .asset-th-right,
.assets-page .asset-td-right {
    text-align: right;
}

.assets-page .asset-th-action,
.assets-page .asset-td-action {
    width: 64px;
    white-space: nowrap;
}

.assets-page .asset-symbol {
    font-weight: 600;
}

.assets-page .asset-name {
    font-size: 0.75rem;
    color: var(--text-light);
}

.assets-page .asset-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.assets-page .asset-strong {
    font-weight: 600;
}

.assets-page .asset-edit-link {
    font-size: 0.85rem;
}

/* Empty state */
.assets-page .asset-empty {
    text-align: center;
    padding: 2rem;
    opacity: 0.6;
    font-size: 0.9rem;
}

/* Charts */
.assets-page .asset-chart-block {
    margin-top: 1rem;
}

.assets-page .asset-chart-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 1rem;
}

.assets-page .asset-chart-title {
    font-size: 0.85rem;
    color: var(--text-light);
}

.assets-page .chart-toggle-group {
    background: #f7fafc;
    border-radius: 6px;
    padding: 2px;
    display: flex;
    gap: 2px;
}

.assets-page .chart-toggle {
    border: none;
    background: transparent;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    color: var(--text-light);
    font-family: inherit;
}

.assets-page .chart-toggle.active {
    background: #ffffff;
    color: var(--text-dark);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.assets-page .asset-chart-canvas {
    height: 200px;
    width: 100%;
}

/* =========================================
   MODALS + SEARCH UI (used by assets page)
   Moved from assets.html <style> block
   ========================================= */

/* Backdrop (global class), behavior scoped to assets page */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1800;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    box-sizing: border-box;
}

/* Keep assets modals centered on mobile (override global bottom-sheet behavior) */
.assets-page .modal-backdrop .modal-content.assets-modal {
    position: relative;
    bottom: auto;
    left: auto;
    width: 100%;
    max-width: 400px;
    margin: 0;
    border-radius: 24px !important;
    animation: assetsSlideUp 0.2s ease-out;
    overflow: visible;
}

@media (max-width: 768px) {
    .assets-page .modal-backdrop {
        align-items: center;
        padding: 0.75rem;
    }

    .assets-page .modal-backdrop .modal-content.assets-modal {
        max-width: 420px;
        width: 100%;
        margin-bottom: 40px; /* keep clear of bottom nav */
    }

    .assets-page .assets-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

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

/* Form + search UI */
.form-input {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    box-sizing: border-box;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin-top: 4px;
}

.search-item {
    padding: 0.6rem;
    cursor: pointer;
    border-bottom: 1px solid #f7fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-item:hover {
    background: #f0fdf4;
}

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

/* Assets modal micro-layout */
.assets-page .assets-modal-help {
    font-size: 0.85rem;
    color: var(--text-medium);
    margin-bottom: 1rem;
}

.assets-page .assets-modal-label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
    color: var(--text-dark);
}

.assets-page .assets-search-wrap {
    position: relative;
    margin-bottom: 1rem;
}

.assets-page .assets-qty-input {
    margin-bottom: 1.5rem;
}

.assets-page .assets-btn-ghost {
    background: transparent;
    color: var(--text-medium);
}


/* Assets autocomplete dropdown */
.assets-page .assets-autocomplete {
    position: relative;
}

.assets-page .assets-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.12);
    z-index: 20;
    overflow: hidden;
}

.assets-page .assets-dropdown-hint {
    padding: 10px 12px;
    font-size: 0.85rem;
    color: var(--text-light);
    background: #fafafa;
    border-bottom: 1px solid #f1f5f9;
}

.assets-page .assets-dropdown-list {
    max-height: 260px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.assets-page .assets-dd-item {
    width: 100%;
    border: 0;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}

.assets-page .assets-dd-item:hover {
    background: #f0fdf4; /* soft green tint */
}

.assets-page .assets-dd-badge {
    width: 44px;
    flex: 0 0 44px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: #f1f5f9;
    color: #334155;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

.assets-page .assets-dd-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.assets-page .assets-dd-symbol {
    font-weight: 700;
    color: var(--text-dark);
    font-size: 0.92rem;
    line-height: 1.1;
}

.assets-page .assets-dd-name {
    color: var(--text-light);
    font-size: 0.82rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.assets-page .assets-pick-error {
    margin-top: 8px;
    font-size: 0.85rem;
    color: #c53030;
}

/* =========================================
   MEDIA QUERY: PHONES & TABLETS (< 768px)
   ========================================= */
@media (max-width: 768px) {

    /* HIDE DESKTOP ELEMENTS */
    .nav-links, .desktop-only { display: none !important; }

    /* SHOW MOBILE ELEMENTS */
    .bottom-nav { display: flex; }

    /* LAYOUT ADJUSTMENTS */
    .container {
        padding: 1rem;
        padding-bottom: 100px; /* Space for bottom bar */
    }

    /* NAVBAR SIMPLIFICATION */
    .navbar {
        justify-content: center;
        padding: 0.8rem;
    }
    .nav-brand { font-size: 1.1rem; }

    /* FLATTEN GRIDS (Stack columns vertically) */
    div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* CARD ADJUSTMENTS */
    .card {
        padding: 1.2rem;
        border-radius: 16px;
    }

    /* FONT SIZES */
    h2 { font-size: 1.5rem; margin-top: 1rem !important; }

    /* MODALS -> BOTTOM SHEETS */
    .modal-content {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 24px 24px 0 0 !important;
        margin: 0 !important;
        padding: 1.5rem !important;
        animation: slideUpBottom 0.3s ease-out !important;
    }

    /* TABLES (Horizontal Scroll - Phase 1) */
    div[style*="overflow-x:auto"],
    div[style*="overflow-x: auto"] {
        -webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
    }

    /* Reduce font size in tables */
    table { font-size: 0.85rem !important; }
    td, th { padding: 0.75rem 0.4rem !important; }
}

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

/* MOBILE MENU (Bottom Sheet) */
.mobile-menu-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 2000; /* Above bottom nav */
    display: flex;
    align-items: flex-end; /* Align to bottom */
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.mobile-menu-content {
    width: 100%;
    max-width: 500px; /* Don't stretch too wide on tablets */
    background: #ffffff;
    border-radius: 24px 24px 0 0;
    padding: 2rem 1.5rem 1.5rem 1.5rem;
    animation: slideUpBottom 0.3s ease-out;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.1);
}

/* Menu Grid Layout */
.menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

.menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-medium);
    gap: 0.5rem;
    padding: 1rem 0;
    border-radius: 12px;
    transition: background 0.1s;
}

.menu-item:active {
    background: #f7fafc;
}

.menu-item span {
    font-size: 0.85rem;
    font-weight: 500;
}

.icon-box {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- Onboarding Banner (Robust Layout) --- */
.onboarding-banner {
    max-width: 1200px;
    margin: 2rem auto;
    width: 95%; /* Safe margin on mobile */

    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #00cea6;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
    overflow: hidden; /* Cuts off anything trying to escape */
}

.onboarding-banner .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap; /* Allows stacking on mobile */
    gap: 1rem;
    padding: 1.25rem 2rem;
    width: 100%;
    box-sizing: border-box; /* CRITICAL: Keeps padding inside the width */
}

.onboarding-banner span {
    flex: 1 1 auto; /* Text takes available space */
    min-width: 200px; /* Wraps early on tiny screens */
    font-weight: 500;
    font-size: 0.95rem;
    color: #334155;
    line-height: 1.5; /* Better readability when wrapping */
}

.onboarding-banner .btn-light {
    flex: 0 0 auto; /* Button NEVER shrinks or grows */
    background: #00cea6;
    color: #ffffff;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: inline-block;
}

.onboarding-banner .btn-light:hover {
    background: #00b894;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 206, 166, 0.25);
}

.auth-card {
  max-width: 520px;
  margin: 3rem auto;
  padding: 2rem;
}

.auth-field input,
.auth-field select {
  width: 100%;
  box-sizing: border-box;
}
