/* styles.css — Custom styles (plain CSS, Tailwind loaded via CDN for utilities) */

/* ── Base ───────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: #f9fafb;
  color: #111827;
  min-height: 100vh;
}

@media (prefers-color-scheme: dark) {
  body { background: #111827; color: #f9fafb; }
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
  border: 1px solid #f3f4f6;
  padding: 1rem;
}

@media (prefers-color-scheme: dark) {
  .card { background: #1f2937; border-color: #374151; }
}

.card-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.card-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #111827;
}

@media (prefers-color-scheme: dark) {
  .card-value { color: #f9fafb; }
}

.card-sub {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-top: 0.125rem;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  background: #2563eb;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.btn:hover { background: #1d4ed8; }

.btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem 0.75rem;
  background: #f3f4f6;
  color: #374151;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 0.375rem;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-sm:hover { background: #e5e7eb; }

.btn-danger {
  background: #fef2f2;
  color: #dc2626;
}

.btn-danger:hover { background: #fee2e2; }

@media (prefers-color-scheme: dark) {
  .btn-sm { background: #374151; color: #d1d5db; }
  .btn-sm:hover { background: #4b5563; }
  .btn-danger { background: rgba(127,29,29,.2); color: #f87171; }
  .btn-danger:hover { background: rgba(127,29,29,.4); }
}

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 0.25rem;
}

.form-input, .select-sm {
  width: 100%;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  background: #fff;
  color: #111827;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus, .select-sm:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.select-sm {
  width: auto;
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  border-radius: 0.375rem;
}

@media (prefers-color-scheme: dark) {
  .form-input, .select-sm {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
  }
}

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 500;
  border-radius: 9999px;
  background: #f3f4f6;
  color: #4b5563;
}

.badge-stock    { background: #eff6ff; color: #1d4ed8; }
.badge-etf      { background: #f5f3ff; color: #6d28d9; }
.badge-gold-etf { background: #fffbeb; color: #b45309; }
.badge-mf       { background: #f0fdf4; color: #15803d; }

@media (prefers-color-scheme: dark) {
  .badge { background: #374151; color: #d1d5db; }
  .badge-stock    { background: rgba(30,58,138,.3); color: #93c5fd; }
  .badge-etf      { background: rgba(76,29,149,.3); color: #c4b5fd; }
  .badge-gold-etf { background: rgba(120,53,15,.3); color: #fcd34d; }
  .badge-mf       { background: rgba(20,83,45,.3); color: #86efac; }
}

/* ── Charts ─────────────────────────────────────────────────────────────────── */
.chart-container {
  position: relative;
  width: 100%;
  max-height: 320px;
}

/* ── Drop zones ─────────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed #e5e7eb;
  border-radius: 0.75rem;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: #3b82f6;
  background: rgba(59,130,246,.04);
}

@media (prefers-color-scheme: dark) {
  .drop-zone { border-color: #4b5563; }
  .drop-zone:hover, .drop-zone.drag-over {
    border-color: #60a5fa;
    background: rgba(96,165,250,.06);
  }
}

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-box {
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 25px 50px rgba(0,0,0,.25);
  width: 100%;
  max-width: 42rem;
  max-height: 90vh;
  overflow-y: auto;
}

@media (prefers-color-scheme: dark) {
  .modal-box { background: #1f2937; }
}

/* ── Toast ──────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 100;
  opacity: 0;
  transform: translateY(0.5rem);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translateY(0); }

.toast-success { background: #dcfce7; color: #166534; }
.toast-error   { background: #fee2e2; color: #991b1b; }
.toast-info    { background: #dbeafe; color: #1e40af; }

@media (prefers-color-scheme: dark) {
  .toast-success { background: #14532d; color: #bbf7d0; }
  .toast-error   { background: #7f1d1d; color: #fecaca; }
  .toast-info    { background: #1e3a5f; color: #bfdbfe; }
}

/* ── Scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ── Utility overrides ──────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-green-600 { color: #16a34a; }
.text-red-500   { color: #ef4444; }
.text-blue-600  { color: #2563eb; }

@media (prefers-color-scheme: dark) {
  .text-green-600 { color: #4ade80; }
  .text-red-500   { color: #f87171; }
  .text-blue-600  { color: #60a5fa; }
}

/* ── Summary tab — hero net-worth card ──────────────────────────────────────── */
.summary-hero-row {
  display: flex;
}

.summary-hero-card {
  /* Slightly elevated look to distinguish it as the headline number */
  border-left: 4px solid #2563eb;
  padding: 1.25rem 1.5rem;
  min-width: 260px;
}

@media (prefers-color-scheme: dark) {
  .summary-hero-card { border-left-color: #60a5fa; }
}

.summary-hero-value {
  font-size: 2rem !important;
  line-height: 1.2;
}

/* ── Summary tab — section divider labels ───────────────────────────────────── */
.summary-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid #f3f4f6;
}

@media (prefers-color-scheme: dark) {
  .summary-section-label { border-bottom-color: #374151; }
}

/* ── card-sub colour helpers (used in summary) ──────────────────────────────── */
.card-sub.positive { color: #16a34a; }
.card-sub.negative { color: #ef4444; }

@media (prefers-color-scheme: dark) {
  .card-sub.positive { color: #4ade80; }
  .card-sub.negative { color: #f87171; }
}

/* ── App shell layout (sidebar + content) ───────────────────────────────────── */

/* Header spans full width */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  width: 100%;
}

/* Shell: sidebar on the left, content on the right */
.app-shell {
  display: flex;
  min-height: calc(100vh - 3.5rem); /* subtract header height */
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
:root {
  --sidebar-width: 220px;
  --sidebar-collapsed-width: 56px;
  --sidebar-bg: #1e2433;
  --sidebar-bg-dark: #111827;
  --sidebar-border: #2d3748;
  --sidebar-text: #9ca3af;
  --sidebar-text-hover: #f9fafb;
  --sidebar-active-bg: rgba(59, 130, 246, 0.15);
  --sidebar-active-border: #3b82f6;
  --sidebar-active-text: #60a5fa;
  --nav-group-label-color: #4b5563;
  --header-height: 3.5rem;
}

@media (prefers-color-scheme: light) {
  :root {
    --sidebar-bg: #f8fafc;
    --sidebar-border: #e2e8f0;
    --sidebar-text: #64748b;
    --sidebar-text-hover: #0f172a;
    --sidebar-active-bg: rgba(59, 130, 246, 0.08);
    --sidebar-active-border: #3b82f6;
    --sidebar-active-text: #2563eb;
    --nav-group-label-color: #94a3b8;
  }
}

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.2s ease, min-width 0.2s ease;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  flex-shrink: 0;
  padding: 0.75rem 0;
}

/* Collapsed state */
.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
  min-width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-group-label {
  display: none;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0.625rem 0;
}

/* Nav group */
.nav-group {
  margin-bottom: 0.25rem;
}

.nav-group-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--nav-group-label-color);
  padding: 0.5rem 1rem 0.25rem;
  white-space: nowrap;
  overflow: hidden;
}

/* Nav item */
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--sidebar-text);
  background: none;
  border: none;
  border-left: 3px solid transparent;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.nav-item:hover {
  color: var(--sidebar-text-hover);
  background: rgba(255, 255, 255, 0.05);
}

.nav-item-active {
  color: var(--sidebar-active-text) !important;
  background: var(--sidebar-active-bg) !important;
  border-left-color: var(--sidebar-active-border) !important;
}

.nav-icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 1.25rem;
  text-align: center;
}

.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Sidebar toggle button ──────────────────────────────────────────────────── */
.sidebar-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: none;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  color: #6b7280;
  font-size: 1.125rem;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
  background: #f3f4f6;
  color: #111827;
}

@media (prefers-color-scheme: dark) {
  .sidebar-toggle-btn:hover {
    background: #374151;
    color: #f9fafb;
  }
}

/* ── Main content area ──────────────────────────────────────────────────────── */
.app-content {
  flex: 1;
  min-width: 0;
  padding: 1.5rem 1.5rem 5rem; /* bottom padding for mobile nav */
  overflow-x: hidden;
}

/* ── Mobile bottom navigation (< 768px) ────────────────────────────────────── */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 767px) {
  /* Hide sidebar on mobile */
  .sidebar {
    display: none;
  }

  /* Show mobile bottom nav */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 40;
    background: #1e2433;
    border-top: 1px solid #2d3748;
    height: 3.5rem;
    align-items: stretch;
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.125rem;
    background: none;
    border: none;
    border-top: 2px solid transparent;
    cursor: pointer;
    color: #9ca3af;
    padding: 0.25rem 0;
    transition: color 0.15s, border-color 0.15s;
  }

  .mobile-nav-item:hover {
    color: #f9fafb;
  }

  .mobile-nav-item-active {
    color: #60a5fa !important;
    border-top-color: #3b82f6 !important;
  }

  .mobile-nav-icon {
    font-size: 1.125rem;
    line-height: 1;
  }

  .mobile-nav-label {
    font-size: 0.6rem;
    font-weight: 500;
    white-space: nowrap;
  }

  /* Reduce content padding on mobile */
  .app-content {
    padding: 1rem 1rem 4.5rem;
  }

  /* Hide sidebar toggle on mobile */
  .sidebar-toggle-btn {
    display: none;
  }

  /* Push toast above mobile bottom nav */
  .toast {
    bottom: 5rem;
  }
}

/* ── Coming Soon placeholder ────────────────────────────────────────────────── */
.coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 16rem;
  color: #9ca3af;
  text-align: center;
  gap: 0.75rem;
}

.coming-soon-icon {
  font-size: 3rem;
}

.coming-soon-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: #6b7280;
}

.coming-soon-sub {
  font-size: 0.875rem;
  color: #9ca3af;
}
