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

:root {
  /* Color Palette */
  --bg-gradient: linear-gradient(135deg, #070913 0%, #0c1020 50%, #1a103c 100%);
  --panel-bg: rgba(13, 17, 33, 0.7);
  --panel-border: rgba(255, 255, 255, 0.08);
  --card-bg: rgba(255, 255, 255, 0.03);
  --card-border: rgba(255, 255, 255, 0.05);
  
  --primary-color: #6366f1; /* Neon Indigo */
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.25);
  
  --secondary-color: #a855f7; /* Purple */
  --accent-color: #06b6d4; /* Cyan */
  
  --text-main: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* Status Colors */
  --status-pending-bg: rgba(245, 158, 11, 0.15);
  --status-pending-text: #fbbf24;
  --status-progress-bg: rgba(59, 130, 246, 0.15);
  --status-progress-text: #60a5fa;
  --status-complete-bg: rgba(16, 185, 129, 0.15);
  --status-complete-text: #34d399;
  
  /* Category Colors */
  --cat-work-bg: rgba(99, 102, 241, 0.2);
  --cat-work-text: #818cf8;
  --cat-personal-bg: rgba(236, 72, 153, 0.2);
  --cat-personal-text: #f472b6;
  --cat-health-bg: rgba(16, 185, 129, 0.2);
  --cat-health-text: #34d399;
  --cat-finance-bg: rgba(245, 158, 11, 0.2);
  --cat-finance-text: #fbbf24;
  --cat-other-bg: rgba(148, 163, 184, 0.2);
  --cat-other-text: #cbd5e1;

  /* Dimensions */
  --border-radius-lg: 16px;
  --border-radius-md: 10px;
  --border-radius-sm: 6px;
  
  /* Transitions */
  --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base resets & styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  padding: 2rem 1.5rem;
  overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* App Container */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Glassmorphic Header & Panels */
header {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-lg);
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  width: 42px;
  height: 42px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  color: white;
  box-shadow: 0 0 15px var(--primary-glow);
}

.brand-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  background: linear-gradient(to right, #ffffff, #c7d2fe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: -2px;
}

/* Toolbar Controls */
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-md);
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition-smooth);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary-color);
  border-color: transparent;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: transparent;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

/* Stats Dashboard */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-lg);
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary-color);
}

.stat-card.stat-value::after { background: var(--secondary-color); }
.stat-card.stat-avg::after { background: var(--accent-color); }
.stat-card.stat-net::after { background: var(--net-indicator-color, var(--text-muted)); }

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-val {
  font-family: 'Outfit', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.1;
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--text-secondary);
}

/* Spreadsheet Wrapper */
.spreadsheet-container {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.35);
}

/* Search and Filter bar */
.filter-bar {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.search-wrapper {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.search-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  border-radius: var(--border-radius-md);
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  outline: none;
  transition: var(--transition-smooth);
}

.search-input:focus {
  border-color: var(--primary-color);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.15);
}

.search-icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.875rem;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Table Style */
.table-scroll {
  overflow-x: auto;
  max-height: calc(100vh - 350px);
  min-height: 400px;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

th {
  background: rgba(12, 16, 32, 0.9);
  padding: 0.875rem 1.25rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--panel-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: var(--transition-smooth);
}

tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.01);
}

tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

td {
  padding: 0;
  position: relative;
}

/* Cell Inputs */
.cell-input {
  width: 100%;
  height: 44px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-main);
  padding: 0.5rem 1.25rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  outline: none;
  transition: var(--transition-smooth);
}

.cell-input::placeholder {
  color: var(--text-muted);
  opacity: 0.5;
}

.cell-input:focus {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid var(--primary-color);
  box-shadow: inset 0 0 4px rgba(99, 102, 241, 0.2);
  z-index: 5;
}

/* Day Column (Read only styling) */
.day-cell {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0.5rem 1.25rem;
  width: 90px;
  text-align: center;
  background: rgba(0, 0, 0, 0.15);
  border-right: 1px solid var(--panel-border);
  user-select: none;
}

/* Dropdown Cell Styling */
.cell-select {
  width: 100%;
  height: 44px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-main);
  padding: 0.5rem 1.25rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: var(--transition-smooth);
}

.cell-select:focus {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid var(--primary-color);
  z-index: 5;
}

/* Wrap select in a container for the arrow */
.select-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
}

.select-wrapper::after {
  content: '▼';
  font-size: 0.6rem;
  color: var(--text-muted);
  position: absolute;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0.6;
  transition: var(--transition-smooth);
}

.select-wrapper:focus-within::after {
  color: var(--primary-color);
  opacity: 1;
}

/* Color Code Statuses inside table */
select[data-type="status"].status-pending {
  color: var(--status-pending-text);
  font-weight: 500;
}
select[data-type="status"].status-progress {
  color: var(--status-progress-text);
  font-weight: 500;
}
select[data-type="status"].status-complete {
  color: var(--status-complete-text);
  font-weight: 500;
}

/* Make dropdown options look neat on operating system dropdowns */
.cell-select option {
  background: #0f172a;
  color: var(--text-main);
  padding: 8px;
}

/* Category Pill Styling when rendering */
.select-wrapper.category-wrapper {
  padding: 0 0.5rem;
  display: flex;
  align-items: center;
}

.category-select {
  padding-left: 0.75rem !important;
}

/* Numeric alignment */
.number-input {
  text-align: right;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  transition: var(--transition-smooth);
}

/* Budget threshold fonts */
.budget-under {
  color: #34d399 !important; /* Emerald green for under or equal to $20 */
  text-shadow: 0 0 8px rgba(52, 211, 153, 0.1);
}

.budget-over {
  color: #f87171 !important; /* Rose red for over $20 */
  text-shadow: 0 0 8px rgba(248, 113, 113, 0.1);
}

/* Import dialog / hidden file input */
#csv-file-input {
  display: none;
}

/* Footer Section */
footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.footer-toolbar {
  display: flex;
  gap: 0.5rem;
}

.keyboard-shortcuts-info {
  display: flex;
  gap: 1rem;
  color: var(--text-secondary);
}

.kbd-badge {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.7rem;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid var(--primary-color);
  color: var(--text-main);
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 15px rgba(99, 102, 241, 0.2);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 100;
  transform: translateY(100px);
  opacity: 0;
  transition: cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.4s;
}

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

/* Category Badge Indicators */
.cat-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.cat-work { background: var(--cat-work-bg); color: var(--cat-work-text); }
.cat-personal { background: var(--cat-personal-bg); color: var(--cat-personal-text); }
.cat-health { background: var(--cat-health-bg); color: var(--cat-health-text); }
.cat-finance { background: var(--cat-finance-bg); color: var(--cat-finance-text); }
.cat-other { background: var(--cat-other-bg); color: var(--cat-other-text); }

/* Budget Selector Bar */
.budget-selector-bar {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-lg);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  flex-wrap: wrap;
}

.selector-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.budget-options {
  display: flex;
  gap: 0.5rem;
}

.btn-budget {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  padding: 0.4rem 1.25rem;
  border-radius: var(--border-radius-md);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-budget:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-budget.active {
  background: var(--primary-color);
  border-color: transparent;
  color: white;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

/* Streak Widget Styles */
.streak-widget {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  padding: 0.4rem 1.25rem;
  border-radius: var(--border-radius-md);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  transition: var(--transition-smooth);
}

.streak-widget:hover {
  border-color: rgba(245, 158, 11, 0.3);
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.1);
}

.streak-icon-fire {
  font-size: 1.5rem;
  animation: flame-flicker 1.5s ease-in-out infinite alternate;
}

.streak-details {
  display: flex;
  flex-direction: column;
}

.streak-count {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
}

.streak-label-sub {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Flame animation */
@keyframes flame-flicker {
  0% { transform: scale(0.92) rotate(-2deg); filter: drop-shadow(0 0 2px rgba(245, 158, 11, 0.5)); }
  100% { transform: scale(1.08) rotate(2deg); filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.8)); }
}


/* Grid View Styles */
.grid-legend {
  display: flex;
  justify-content: flex-end;
  gap: 1.25rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--panel-border);
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.safe-dot { background: var(--status-complete-text); }
.overspend-dot { background: #f87171; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 1rem;
  padding: 1.5rem;
  max-height: calc(100vh - 350px);
  overflow-y: auto;
}

.grid-card {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--border-radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.grid-card:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.04);
}

.grid-card.unlogged {
  border: 1px dashed rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.grid-card.safe-spend {
  border: 1px solid var(--status-complete-text);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.05);
}



.grid-card.over-spend {
  border: 1px solid #f87171;
  box-shadow: 0 0 10px rgba(248, 113, 113, 0.05);
}

.grid-card-day {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.grid-card-info {
  text-align: right;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.grid-card.safe-spend .grid-card-info { color: var(--status-complete-text); }

.grid-card.over-spend .grid-card-info { color: #f87171; }

.grid-card-input-wrapper {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  gap: 0.5rem;
}

.grid-card-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--primary-color);
  color: var(--text-main);
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  text-align: center;
  border-radius: var(--border-radius-sm);
  outline: none;
  padding: 0.25rem;
  font-size: 0.85rem;
}

.active-view-btn {
  background: var(--primary-color) !important;
  border-color: transparent !important;
  color: white !important;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

/* Month Selector Dropdown */
.month-select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 0.4rem 1.25rem;
  border-radius: var(--border-radius-md);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.month-select:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.month-select option {
  background: #0d0f1a;
  color: var(--text-main);
}

/* Wave View Chart Styles */
.wave-chart-card {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-lg);
  padding: 1.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  margin: 1rem 0;
}

.chart-header {
  margin-bottom: 1.5rem;
}

.chart-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.chart-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.chart-body {
  width: 100%;
  height: 350px;
  position: relative;
}

.grid-card-note {
  font-size: 0.65rem;
  font-weight: normal;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.25rem;
  max-width: 90px;
}

.chart-dot-group:hover circle:first-child {
  r: 9;
  filter: drop-shadow(0 0 6px var(--primary-color));
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .table-scroll {
    max-height: none;
  }
  table {
    min-width: 800px;
  }
}

@media (max-width: 600px) {
  body {
    padding: 1rem;
  }
  header {
    flex-direction: column;
    align-items: flex-start;
  }
  .toolbar {
    width: 100%;
    justify-content: space-between;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  footer {
    flex-direction: column;
    gap: 0.5rem;
  }
}
