/* ============================================
   DALES FINANCE TRACKER - MODERN LIGHT THEME
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* --- CSS Variables --- */
:root {
  --bg-primary: #f0f4f8;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --bg-elevated: rgba(255, 255, 255, 0.9);
  --border-glass: rgba(0, 0, 0, 0.08);
  --border-glass-hover: rgba(0, 0, 0, 0.15);
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-teal: #06b6d4;
  --accent-pink: #ec4899;
  --gradient-primary: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --gradient-accent: linear-gradient(135deg, #06b6d4, #3b82f6);
  --gradient-success: linear-gradient(135deg, #10b981, #059669);
  --gradient-danger: linear-gradient(135deg, #ef4444, #dc2626);
  --gradient-warning: linear-gradient(135deg, #f59e0b, #d97706);
  --glow-blue: 0 0 20px rgba(59, 130, 246, 0.2);
  --glow-purple: 0 0 20px rgba(139, 92, 246, 0.2);
  --glow-green: 0 0 15px rgba(16, 185, 129, 0.15);
  --glow-red: 0 0 15px rgba(239, 68, 68, 0.15);
  --card-shadow: 0 4px 24px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.04);
  --card-shadow-hover: 0 8px 40px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.06);
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Base --- */
* {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
  min-height: 100vh;
  background: var(--bg-primary);
  color: var(--text-primary);
}

a {
  color: var(--accent-blue);
  transition: var(--transition-smooth);
}
a:hover {
  color: var(--accent-purple);
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.3);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 92, 246, 0.5);
}

/* --- Gain / Loss --- */
.gain { color: #059669 !important; font-weight: 600; }
.loss { color: #dc2626 !important; font-weight: 600; }

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 68px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 4px 0 30px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  z-index: 1050;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.sidebar.expanded {
  width: 220px;
}

.sidebar-brand {
  padding: 1.1rem 0;
  text-align: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-brand a {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-brand-icon {
  font-size: 1.4rem;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  flex-shrink: 0;
}

.sidebar-brand .sidebar-label {
  font-weight: 700;
  font-size: 1rem;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.25rem;
  color: #475569;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.88rem;
  border-radius: 10px;
  margin: 0 0.5rem;
  transition: var(--transition-smooth);
  white-space: nowrap;
  overflow: hidden;
  border: none;
  background: none;
  cursor: pointer;
  width: calc(100% - 1rem);
  text-align: left;
}

.sidebar-link i {
  font-size: 1.15rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.sidebar-link:hover {
  color: #1e293b;
  background: rgba(59, 130, 246, 0.08);
}

.sidebar-link:hover i {
  color: var(--accent-blue);
}

.sidebar-label {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sidebar.expanded .sidebar-label {
  opacity: 1;
}

.sidebar-footer {
  padding: 0.5rem 0;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.sidebar-user {
  color: var(--text-muted) !important;
  font-size: 0.82rem;
}

.sidebar-logout {
  color: #dc2626 !important;
  font-size: 0.82rem;
}
.sidebar-logout:hover {
  background: rgba(239, 68, 68, 0.08) !important;
  color: #dc2626 !important;
}

/* --- Main Content Layout --- */
.main-content {
  margin-left: 68px;
  min-height: 100vh;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content.sidebar-expanded {
  margin-left: 220px;
}

/* --- Mobile sidebar --- */
.sidebar-toggle {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1060;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  padding: 0.4rem 0.6rem;
  font-size: 1.3rem;
  color: var(--text-primary);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.sidebar-toggle:hover {
  background: rgba(59, 130, 246, 0.08);
}

@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    width: 220px;
  }
  .sidebar .sidebar-label {
    opacity: 1;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.15);
  }
  .main-content {
    margin-left: 0;
  }
  .main-content.sidebar-expanded {
    margin-left: 0;
  }
}

@media (min-width: 992px) {
  .sidebar-toggle {
    display: none !important;
  }
}

/* --- Cards (glassmorphism) --- */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  transition: var(--transition-smooth);
  overflow: hidden;
}

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

.card-header {
  background: rgba(0, 0, 0, 0.02) !important;
  border-bottom: 1px solid var(--border-glass) !important;
  padding: 1rem 1.25rem;
}

.card-header h5 {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.card-body {
  padding: 1.25rem;
}

/* Category border indicators */
.card-isa { border-left: 3px solid var(--accent-blue) !important; }
.card-standard { border-left: 3px solid var(--accent-purple) !important; }
.card-bank { border-left: 3px solid #f59e0b !important; }
.card-pension { border-left: 3px solid var(--accent-teal) !important; }
.card-investment { border-left: 3px solid var(--text-muted) !important; }

/* --- Net Worth Hero --- */
.net-worth-card {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.06), rgba(139, 92, 246, 0.06)) !important;
  border: 1px solid rgba(139, 92, 246, 0.15) !important;
}

.net-worth-total {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #2563eb, #7c3aed, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 0 30px rgba(139, 92, 246, 0.15));
  line-height: 1.1;
  padding: 0.25rem 0;
}

/* --- Badges --- */
.badge-glass {
  background: rgba(0, 0, 0, 0.04) !important;
  color: var(--text-primary) !important;
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-weight: 500;
  font-size: 0.8rem;
  padding: 0.5em 0.85em;
  border-radius: 8px;
  backdrop-filter: blur(8px);
  transition: var(--transition-smooth);
}
.badge-glass:hover {
  background: rgba(0, 0, 0, 0.07) !important;
}

.badge-shares { border-color: rgba(5, 150, 105, 0.3) !important; color: #059669 !important; }
.badge-banks { border-color: rgba(217, 119, 6, 0.3) !important; color: #d97706 !important; }
.badge-pensions { border-color: rgba(6, 182, 212, 0.3) !important; color: #0891b2 !important; }
.badge-investments { border-color: rgba(139, 92, 246, 0.3) !important; color: #7c3aed !important; }

/* --- Tables --- */
.table {
  color: var(--text-primary);
  --bs-table-bg: transparent;
  --bs-table-color: var(--text-primary);
  --bs-table-hover-bg: rgba(59, 130, 246, 0.04);
  --bs-table-hover-color: var(--text-primary);
  --bs-table-striped-bg: rgba(0, 0, 0, 0.02);
  --bs-table-active-bg: rgba(59, 130, 246, 0.06);
  --bs-table-active-color: var(--text-primary);
  margin-bottom: 0;
  border-color: var(--border-glass);
}

.table > :not(caption) > * > * {
  border-bottom-color: var(--border-glass);
  padding: 0.75rem 0.85rem;
}

.table thead th {
  background: rgba(0, 0, 0, 0.02);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-glass) !important;
}

.table tbody tr {
  transition: var(--transition-smooth);
}

.table tbody tr:hover {
  background: rgba(59, 130, 246, 0.06) !important;
}

.table-active,
.table > tbody > .table-active > * {
  --bs-table-bg-state: rgba(59, 130, 246, 0.06) !important;
  background-color: rgba(59, 130, 246, 0.06) !important;
}

/* --- Buttons --- */
.btn {
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: 10px;
  padding: 0.5rem 1.15rem;
  transition: var(--transition-smooth);
  letter-spacing: -0.01em;
}

.btn-primary {
  background: var(--gradient-primary) !important;
  border: none !important;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}
.btn-primary:hover {
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.5);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--gradient-success) !important;
  border: none !important;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}
.btn-success:hover {
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.5);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--gradient-danger) !important;
  border: none !important;
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.5);
  transform: translateY(-1px);
}

.btn-outline-primary {
  color: var(--accent-blue) !important;
  border: 1px solid rgba(59, 130, 246, 0.4) !important;
  background: transparent !important;
}
.btn-outline-primary:hover {
  background: rgba(59, 130, 246, 0.15) !important;
  border-color: var(--accent-blue) !important;
  color: #93c5fd !important;
}

.btn-outline-success {
  color: #34d399 !important;
  border: 1px solid rgba(16, 185, 129, 0.4) !important;
  background: transparent !important;
}
.btn-outline-success:hover {
  background: rgba(16, 185, 129, 0.15) !important;
  border-color: #34d399 !important;
}

.btn-outline-danger {
  color: #f87171 !important;
  border: 1px solid rgba(239, 68, 68, 0.4) !important;
  background: transparent !important;
}
.btn-outline-danger:hover {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: #f87171 !important;
}

.btn-outline-info {
  color: var(--accent-teal) !important;
  border: 1px solid rgba(6, 182, 212, 0.4) !important;
  background: transparent !important;
}
.btn-outline-info:hover {
  background: rgba(6, 182, 212, 0.15) !important;
  border-color: var(--accent-teal) !important;
}

.btn-outline-secondary {
  color: var(--text-secondary) !important;
  border: 1px solid rgba(148, 163, 184, 0.3) !important;
  background: transparent !important;
}
.btn-outline-secondary:hover {
  background: rgba(148, 163, 184, 0.1) !important;
  color: var(--text-primary) !important;
}

.btn-outline-light {
  color: var(--text-secondary) !important;
  border: 1px solid rgba(0, 0, 0, 0.15) !important;
  background: transparent !important;
}
.btn-outline-light:hover {
  background: rgba(0, 0, 0, 0.05) !important;
  color: var(--text-primary) !important;
  border-color: rgba(0, 0, 0, 0.2) !important;
}

.btn-secondary {
  background: rgba(0, 0, 0, 0.05) !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  color: var(--text-secondary) !important;
}
.btn-secondary:hover {
  background: rgba(0, 0, 0, 0.08) !important;
  color: var(--text-primary) !important;
}

.btn-sm {
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  border-radius: 8px;
}

/* --- Forms --- */
.form-control,
.form-select {
  background: #ffffff !important;
  border: 1px solid var(--border-glass) !important;
  color: var(--text-primary) !important;
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  transition: var(--transition-smooth);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--accent-blue) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15) !important;
  background: #ffffff !important;
}

.form-control::placeholder {
  color: #94a3b8 !important;
}

.form-label {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}

.form-select option {
  background: #ffffff;
  color: var(--text-primary);
}

/* --- Modals --- */
.modal-content {
  background: #ffffff !important;
  border: 1px solid var(--border-glass) !important;
  border-radius: 16px !important;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6) !important;
  backdrop-filter: blur(20px);
}

.modal-header {
  border-bottom: 1px solid var(--border-glass) !important;
  padding: 1.15rem 1.25rem;
}

.modal-header.bg-success {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(5, 150, 105, 0.1)) !important;
  border-bottom: 1px solid rgba(16, 185, 129, 0.15) !important;
}

.modal-header.bg-danger {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(220, 38, 38, 0.1)) !important;
  border-bottom: 1px solid rgba(239, 68, 68, 0.15) !important;
}

.modal-title {
  color: var(--text-primary) !important;
  font-weight: 600;
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  border-top: 1px solid var(--border-glass) !important;
  padding: 1rem 1.25rem;
}

.btn-close {
  filter: none;
}

.btn-close-white {
  filter: invert(1) brightness(1);
}

.modal-header.bg-success .modal-title,
.modal-header.bg-danger .modal-title {
  color: var(--text-primary) !important;
}

/* --- Alerts --- */
.alert-danger {
  background: rgba(239, 68, 68, 0.08) !important;
  border: 1px solid rgba(239, 68, 68, 0.2) !important;
  color: #dc2626 !important;
  border-radius: 12px;
}

.alert-success {
  background: rgba(16, 185, 129, 0.08) !important;
  border: 1px solid rgba(16, 185, 129, 0.2) !important;
  color: #059669 !important;
  border-radius: 12px;
}

/* --- Stock Search --- */
.stock-search-results {
  position: absolute;
  z-index: 1000;
  width: 100%;
  max-height: 200px;
  overflow-y: auto;
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-top: none;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

.stock-search-results .list-group-item {
  cursor: pointer;
  background: transparent !important;
  color: var(--text-primary) !important;
  border-color: rgba(0, 0, 0, 0.06) !important;
  transition: var(--transition-smooth);
}

.stock-search-results .list-group-item:hover {
  background: rgba(59, 130, 246, 0.1) !important;
}

/* --- Page Headings --- */
h2 {
  font-weight: 700;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

h2 i {
  margin-right: 0.4rem;
  opacity: 0.7;
}

h4 {
  font-weight: 600;
  color: var(--text-primary);
}

h5 {
  font-weight: 600;
}

h6 {
  font-weight: 500;
}

.text-muted {
  color: var(--text-muted) !important;
}

/* --- Section value highlights --- */
.card-body h4 {
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}

/* portfolio value glow */
.value-glow {
  color: #2563eb;
  text-shadow: 0 0 20px rgba(37, 99, 235, 0.15);
}

/* --- Stats grid on subpages --- */
.stat-label {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* --- Footer --- */
.footer-custom {
  background: linear-gradient(135deg, rgba(248, 250, 252, 0.95), rgba(241, 245, 249, 0.98)) !important;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  color: var(--text-muted) !important;
}

.footer-custom small {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* --- Login Page --- */
.login-wrapper {
  min-height: 100vh;
  background: #f0f4f8;
  position: relative;
  overflow: hidden;
}

.login-wrapper::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 40%, rgba(59, 130, 246, 0.1) 0%, transparent 50%),
              radial-gradient(circle at 70% 60%, rgba(139, 92, 246, 0.08) 0%, transparent 50%);
  animation: loginBgShift 20s ease infinite alternate;
}

@keyframes loginBgShift {
  0% { transform: translate(0, 0); }
  100% { transform: translate(-5%, -3%); }
}

.login-card {
  background: rgba(255, 255, 255, 0.9) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass) !important;
  border-radius: 20px !important;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05) !important;
  position: relative;
  z-index: 1;
}

.login-card .card-title {
  font-weight: 700;
  font-size: 1.5rem;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-card .btn-primary {
  padding: 0.65rem;
  font-size: 1rem;
  font-weight: 600;
}

/* --- Snapshot Button --- */
.btn-snapshot {
  background: rgba(0, 0, 0, 0.04) !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  color: var(--text-secondary) !important;
  border-radius: 10px;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition-smooth);
}

.btn-snapshot:hover {
  background: rgba(59, 130, 246, 0.12) !important;
  border-color: rgba(59, 130, 246, 0.3) !important;
  color: var(--accent-blue) !important;
  transform: translateY(-1px);
}

/* --- Chart container --- */
#netWorthChart {
  border-radius: 8px;
}

/* --- Transaction type badges --- */
.badge.bg-success {
  background: var(--gradient-success) !important;
  font-weight: 500;
}
.badge.bg-danger {
  background: var(--gradient-danger) !important;
  font-weight: 500;
}
.badge.bg-secondary {
  background: rgba(0, 0, 0, 0.06) !important;
  color: var(--text-secondary) !important;
}
.badge.bg-info {
  background: rgba(6, 182, 212, 0.15) !important;
  color: #22d3ee !important;
}
.badge.bg-warning {
  background: rgba(245, 158, 11, 0.15) !important;
  color: #fbbf24 !important;
}

/* --- HR --- */
hr {
  border-color: var(--border-glass);
  opacity: 1;
}

/* --- Responsive tweaks --- */
@media (max-width: 768px) {
  .net-worth-total {
    font-size: 2.2rem;
  }

  .card {
    border-radius: 12px;
  }

  h2 {
    font-size: 1.3rem;
  }
}

/* --- Animation for page load --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: fadeInUp 0.4s ease forwards;
}

.row > .col-12 .card:nth-child(1) { animation-delay: 0.05s; }
.row > .col-12 .card:nth-child(2) { animation-delay: 0.1s; }
.row > .col-12 .card:nth-child(3) { animation-delay: 0.15s; }

/* Make sure text-decoration-none inherits theme colors */
.text-decoration-none {
  color: var(--accent-blue) !important;
}
.text-decoration-none:hover {
  color: var(--accent-purple) !important;
}

/* Container override for dark background */
.container {
  color: var(--text-primary);
}
