/*
 * Portfolio Tracker — Dark Glassmorphism Theme
 *
 * Design language:
 *   - Deep navy/charcoal backgrounds
 *   - Frosted-glass cards (translucent with blur)
 *   - Teal/green accents for positive values
 *   - Red accents for negative values
 *   - Left sidebar navigation
 *
 * CSS custom properties (variables) are defined at :root so every component
 * can reference the same palette.  Change a variable here and it updates everywhere.
 */

/* ============================================================
   RESET & BASE
   ============================================================ */

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

:root {
    /* Background layers */
    --bg-page:          #070b14;   /* deep space navy — page background */
    --bg-sidebar:       #0b1020;   /* slightly lighter for sidebar */
    --bg-card:          rgba(255, 255, 255, 0.05);   /* frosted glass base */
    --bg-card-hover:    rgba(255, 255, 255, 0.08);
    --bg-input:         rgba(255, 255, 255, 0.07);
    --bg-row-hover:     rgba(255, 255, 255, 0.04);
    --bg-badge:         rgba(255, 255, 255, 0.10);

    /* Text */
    --text-primary:     #e6edf3;
    --text-secondary:   #8b949e;
    --text-muted:       #4d5566;
    --text-inverse:     #070b14;

    /* Accent — teal/green */
    --accent:           #00d4aa;
    --accent-dim:       rgba(0, 212, 170, 0.15);
    --accent-hover:     #00f2c3;

    /* Positive (gain) */
    --positive:         #3fb950;
    --positive-dim:     rgba(63, 185, 80, 0.15);

    /* Negative (loss) */
    --negative:         #f85149;
    --negative-dim:     rgba(248, 81, 73, 0.15);

    /* Neutral */
    --neutral:          #8b949e;

    /* Borders */
    --border:           rgba(255, 255, 255, 0.08);
    --border-accent:    rgba(0, 212, 170, 0.30);

    /* Shadows */
    --shadow-card:      0 4px 24px rgba(0, 0, 0, 0.40);
    --shadow-elevated:  0 8px 40px rgba(0, 0, 0, 0.60);

    /* Sizing */
    --sidebar-width:    220px;
    --topbar-height:    60px;

    /* Transitions */
    --transition:       0.18s ease;

    /* Tax treatment badge colours */
    --tax-traditional:  #3b82f6;   /* blue */
    --tax-roth:         #8b5cf6;   /* purple */
    --tax-taxable:      #f59e0b;   /* amber */
    --tax-hsa:          #10b981;   /* emerald */
    --tax-crypto:       #f97316;   /* orange */
}

html, body {
    height: 100%;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-page);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
}

/* ============================================================
   LAYOUT — sidebar + main content
   ============================================================ */

.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ---------- Sidebar ---------- */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px 18px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo-icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-inverse);
    flex-shrink: 0;
}

.sidebar-logo-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.sidebar-logo-sub {
    font-size: 11px;
    color: var(--text-secondary);
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.sidebar-section-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 16px 18px 6px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 18px;
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 500;
    transition: color var(--transition), background var(--transition);
    border-radius: 0;
    position: relative;
}

.sidebar-nav a:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.04);
}

.sidebar-nav a.active {
    color: var(--accent);
    background: var(--accent-dim);
}

/* accent left bar for active item */
.sidebar-nav a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

.sidebar-nav a .nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid var(--border);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    padding: 6px 0;
}

.sidebar-footer a:hover {
    color: var(--negative);
}

/* ---------- Main content area ---------- */

.main-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.page-header {
    padding: 28px 32px 0;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.page-body {
    padding: 24px 32px 40px;
    flex: 1;
}

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

.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-card);
    padding: 20px;
}

.glass-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255,255,255,0.12);
}

/* ============================================================
   SUMMARY / STAT CARDS (dashboard top row)
   ============================================================ */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    backdrop-filter: blur(12px);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
    transition: background var(--transition), border-color var(--transition);
}

.stat-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255,255,255,0.12);
}

/* subtle gradient glow in top-right corner */
.stat-card::after {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 80px;
    height: 80px;
    background: var(--accent);
    opacity: 0.04;
    border-radius: 50%;
    pointer-events: none;
}

.stat-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.stat-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.stat-value.positive { color: var(--positive); }
.stat-value.negative { color: var(--negative); }
.stat-value.accent   { color: var(--accent); }

/* ============================================================
   POSITIONS TABLE
   ============================================================ */

.table-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    backdrop-filter: blur(12px);
    overflow: hidden;
}

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

.table-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.table-controls {
    display: flex;
    gap: 8px;
}

.positions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.positions-table thead th {
    padding: 10px 16px;
    text-align: right;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

/* Symbol column is left-aligned */
.positions-table thead th:first-child,
.positions-table tbody td:first-child {
    text-align: left;
    padding-left: 20px;
}

.positions-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
    cursor: pointer;
}

.positions-table tbody tr:last-child {
    border-bottom: none;
}

.positions-table tbody tr:hover,
.positions-table tbody tr.expanded {
    background: var(--bg-row-hover);
}

.positions-table tbody td {
    padding: 12px 16px;
    text-align: right;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Symbol + name cell */
.symbol-cell {
    display: flex;
    flex-direction: column;
}

.symbol-cell .symbol {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.symbol-cell .sec-name {
    font-size: 11px;
    color: var(--text-secondary);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* P&L coloring */
.positive { color: var(--positive); }
.negative { color: var(--negative); }
.neutral  { color: var(--neutral); }

/* Total return highlight — the "SGOV fix" */
.total-return {
    font-weight: 600;
}

/* Expandable lot row */
.lot-row {
    display: none;
    background: rgba(0, 0, 0, 0.25);
}

.lot-row.visible {
    display: table-row;
}

.lot-row td {
    padding: 0;
}

.lot-detail-panel {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.lot-detail-panel h4 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* ============================================================
   BADGES
   ============================================================ */

.badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: var(--bg-badge);
    color: var(--text-secondary);
}

/* Tax treatment badges */
.badge-traditional { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.badge-roth        { background: rgba(139, 92, 246, 0.15); color: #c4b5fd; }
.badge-taxable     { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.badge-hsa         { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
.badge-crypto      { background: rgba(249, 115, 22, 0.15); color: #fdba74; }

/* Expand toggle indicator */
.expand-toggle {
    display: inline-block;
    width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    font-size: 10px;
    border-radius: 4px;
    background: var(--bg-badge);
    color: var(--text-secondary);
    transition: transform var(--transition);
    margin-right: 6px;
    user-select: none;
    flex-shrink: 0;
}

.expand-toggle.open {
    transform: rotate(90deg);
    color: var(--accent);
}

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

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background var(--transition), opacity var(--transition);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

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

.btn-secondary {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-card-hover);
    border-color: rgba(255,255,255,0.14);
}

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

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

.btn-danger {
    background: var(--negative-dim);
    border: 1px solid rgba(248,81,73,0.25);
    color: var(--negative);
}

.btn-danger:hover:not(:disabled) {
    background: rgba(248,81,73,0.25);
}

/* Small variant */
.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* ============================================================
   FORMS & INPUTS
   ============================================================ */

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

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.form-input,
.form-select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    padding: 10px 14px;
    outline: none;
    transition: border-color var(--transition), background var(--transition);
    appearance: none;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--accent);
    background: rgba(255,255,255,0.09);
}

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

.form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 5px;
}

/* ============================================================
   LOGIN PAGE (full-screen centred)
   ============================================================ */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-page);
    /* subtle radial gradient behind the card */
    background-image:
        radial-gradient(ellipse at 30% 40%, rgba(0, 212, 170, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 80%, rgba(59, 130, 246, 0.05) 0%, transparent 60%);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    backdrop-filter: blur(20px);
    padding: 40px 36px;
    box-shadow: var(--shadow-elevated);
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
}

.login-logo-icon {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-inverse);
}

.login-logo h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.login-logo p {
    font-size: 12px;
    color: var(--text-secondary);
}

.login-card h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.login-card .login-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

.error-message {
    background: var(--negative-dim);
    border: 1px solid rgba(248,81,73,0.25);
    border-radius: 8px;
    color: var(--negative);
    font-size: 13px;
    padding: 10px 14px;
    margin-bottom: 16px;
    display: none;
}

.error-message.visible {
    display: block;
}

/* ============================================================
   SETTINGS / ACCOUNTS LIST
   ============================================================ */

.account-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.account-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: background var(--transition);
}

.account-item:hover {
    background: var(--bg-card-hover);
}

.account-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--bg-badge);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.account-info {
    flex: 1;
}

.account-info .acct-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.account-info .acct-broker {
    font-size: 12px;
    color: var(--text-secondary);
}

.account-actions {
    display: flex;
    gap: 8px;
}

/* ============================================================
   NOTIFICATION TOAST
   ============================================================ */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    backdrop-filter: blur(16px);
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-primary);
    box-shadow: var(--shadow-elevated);
    pointer-events: all;
    animation: slideIn 0.2s ease;
    min-width: 240px;
    max-width: 360px;
}

.toast.success { border-left: 3px solid var(--positive); }
.toast.error   { border-left: 3px solid var(--negative); }
.toast.info    { border-left: 3px solid var(--accent); }

@keyframes slideIn {
    from { transform: translateX(30px); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

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

/* ============================================================
   SYNC STATUS INDICATOR
   ============================================================ */

.sync-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.sync-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
}

.sync-dot.syncing {
    background: var(--accent);
    animation: pulse 1s infinite;
}

.sync-dot.success { background: var(--positive); }
.sync-dot.error   { background: var(--negative); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.3; }
}

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

.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

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

.empty-state p {
    font-size: 13px;
    color: var(--text-muted);
    max-width: 320px;
    margin: 0 auto 20px;
    line-height: 1.6;
}

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

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

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

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.20);
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */

.flex        { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.gap-16      { gap: 16px; }
.mt-4        { margin-top: 4px; }
.mt-8        { margin-top: 8px; }
.mt-16       { margin-top: 16px; }
.mt-24       { margin-top: 24px; }
.mb-16       { margin-bottom: 16px; }
.mb-24       { margin-bottom: 24px; }
.text-sm     { font-size: 12px; }
.text-muted  { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-mono   { font-family: 'JetBrains Mono', 'Fira Code', monospace; }
.hidden      { display: none !important; }

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

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: #111827;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px;
    width: 100%;
    max-width: 460px;
    box-shadow: var(--shadow-elevated);
    transform: translateY(10px);
    transition: transform 0.2s ease;
}

.modal-overlay.open .modal {
    transform: translateY(0);
}

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

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
}

.modal-close:hover { color: var(--text-primary); background: var(--bg-row-hover); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}
