/* ===========================================
   Yuvi's Daily Expense Tracker — styles.css
   Modern, mobile-first, premium design
   =========================================== */

/* ---------- Design Tokens ---------- */
:root {
  --bg: #f0f2f8;
  --bg-card: #ffffff;
  --bg-muted: #f8f9fc;
  --text: #1a1d2e;
  --text-sec: #5a6074;
  --text-muted: #9ea3b8;
  --border: #e4e7f0;

  --accent: #6c63ff;
  --accent-light: #ede9fe;
  --accent-dark: #4f46e5;

  --green: #10b981;
  --green-light: #d1fae5;
  --red: #ef4444;
  --red-light: #fee2e2;
  --blue: #3b82f6;
  --blue-light: #dbeafe;
  --amber: #f59e0b;
  --amber-light: #fef3c7;
  --pink: #ec4899;
  --pink-light: #fce7f3;
  --teal: #14b8a6;
  --teal-light: #ccfbf1;

  --shadow-xs: 0 1px 4px rgba(0,0,0,0.06);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.07);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.09);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.15);

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-full: 9999px;

  --t: 0.2s ease;
  --t-slow: 0.35s ease;
}

/* ---------- Reset ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- Header ---------- */
.header {
  background: linear-gradient(135deg, #6c63ff 0%, #a855f7 50%, #ec4899 100%);
  color: white;
  padding: 2.5rem 1.25rem 3rem;
  text-align: center;
  border-radius: 0 0 var(--r-xl) var(--r-xl);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.header-inner {
  position: relative;
  z-index: 1;
}

/* ---------- Login Screen ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6c63ff 0%, #a855f7 50%, #ec4899 100%);
  padding: 1.25rem;
}

.login-container {
  width: 100%;
  max-width: 400px;
}

.login-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 2.5rem 2rem;
  box-shadow: 0 16px 48px rgba(0,0,0,0.18);
  animation: slideUp 0.4s ease both;
}

.login-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-emoji {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  display: block;
}

.login-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.login-header p {
  color: var(--text-sec);
  font-size: 0.9rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-error {
  background: #fee2e2;
  color: #dc2626;
  padding: 0.65rem 0.875rem;
  border-radius: 8px;
  font-size: 0.875rem;
  text-align: center;
  font-weight: 500;
}

.btn--block {
  width: 100%;
  justify-content: center;
}

.btn-logout {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: rgba(255,255,255,0.2);
  color: white;
  border: 1.5px solid rgba(255,255,255,0.35);
  padding: 0.45rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
  -webkit-tap-highlight-color: transparent;
}

.btn-logout:hover {
  background: rgba(255,255,255,0.32);
  transform: translateY(-1px);
}

/* ---------- Header ---------- */
.header-emoji {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  display: block;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}

.header h1 {
  font-size: clamp(1.5rem, 5vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 0.4rem;
  text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header p {
  font-size: clamp(0.875rem, 2.5vw, 1.05rem);
  opacity: 0.9;
  font-weight: 400;
}

/* ---------- Container ---------- */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ---------- Summary Cards ---------- */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.875rem;
  margin-bottom: 1.5rem;
  margin-top: -1.5rem;
}

.summary-card {
  background: var(--bg-card);
  border-radius: var(--r-md);
  padding: 1.125rem 1rem;
  box-shadow: var(--shadow-md);
  border-left: 4px solid transparent;
  transition: transform var(--t), box-shadow var(--t);
  position: relative;
  overflow: hidden;
}

.summary-card::after {
  content: '';
  position: absolute;
  top: -20px;
  right: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  opacity: 0.07;
}

.summary-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.summary-card--today   { border-color: var(--accent); }
.summary-card--today::after { background: var(--accent); }
.summary-card--count   { border-color: var(--green); }
.summary-card--count::after { background: var(--green); }
.summary-card--month   { border-color: var(--amber); }
.summary-card--month::after { background: var(--amber); }
.summary-card--avg     { border-color: var(--pink); }
.summary-card--avg::after { background: var(--pink); }

.summary-card__icon {
  font-size: 1.5rem;
  margin-bottom: 0.35rem;
}

.summary-card__label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.summary-card__value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.summary-card--today .summary-card__value   { color: var(--accent); }
.summary-card--count .summary-card__value   { color: var(--green); }
.summary-card--month .summary-card__value   { color: var(--amber); }
.summary-card--avg .summary-card__value     { color: var(--pink); }

/* ---------- Sections ---------- */
.section {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 1.375rem 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  animation: fadeUp 0.4s ease both;
}

.section__header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 1.125rem;
  flex-wrap: wrap;
  row-gap: 0.5rem;
}

.section__icon {
  font-size: 1.3rem;
}

.section__title {
  font-size: 1.1rem;
  font-weight: 700;
  flex: 1;
}

.section__actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.section--danger-zone {
  border: 1.5px solid var(--red-light);
}

/* ---------- Form ---------- */
.expense-form {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.form-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.form-group--grow  { flex: 1 1 200px; }
.form-group--half  { flex: 1 1 140px; }
.form-group--amount { flex: 0 0 130px; }

.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-sec);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-group input,
.form-group select {
  padding: 0.7rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-muted);
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a6074' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  padding-right: 2.25rem;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 3.5px rgba(108,99,255,0.14);
}

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

/* hide number spinners */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }
input[type="number"] { -moz-appearance: textfield; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.2rem;
  border: none;
  border-radius: var(--r-sm);
  font-size: 0.92rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--t);
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn--lg { padding: 0.8rem 1.6rem; font-size: 1rem; }
.btn--sm { padding: 0.4rem 0.875rem; font-size: 0.82rem; }

.btn--primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(108,99,255,0.35);
}
.btn--primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(108,99,255,0.45); }
.btn--primary:active { transform: translateY(0); }

.btn--success {
  background: linear-gradient(135deg, var(--green) 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(16,185,129,0.32);
}
.btn--success:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16,185,129,0.42); }

.btn--info {
  background: linear-gradient(135deg, var(--blue) 0%, #2563eb 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(59,130,246,0.32);
}
.btn--info:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(59,130,246,0.42); }

.btn--danger {
  background: linear-gradient(135deg, var(--red) 0%, #dc2626 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(239,68,68,0.28);
}
.btn--danger:hover { transform: translateY(-2px); }

.btn--danger-soft {
  background: var(--red-light);
  color: var(--red);
  border: 1.5px solid rgba(239,68,68,0.25);
}
.btn--danger-soft:hover { background: #fecaca; }

.btn--outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn--outline:hover { background: var(--accent-light); }

.btn--ghost {
  background: var(--bg-muted);
  color: var(--text-sec);
  border: 1.5px solid var(--border);
}
.btn--ghost:hover { background: var(--border); }

.form-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-top: 0.25rem;
}

/* ---------- Entry List / Cards ---------- */
.entry-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.entry-card {
  background: var(--bg-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 0.9rem 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  transition: box-shadow var(--t), border-color var(--t);
  animation: fadeUp 0.3s ease both;
}

.entry-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: #d1d5e4;
}

.entry-card__left {
  flex: 1;
  min-width: 0;
}

.entry-card__title {
  font-weight: 700;
  font-size: 0.97rem;
  color: var(--text);
  margin-bottom: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  font-size: 0.78rem;
  color: var(--text-sec);
}

.entry-card__badge {
  background: var(--accent-light);
  color: var(--accent);
  border-radius: var(--r-full);
  padding: 0.15rem 0.55rem;
  font-weight: 600;
  font-size: 0.73rem;
}

.entry-card__notes {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  font-style: italic;
}

.entry-card__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
  flex-shrink: 0;
}

.entry-card__amount {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--red);
}

.entry-card__btns {
  display: flex;
  gap: 0.35rem;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: all var(--t);
  -webkit-tap-highlight-color: transparent;
}

.icon-btn--edit {
  background: var(--blue-light);
  color: var(--blue);
}
.icon-btn--edit:hover { background: #bfdbfe; }

.icon-btn--del {
  background: var(--red-light);
  color: var(--red);
}
.icon-btn--del:hover { background: #fecaca; }

/* Compact list for report */
.entry-list--compact .entry-card {
  padding: 0.65rem 0.875rem;
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

.empty-state__emoji {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  display: block;
}

.empty-state p {
  font-size: 0.93rem;
}

/* ---------- Month Selector ---------- */
.month-select {
  padding: 0.45rem 2rem 0.45rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.88rem;
  font-family: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-muted);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a6074' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  transition: border-color var(--t);
}

.month-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ---------- Report Stats ---------- */
.report-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.report-stat {
  background: var(--bg-muted);
  border-radius: var(--r-md);
  padding: 0.875rem 0.75rem;
  text-align: center;
  border: 1.5px solid var(--border);
  transition: transform var(--t);
}

.report-stat:hover { transform: translateY(-2px); }

.report-stat__label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.report-stat__value {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent);
  word-break: break-word;
}

/* ---------- Charts ---------- */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.chart-wrapper {
  background: var(--bg-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 1rem;
}

.chart-wrapper h3 {
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 0.875rem;
  text-align: center;
  color: var(--text-sec);
}

.chart-container--donut {
  max-width: 260px;
  margin: 0 auto;
}

.chart-container--bar {
  height: 220px;
  position: relative;
}

/* ---------- Export + Danger ---------- */
.export-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1.5px solid var(--border);
}

.danger-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.data-note {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 30, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  background: var(--bg-card);
  border-radius: var(--r-xl);
  padding: 1.5rem 1.25rem;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s ease;
}

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

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--r-full);
  border: none;
  background: var(--bg-muted);
  color: var(--text-sec);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t);
}

.modal-close:hover { background: var(--red-light); color: var(--red); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: #1a1d2e;
  color: #ffffff;
  padding: 0.7rem 1.4rem;
  border-radius: var(--r-full);
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 2000;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.toast--success { background: var(--green); }
.toast.toast--error   { background: var(--red); }

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 1.5rem 1rem 2.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #a0aec0; }

/* ---------- Animations ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsive ---------- */
@media (min-width: 640px) {
  .summary-cards {
    grid-template-columns: repeat(4, 1fr);
  }

  .summary-card__value {
    font-size: 1.2rem;
  }
}

@media (max-width: 639px) {
  .summary-card__value {
    font-size: 1.15rem;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .form-group--amount {
    flex: 1 1 120px;
  }

  .export-actions {
    flex-direction: column;
  }

  .export-actions .btn {
    width: 100%;
    justify-content: center;
  }

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

@media (max-width: 420px) {
  .container {
    padding: 1.25rem 0.75rem;
  }

  .section {
    padding: 1.125rem 0.875rem;
  }

  .modal-card {
    padding: 1.25rem 1rem;
  }

  .btn--lg {
    padding: 0.75rem 1.2rem;
    font-size: 0.95rem;
  }

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

  .entry-card__title {
    font-size: 0.9rem;
  }

  .entry-card__amount {
    font-size: 1rem;
  }
}