/* ==========================================================================
   Adarsh Group - Modern Mobile-First Application Stylesheet
   Designed for Mobile Screens (max-width 540px centered on desktop)
   ========================================================================== */

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --success: #10b981;
  --success-dark: #059669;
  --success-light: #ecfdf5;
  --expense: #ef4444;
  --expense-dark: #dc2626;
  --expense-light: #fef2f2;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --neutral-900: #0f172a;
  --neutral-800: #1e293b;
  --neutral-700: #334155;
  --neutral-600: #475569;
  --neutral-500: #64748b;
  --neutral-400: #94a3b8;
  --neutral-200: #e2e8f0;
  --neutral-100: #f1f5f9;
  --neutral-50: #f8fafc;
  --white: #ffffff;

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-nav: 0 -4px 12px rgba(0, 0, 0, 0.05);

  --max-app-width: 520px;
}

/* Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  background-color: #e2e8f0;
  font-family: var(--font-family);
  color: var(--neutral-900);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Mobile App Wrapper (Centered on desktop, 100% on mobile) */
.app-container {
  width: 100%;
  max-width: var(--max-app-width);
  margin: 0 auto;
  min-height: 100vh;
  background-color: var(--neutral-50);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 25px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   Header
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--neutral-200);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--neutral-900);
}

.header-logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 2px 5px rgba(79, 70, 229, 0.3);
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--neutral-900);
}

.header-year-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  border: 1px solid rgba(79, 70, 229, 0.15);
  transition: all 0.2s ease;
}

.header-year-pill:hover,
.header-year-pill:active {
  background: #e0e7ff;
  transform: translateY(-1px);
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */
.app-content {
  flex: 1;
  padding: 16px 16px 85px 16px; /* 85px bottom padding ensures sticky nav never hides content */
  overflow-x: hidden;
}

/* Page Sub-Header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--neutral-900);
}

.btn-header-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  color: var(--white);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.25);
  transition: all 0.15s ease;
}

.btn-header-action:active {
  transform: scale(0.97);
}

/* ==========================================================================
   Alerts & Notifications
   ========================================================================== */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: fadeIn 0.3s ease;
}

.alert-success {
  background-color: var(--success-light);
  color: var(--success-dark);
  border: 1px solid #a7f3d0;
}

.alert-error {
  background-color: var(--expense-light);
  color: var(--expense-dark);
  border: 1px solid #fecaca;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Cards & Dashboard Layout
   ========================================================================== */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--neutral-200);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

/* Hero Balance Card */
.balance-card {
  background: linear-gradient(135deg, #1e1b4b, #312e81);
  color: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px 18px;
  margin-bottom: 16px;
  box-shadow: 0 8px 20px rgba(49, 46, 129, 0.25);
  position: relative;
  overflow: hidden;
}

.balance-card::after {
  content: "";
  position: absolute;
  top: -30px;
  right: -30px;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 70%);
  border-radius: 50%;
}

.balance-card .balance-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #c7d2fe;
  font-weight: 600;
  margin-bottom: 6px;
}

.balance-card .balance-amount {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--white);
  margin-bottom: 12px;
}

.balance-card .balance-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(4px);
}

/* Stats Grid (2 Columns) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-box {
  background: var(--white);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.stat-box.stat-contrib {
  border-left: 4px solid var(--success);
}

.stat-box.stat-expense {
  border-left: 4px solid var(--expense);
}

.stat-box.stat-members {
  border-left: 4px solid var(--primary);
}

.stat-box.stat-pending {
  border-left: 4px solid var(--warning);
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--neutral-500);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--neutral-900);
}

.stat-subtext {
  font-size: 11px;
  color: var(--neutral-400);
  margin-top: 4px;
}

/* Section Header inside cards */
.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--neutral-800);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Group Breakdown List */
.group-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.group-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.group-item-header {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
}

.group-item-name {
  font-weight: 600;
  color: var(--neutral-700);
}

.group-item-amount {
  font-weight: 700;
  color: var(--neutral-900);
}

.progress-track {
  width: 100%;
  height: 6px;
  background-color: var(--neutral-100);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.progress-fill-contrib {
  background-color: var(--success);
}

.progress-fill-expense {
  background-color: var(--expense);
}

/* ==========================================================================
   Search & Filter Bar
   ========================================================================== */
.search-container {
  margin-bottom: 14px;
}

.search-form {
  display: flex;
  gap: 8px;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
}

.search-input-wrapper svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--neutral-400);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 44px;
  padding: 8px 12px 8px 38px;
  border-radius: var(--radius-full);
  border: 1px solid var(--neutral-200);
  background: var(--white);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.btn-search {
  height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-full);
  background: var(--neutral-800);
  color: var(--white);
  border: none;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

/* Filter Pills */
.filter-pills-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
  scrollbar-width: none; /* Firefox */
}

.filter-pills-scroll::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.filter-pill {
  white-space: nowrap;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  background: var(--white);
  border: 1px solid var(--neutral-200);
  color: var(--neutral-600);
  transition: all 0.15s ease;
}

.filter-pill.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

/* ==========================================================================
   List Items & Cards (Members, Contributions, Expenses)
   ========================================================================== */
.item-card {
  background: var(--white);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.1s ease, border-color 0.1s ease;
}

.item-card:active {
  transform: scale(0.99);
  background-color: var(--neutral-50);
}

.item-main {
  flex: 1;
  min-width: 0;
}

.item-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--neutral-900);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-subtitle {
  font-size: 12.5px;
  color: var(--neutral-500);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.item-amount-badge {
  text-align: right;
  flex-shrink: 0;
}

.amount-val {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.amount-val-contrib {
  color: var(--success-dark);
}

.amount-val-expense {
  color: var(--expense-dark);
}

.amount-val-zero {
  color: var(--neutral-400);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}

.badge-tag {
  background: var(--neutral-100);
  color: var(--neutral-600);
}

.badge-success {
  background: var(--success-light);
  color: var(--success-dark);
}

.badge-warning {
  background: var(--warning-light);
  color: #b45309;
}

.badge-expense {
  background: var(--expense-light);
  color: var(--expense-dark);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--neutral-400);
}

.empty-state-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--neutral-500);
}

/* ==========================================================================
   Forms & Controls
   ========================================================================== */
.form-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--neutral-200);
  padding: 20px 16px;
  box-shadow: var(--shadow-sm);
}

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

.form-label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--neutral-700);
  margin-bottom: 6px;
}

.form-label .required {
  color: var(--expense);
}

.form-control {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1.5px solid var(--neutral-200);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-family: inherit;
  color: var(--neutral-900);
  background-color: var(--white);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

textarea.form-control {
  min-height: 80px;
  resize: vertical;
}

/* Checkbox control */
.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  padding: 6px 0;
}

.form-check-input {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-check-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--neutral-700);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.25);
}

.btn-primary:active {
  background: var(--primary-dark);
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--neutral-100);
  color: var(--neutral-700);
  border: 1px solid var(--neutral-200);
}

.btn-secondary:active {
  background: var(--neutral-200);
}

.btn-danger {
  background: var(--expense);
  color: var(--white);
}

.btn-danger:active {
  background: var(--expense-dark);
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
}

/* ==========================================================================
   Sticky Bottom Navigation
   ========================================================================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-app-width);
  height: 64px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--neutral-200);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 50;
  padding: 0 8px;
  box-shadow: var(--shadow-nav);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--neutral-400);
  font-size: 11px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.2s ease;
  flex: 1;
  text-align: center;
}

.nav-item svg {
  width: 22px;
  height: 22px;
  margin-bottom: 3px;
  transition: transform 0.2s ease, stroke 0.2s ease;
}

.nav-item.active {
  color: var(--primary);
  font-weight: 700;
}

.nav-item.active svg {
  stroke: var(--primary);
  transform: translateY(-1px);
}

/* ==========================================================================
   Years & Settings Page
   ========================================================================== */
.year-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--neutral-200);
  margin-bottom: 10px;
  background: var(--white);
}

.year-item.is-active-year {
  border-color: var(--primary);
  background: var(--primary-light);
}

.year-label {
  font-size: 18px;
  font-weight: 700;
}

.btn-activate {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--neutral-200);
  background: var(--white);
  color: var(--neutral-700);
  cursor: pointer;
}

.btn-activate:hover {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

/* Backup Item */
.backup-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--neutral-100);
  font-size: 13px;
}

.backup-item:last-child {
  border-bottom: none;
}

