/* ========================================
   CSS Variables & Reset
   ======================================== */
:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #252542;
  --bg-glass: rgba(37, 37, 66, 0.8);
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --success: #22c55e;
  --warning: #eab308;
  --error: #ef4444;
  --gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --radius: 16px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

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

/* ========================================
   Screens & Layout
   ======================================== */
.screen {
  display: none;
  min-height: 100vh;
}

.screen.active {
  display: block;
}

/* ========================================
   Auth Screen
   ======================================== */
.auth-container {
  max-width: 400px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.logo {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.auth-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.auth-header p {
  color: var(--text-secondary);
}

.auth-tabs {
  display: flex;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 1.5rem;
}

.tab-btn {
  flex: 1;
  padding: 0.75rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  border-radius: calc(var(--radius) - 4px);
  transition: all 0.3s ease;
}

.tab-btn.active {
  background: var(--accent);
  color: white;
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.875rem 1rem;
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
}

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

/* ========================================
   Buttons
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary {
  background: var(--gradient);
  color: white;
  width: 100%;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.btn-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-icon:hover {
  background: var(--accent);
  color: white;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
}

.error-message {
  color: var(--error);
  text-align: center;
  margin-top: 1rem;
  font-size: 0.875rem;
}

/* ========================================
   Main Header
   ======================================== */
.main-header {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  padding: 1rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.greeting {
  font-size: 1.125rem;
  font-weight: 500;
}

#user-name {
  color: var(--accent-light);
}

/* ========================================
   Stats Section
   ======================================== */
.stats-section {
  padding: 1.5rem;
}

.stats-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stats-card.main-stat {
  background: var(--gradient);
  margin-bottom: 1rem;
}

.stat-label {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.8);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
}

.stat-value.small {
  font-size: 1.5rem;
}

.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.stats-card.clickable {
  cursor: pointer;
  transition: all 0.2s ease;
}

.stats-card.clickable:hover {
  background: var(--accent);
  transform: translateY(-2px);
}

.stats-card.clickable:active {
  transform: translateY(0);
}

/* ========================================
   Category Section
   ======================================== */
.category-section {
  padding: 0 1.5rem 1.5rem;
}

.category-section h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.category-chart {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
}

.category-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.category-info {
  flex: 1;
}

.category-name {
  font-size: 0.875rem;
  font-weight: 500;
}

.category-bar {
  height: 4px;
  background: var(--bg-secondary);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}

.category-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

.category-amount {
  font-weight: 600;
  font-size: 0.875rem;
}

/* ========================================
   Expenses Section
   ======================================== */
.expenses-section {
  padding: 0 1.5rem 6rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.section-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.expenses-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.expense-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  padding: 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.expense-item:hover {
  transform: translateX(4px);
}

.expense-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.expense-details {
  flex: 1;
}

.expense-desc {
  font-weight: 500;
  margin-bottom: 2px;
}

.expense-category {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.expense-right {
  text-align: right;
}

.expense-amount {
  font-weight: 600;
  color: var(--error);
}

.expense-date {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ========================================
   FAB (Floating Action Button)
   ======================================== */
.fab {
  position: fixed;
  bottom: 2rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gradient);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
  transition: all 0.3s ease;
  z-index: 100;
}

.fab:hover {
  transform: scale(1.1);
}

/* ========================================
   Modal
   ======================================== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  padding: 1rem;
  overflow-y: auto;
}

.modal.active {
  display: flex;
  align-items: flex-end;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 1.5rem;
  animation: slideUp 0.3s ease;
}

.modal-content.full-height {
  height: 90vh;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(100px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
}

.amount-input {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  transition: border-color 0.3s ease;
}

.amount-input:focus-within {
  border-color: var(--accent);
}

.amount-input .currency {
  padding: 0 0 0 1rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.amount-input input {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  font-weight: 600;
}

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.form-actions .btn {
  flex: 1;
}

/* ========================================
   Filter Bar
   ======================================== */
.filter-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.filter-bar select,
.filter-bar input {
  flex: 1;
  padding: 0.75rem;
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
}

/* ========================================
   Empty State
   ======================================== */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-secondary);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* ========================================
   Responsive
   ======================================== */
@media (min-width: 768px) {
  .modal.active {
    align-items: center;
  }

  .modal-content {
    border-radius: var(--radius);
    max-height: 90vh;
    overflow-y: auto;
  }

  .stats-row {
    grid-template-columns: repeat(4, 1fr);
  }

  .category-chart {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }
}