/* ==========================================================================
   BOLAB Ledger - Modern Dark Mode & Glassmorphism Stylesheet
   ========================================================================== */

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

:root {
  /* Color Tokens */
  --bg-dark: #090d16;
  --bg-card: rgba(22, 30, 46, 0.6);
  --bg-card-hover: rgba(30, 41, 64, 0.75);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-active: rgba(0, 242, 254, 0.4);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  /* Brand & Status Colors */
  --primary: #00f2fe;
  --primary-glow: rgba(0, 242, 254, 0.25);
  --accent-purple: #7c3aed;
  --income-green: #10b981;
  --income-glow: rgba(16, 185, 129, 0.25);
  --expense-red: #f43f5e;
  --expense-glow: rgba(244, 63, 94, 0.25);
  --warning-yellow: #f59e0b;
  
  /* UI Metrics */
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: 'Inter', 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 10% 10%, rgba(124, 58, 237, 0.15) 0px, transparent 50%),
    radial-gradient(at 90% 90%, rgba(0, 242, 254, 0.12) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(16, 185, 129, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  padding-bottom: 80px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-glass);
  padding: 12px 24px;
}

.header-container {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #00f2fe 0%, #7c3aed 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  color: #fff;
  box-shadow: 0 0 20px var(--primary-glow);
}

.brand-title-group h1 {
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(90deg, #fff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Custom Select Dropdowns */
.select-wrapper select, .btn-glass {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}

.select-wrapper select:hover, .btn-glass:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.select-wrapper select option {
  background: #111827;
  color: #f8fafc;
}

.mode-selector {
  border: 1px solid var(--primary) !important;
  color: var(--primary) !important;
  font-weight: 600 !important;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 12px 4px 4px;
  border-radius: 30px;
  border: 1px solid var(--border-glass);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981 0%, #00f2fe 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
}

/* ==========================================================================
   Main Container & Grid Layout
   ========================================================================== */
.main-wrapper {
  max-width: 1280px;
  margin: 24px auto;
  padding: 0 20px;
}

.grid-dashboard {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 20px;
}

/* Glass Card Component */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-glow);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

/* Summary Cards (Top Row) */
.card-summary {
  grid-column: span 4;
}

@media (max-width: 900px) {
  .card-summary {
    grid-column: span 12;
  }
}

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

.summary-title {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

.summary-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.icon-income { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.icon-expense { background: rgba(244, 63, 94, 0.15); color: #f43f5e; }
.icon-net { background: rgba(0, 242, 254, 0.15); color: #00f2fe; }

.summary-amount {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.amount-income { color: var(--income-green); }
.amount-expense { color: var(--expense-red); }
.amount-net { color: var(--primary); }

/* Budget Bar Section */
.card-budget {
  grid-column: span 12;
}

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

.budget-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.budget-status-tag {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.tag-safe { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.tag-warning { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.tag-over { background: rgba(244, 63, 94, 0.2); color: #f43f5e; }

.progress-track {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.5s ease-in-out, background-color 0.3s;
}

/* Analytics Charts */
.card-chart-donut {
  grid-column: span 5;
}
.card-chart-bar {
  grid-column: span 7;
}

@media (max-width: 992px) {
  .card-chart-donut, .card-chart-bar {
    grid-column: span 12;
  }
}

.chart-wrapper {
  position: relative;
  height: 260px;
  margin-top: 10px;
}

/* Shop Mode Formula Banner */
.shop-banner {
  grid-column: span 12;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.2) 0%, rgba(0, 242, 254, 0.15) 100%);
  border: 1px solid rgba(0, 242, 254, 0.3);
}

.formula-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 14px;
  text-align: center;
}

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

.formula-item {
  background: rgba(0, 0, 0, 0.25);
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
}

.formula-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.formula-val {
  font-size: 1.2rem;
  font-weight: 700;
}

/* Family Sharing Panel */
.family-panel {
  grid-column: span 12;
}

.share-code-box {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.3);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--primary);
  width: fit-content;
  margin-top: 10px;
}

.code-display {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--primary);
}

/* Debt & Accounts Modules */
.card-section {
  grid-column: span 6;
}

@media (max-width: 900px) {
  .card-section { grid-column: span 12; }
}

.account-item, .debt-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  transition: var(--transition);
}

.account-item:hover, .debt-item:hover {
  background: rgba(255, 255, 255, 0.07);
}

.item-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.item-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.item-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.item-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Transactions History List */
.card-transactions {
  grid-column: span 12;
}

.list-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.list-controls select, .list-controls input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: #fff;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  outline: none;
}

.tx-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border-glass);
  transition: var(--transition);
}

.tx-row:first-child { border-top-left-radius: var(--radius-md); border-top-right-radius: var(--radius-md); }
.tx-row:last-child { border-bottom-left-radius: var(--radius-md); border-bottom-right-radius: var(--radius-md); border-bottom: none; }

.tx-row:hover {
  background: rgba(255, 255, 255, 0.08);
}

.tx-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.tx-category-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: rgba(255, 255, 255, 0.08);
}

.tx-details .tx-cat-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.tx-details .tx-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
  align-items: center;
}

.tx-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.tx-amount {
  font-size: 1.1rem;
  font-weight: 700;
}

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

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: var(--transition);
}

.btn-icon:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

.btn-delete:hover {
  color: var(--expense-red);
  background: rgba(244, 63, 94, 0.15);
}

/* ==========================================================================
   Floating Action Button & Modals
   ========================================================================== */
.fab-add {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00f2fe 0%, #7c3aed 100%);
  color: #fff;
  border: none;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px rgba(0, 242, 254, 0.4);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  z-index: 90;
}

.fab-add:hover {
  transform: scale(1.08) rotate(90deg);
  box-shadow: 0 14px 30px rgba(0, 242, 254, 0.6);
}

/* Modal Backdrop & Container */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: #111827;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 520px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.8);
  transform: translateY(20px);
  transition: transform 0.3s ease;
  max-height: 90vh;
  overflow-y: auto;
}

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

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

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
}

/* Form Controls in Modal */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-control {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 12px var(--primary-glow);
}

/* Type Toggle Buttons */
.type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.btn-toggle {
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
}

.btn-toggle.active-expense {
  background: var(--expense-red);
  color: #fff;
  border-color: var(--expense-red);
  box-shadow: 0 0 15px var(--expense-glow);
}

.btn-toggle.active-income {
  background: var(--income-green);
  color: #fff;
  border-color: var(--income-green);
  box-shadow: 0 0 15px var(--income-glow);
}

/* Big Number Keypad / Input */
.amount-input-large {
  font-size: 2rem !important;
  font-weight: 800 !important;
  text-align: right;
  color: var(--primary);
}

/* Category Grid Picker */
.category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.cat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.cat-item span.icon {
  font-size: 22px;
  margin-bottom: 4px;
}

.cat-item:hover, .cat-item.selected {
  background: rgba(0, 242, 254, 0.15);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-md);
  border: none;
  background: linear-gradient(135deg, #00f2fe 0%, #7c3aed 100%);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 6px 20px var(--primary-glow);
  transition: var(--transition);
  margin-top: 10px;
}

.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

/* Utility & Auth Overlay Rules */
.hidden {
  display: none !important;
}

#auth-overlay:not(.hidden) {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(9, 13, 22, 0.98);
  z-index: 99999;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  backdrop-filter: blur(25px);
  opacity: 1 !important;
  pointer-events: auto !important;
}
