/* Love Expenses - Main Styles */
:root {
  --primary: #2196F3;
  --primary-dark: #1976D2;
  --accent: #64B5F6;
  --bg: #f5f7fa;
  --card-bg: #ffffff;
  --text: #2d3748;
  --text-muted: #718096;
  --border: #e2e8f0;
  --danger: #e53e3e;
  --success: #38a169;
  --warning: #dd6b20;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding-top: var(--safe-top);
}

/* Login Page */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--card-bg);
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.08);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.login-logo .bx-heart {
  font-size: 48px;
  color: var(--primary);
}

.login-card h1 {
  font-size: 1.5rem;
  margin-bottom: 8px;
  color: var(--text);
  text-align: center;
}

.login-card .subtitle {
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: 0.95rem;
  text-align: center;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 0.9rem;
}

.form-group input, .form-group select {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

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

.checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-wrap input { width: auto; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
  margin-top: 10px;
}

.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.settlement-btn { width: auto; margin-top: 0; min-width: 130px; }

/* Settlements Date Filter - Modern & Sleek */
.date-filter-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.06);
  border: 1px solid var(--border);
}
.date-filter-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}
.date-filter-label .bx {
  font-size: 1.2rem;
  color: var(--primary);
}
.date-filter-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.date-preset {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}
.date-preset .bx {
  font-size: 1.1rem;
}
.date-preset:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(33, 150, 243, 0.08);
}
.date-preset.active {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
.date-filter-range {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  animation: dateRangeFade 0.2s ease;
}
@keyframes dateRangeFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.date-range-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}
.date-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.date-input-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}
.date-input-group input {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.95rem;
  min-width: 170px;
  transition: border-color 0.2s;
}
.date-input-group input:focus {
  outline: none;
  border-color: var(--primary);
}
.date-apply-btn {
  width: auto;
  margin-top: 0;
  padding: 12px 24px;
  border-radius: 12px;
}

/* Review Section - Trigger & Popover (Sandesh only) */
.review-trigger-wrap {
  position: relative;
  display: inline-flex;
}
.review-trigger-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--warning);
  font-size: 1.4rem;
  cursor: pointer;
  transition: all 0.2s;
}
.review-trigger-btn:hover {
  background: rgba(221, 107, 32, 0.1);
  border-color: var(--warning);
  color: var(--warning);
}
.review-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.review-popover {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  z-index: 1000;
  min-width: 90vw;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
}
.review-popover-inner {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  border: 1px solid var(--border);
}
.review-badge:empty { display: none !important; }

@media (max-width: 768px) {
  .review-popover { min-width: calc(100vw - 32px); right: auto; left: 50%; transform: translateX(-50%); }
  .review-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 768px) {
  .date-filter-card { padding: 18px; }
  .date-filter-label { margin-bottom: 14px; font-size: 0.85rem; }
  .date-filter-presets { gap: 10px; }
  .date-preset { padding: 10px 16px; font-size: 0.85rem; }
  .date-input-group { min-width: 100%; }
  .date-input-group input { min-width: 100%; }
  .date-range-inputs { flex-direction: column; }
  .date-apply-btn { width: 100%; }
}

.link { color: var(--primary); text-decoration: none; font-size: 0.9rem; }
.link:hover { text-decoration: underline; }

.alert {
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.alert-danger { background: #fed7d7; color: #c53030; }
.alert-success { background: #c6f6d5; color: #276749; }

/* App Layout */
.app-wrap {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 20px;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
  color: var(--text);
}

.sidebar-brand {
  padding: 0;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-brand .bx-heart { font-size: 1.5rem; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.2s;
  gap: 10px;
}
.sidebar-nav a .bx { font-size: 1.25rem; }

.sidebar-nav a:hover, .sidebar-nav a.active {
  background: rgba(33, 150, 243, 0.1);
  color: var(--primary);
}

.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 24px;
  min-height: 100vh;
  overflow-x: hidden;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.header h2 { font-size: 1.5rem; display: flex; align-items: center; gap: 8px; }

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 8px;
  color: var(--text);
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
  padding: 20px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

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

/* Stats Grid - Equal cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

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

.stat-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: white;
  flex-shrink: 0;
}

/* Expense List - Desktop Table */
.expense-table {
  width: 100%;
  border-collapse: collapse;
}

.expense-table th, .expense-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.expense-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.expense-table tr:hover { background: rgba(0,0,0,0.02); }

/* ========== MOBILE APP STYLE ========== */
@media (max-width: 768px) {
  .menu-toggle { display: flex; align-items: center; justify-content: center; }
  .sidebar-close { display: flex; align-items: center; justify-content: center; }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s;
  }
  .sidebar-overlay.show { display: block; opacity: 1; }
  .sidebar {
    transform: translateX(-100%);
    z-index: 100;
    transition: transform 0.3s;
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content {
    margin-left: 0;
    padding: 12px 16px;
    padding-bottom: 100px;
    padding-top: calc(12px + var(--safe-top));
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    box-sizing: border-box;
  }
  .dashboard-page .card { padding: 14px; margin-bottom: 12px; }
  
  .expense-table-wrap { display: none; }
  .expense-cards { display: block; }
  
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
  }
  .stats-grid .card {
    margin-bottom: 0;
    padding: 12px;
    min-height: 0;
  }
  .stats-grid .stat-icon { width: 36px; height: 36px; font-size: 1rem; }
  .stats-grid .card-title { font-size: 0.8rem; margin-bottom: 4px; }
  .stats-grid .stat-value { font-size: 1.2rem; }
  
  .stat-value { font-size: 1.5rem; }
  .card { border-radius: 16px; padding: 16px; margin-bottom: 16px; }
  
  .header {
    padding: 8px 0 16px;
    margin-bottom: 20px;
    position: sticky;
    top: var(--safe-top);
    background: var(--bg);
    z-index: 10;
  }
  .header h2 { font-size: 1.25rem; }
  
  .btn-add-fab {
    position: fixed;
    bottom: calc(80px + var(--safe-bottom));
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(33, 150, 243, 0.4);
    z-index: 40;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
  }
  .btn-add-fab .bx { font-size: 1.75rem; }
  .header .btn-primary:not(.btn-add-fab) { display: none; }
}

@media (min-width: 769px) {
  .btn-add-fab { display: none !important; }
}

/* Mobile Cards - full app feel */
.expense-cards { display: none; }

@media (max-width: 768px) {
  .expense-cards {
    display: block;
  }
  .expense-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    border-left: 4px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 72px;
  }
  .expense-card .amount {
    font-size: 1.25rem;
    font-weight: 700;
    min-width: 80px;
    text-align: right;
  }
  .expense-card .card-body {
    flex: 1;
    min-width: 0;
  }
  .expense-card .meta {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 4px;
  }
}

/* Mobile Bottom Nav - App style */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  padding: 8px 8px calc(8px + var(--safe-bottom));
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  z-index: 50;
}

@media (max-width: 768px) {
  .mobile-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
  }
  .mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.7rem;
    gap: 4px;
    border-radius: 12px;
    transition: all 0.2s;
    min-width: 56px;
  }
  .mobile-nav a .bx {
    font-size: 1.5rem;
  }
  .mobile-nav a.active {
    color: var(--primary);
    background: rgba(33, 150, 243, 0.1);
    font-weight: 600;
  }
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 24px;
  max-width: 440px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal h3 { margin-bottom: 20px; display: flex; align-items: center; gap: 8px; }

/* Mobile: Bottom Sheet style */
@media (max-width: 768px) {
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    border-radius: 20px 20px 0 0;
    max-height: 85vh;
    padding-bottom: calc(20px + var(--safe-bottom));
    animation: slideUp 0.3s ease;
  }
  .modal::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: -8px auto 16px;
  }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* Review section - stack on mobile */
@media (max-width: 768px) {
  .review-grid { grid-template-columns: 1fr !important; }
}

.hide { display: none !important; }

/* Category badge */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state .bx { font-size: 48px; opacity: 0.3; margin-bottom: 12px; display: block; }
