/* ==========================================================================
   TieTheKnot Budget™ — Design System & Stylesheet (Mobile-First CSS)
   ========================================================================== */

:root {
  /* Core Color Palette: Champagne Gold & Luxury Wedding */
  --primary: #C8A27A;
  --primary-hover: #B58E65;
  --primary-light: #F4ECE1;
  --primary-dark: #916B45;

  --accent-rose: #E8C5C8;
  --accent-rose-light: #FAF0F1;
  
  --sage-green: #6E8B76;
  --sage-light: #EBF2ED;

  --amber-warn: #D98A5B;
  --amber-light: #FDF3EC;

  --danger-red: #D9534F;
  --danger-light: #FDF0F0;

  /* Neutrals & Backgrounds */
  --bg-app: #FAF8F5;
  --bg-card: #FFFFFF;
  --bg-card-subtle: #FDFBF8;
  
  --text-main: #2C2523;
  --text-muted: #7A706A;
  --text-light: #A39993;

  --border-light: #EBE5DF;
  --border-focus: #C8A27A;

  /* Typography */
  --font-serif: 'Playfair Display', 'Cinzel', Georgia, serif;
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Shadows & Elevations */
  --shadow-sm: 0 2px 8px rgba(44, 37, 35, 0.04);
  --shadow-md: 0 8px 24px rgba(44, 37, 35, 0.06);
  --shadow-lg: 0 16px 36px rgba(44, 37, 35, 0.09);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* Layout */
  --max-width: 768px;
  --nav-height: 68px;
  --header-height: 64px;
}

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

.app-container {
  width: 100%;
  max-width: var(--max-width);
  min-height: 100vh;
  background-color: var(--bg-app);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.03);
}

/* ==========================================================================
   Header Area
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-height);
  background: rgba(250, 248, 245, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.brand-tagline {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-select {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  padding: 6px 10px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  outline: none;
}

.btn-primary-compact {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #FFFFFF;
  border: none;
  padding: 7px 14px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(200, 162, 122, 0.3);
  transition: all 0.2s ease;
}

.btn-primary-compact:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(200, 162, 122, 0.4);
}

.btn-primary-compact:active {
  transform: scale(0.98);
}

/* ==========================================================================
   Main Content & Tabs
   ========================================================================== */
.main-content {
  flex: 1;
  padding: 16px 16px calc(var(--nav-height) + 20px) 16px;
  overflow-y: auto;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.25s ease-in-out;
}

.tab-pane.active {
  display: block;
}

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

/* ==========================================================================
   Dashboard Components
   ========================================================================== */
.couple-card {
  background: linear-gradient(135deg, #FFFFFF 0%, var(--primary-light) 100%);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

.couple-names {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  color: var(--text-main);
  font-weight: 700;
}

.wedding-date {
  font-size: 0.85rem;
  color: var(--primary-dark);
  font-weight: 600;
  margin-top: 2px;
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  transition: transform 0.2s;
}

.btn-icon:hover {
  transform: scale(1.08);
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}

.metric-card.primary {
  grid-column: span 2;
  background: linear-gradient(180deg, #FFFFFF 0%, #FAF6F0 100%);
  border-color: rgba(200, 162, 122, 0.4);
}

.metric-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.metric-value-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.metric-val {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.metric-card.primary .metric-val {
  font-size: 1.85rem;
  color: var(--primary-dark);
  font-family: var(--font-serif);
}

.metric-card.highlight-paid .metric-val {
  color: var(--sage-green);
}

.metric-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.btn-text-edit {
  background: none;
  border: none;
  color: var(--primary-dark);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: var(--radius-full);
  margin-top: 8px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--sage-green));
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.status-pill {
  display: inline-block;
  align-self: flex-start;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  margin-top: 6px;
}

.status-pill.safe {
  background: var(--sage-light);
  color: var(--sage-green);
}

.status-pill.warning {
  background: var(--amber-light);
  color: var(--amber-warn);
}

.status-pill.danger {
  background: var(--danger-light);
  color: var(--danger-red);
}

/* Donut Chart Section */
.chart-section-card,
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.section-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.section-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.badge-count {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.chart-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

@media (min-width: 520px) {
  .chart-wrapper {
    flex-direction: row;
    align-items: center;
  }
}

.donut-container {
  width: 170px;
  height: 170px;
  flex-shrink: 0;
}

.donut-chart {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-bg {
  fill: none;
  stroke: #F4EFEA;
  stroke-width: 14;
}

.donut-slice {
  fill: none;
  stroke-width: 14;
  transition: stroke-dasharray 0.5s ease;
}

.donut-center-num {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  fill: var(--text-main);
  transform: rotate(90deg);
  transform-origin: 50px 50px;
}

.donut-center-label {
  font-family: var(--font-sans);
  font-size: 6px;
  font-weight: 600;
  fill: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transform: rotate(90deg);
  transform-origin: 50px 50px;
}

.chart-legend {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 4px;
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  padding: 4px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.legend-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
}

.legend-name {
  font-weight: 500;
  color: var(--text-main);
}

.legend-amount {
  font-weight: 600;
  color: var(--text-main);
}

/* Upcoming Payments List */
.upcoming-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upcoming-item {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.upcoming-info {
  display: flex;
  flex-direction: column;
}

.upcoming-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.upcoming-date {
  font-size: 0.75rem;
  color: var(--amber-warn);
  font-weight: 600;
}

.upcoming-cost {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
}

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

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

.empty-state-text {
  font-size: 0.85rem;
}

/* ==========================================================================
   Expenses Tab
   ========================================================================== */
.controls-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.search-input-wrap {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  color: var(--text-light);
}

.search-input-wrap input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  font-size: 0.85rem;
  outline: none;
}

.search-input-wrap input:focus {
  border-color: var(--border-focus);
}

.filter-actions {
  display: flex;
  gap: 8px;
}

.filter-select {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  font-size: 0.8rem;
  font-weight: 500;
  outline: none;
}

.category-group-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.category-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #FFFFFF;
  cursor: pointer;
  user-select: none;
}

.category-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cat-icon-badge {
  font-size: 1.2rem;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
}

.cat-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.cat-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.cat-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cat-total {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.cat-chevron {
  font-size: 0.8rem;
  color: var(--text-light);
  transition: transform 0.2s ease;
}

.category-group-card.open .cat-chevron {
  transform: rotate(180deg);
}

.category-items-list {
  display: none;
  padding: 0 16px 12px 16px;
  background: #FFFFFF;
  border-top: 1px solid var(--border-light);
}

.category-group-card.open .category-items-list {
  display: block;
}

.expense-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  cursor: pointer;
}

.expense-row:last-child {
  border-bottom: none;
}

.expense-row:hover {
  background: var(--bg-card-subtle);
}

.exp-main-info {
  display: flex;
  flex-direction: column;
}

.exp-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.exp-vendor {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.exp-badges-row {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.badge-tag {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  text-transform: capitalize;
}

.badge-tag.paid { background: var(--sage-light); color: var(--sage-green); }
.badge-tag.partial { background: var(--amber-light); color: var(--amber-warn); }
.badge-tag.pending { background: #F0EDE8; color: var(--text-muted); }

.exp-finance-info {
  text-align: right;
}

.exp-cost {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
}

.exp-paid {
  font-size: 0.75rem;
  color: var(--sage-green);
  font-weight: 500;
}

/* ==========================================================================
   Cost Split Tab
   ========================================================================== */
.contributors-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 14px;
}

@media (min-width: 520px) {
  .contributors-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.contrib-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.contrib-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.contrib-avatar {
  font-size: 1.2rem;
}

.contrib-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
}

.contrib-amount {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.contrib-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.contrib-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
}

.contrib-percent {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ==========================================================================
   Settings Tab
   ========================================================================== */
.settings-group {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.settings-group-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

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

.setting-text {
  display: flex;
  flex-direction: column;
  padding-right: 12px;
}

.setting-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.setting-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.setting-control {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-app);
  font-size: 0.8rem;
  font-weight: 600;
  outline: none;
  min-width: 140px;
}

.settings-info-box {
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--primary-dark);
  margin-bottom: 14px;
  line-height: 1.4;
}

.backup-buttons-row {
  display: flex;
  gap: 10px;
}

.btn-secondary {
  flex: 1;
  background: var(--bg-app);
  border: 1px solid var(--border-light);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: #F0ECE6;
}

.danger-zone {
  border-color: rgba(217, 83, 79, 0.3);
  background: #FFFAF9;
}

.text-danger {
  color: var(--danger-red);
}

.btn-danger {
  background: var(--danger-red);
  color: #FFFFFF;
  border: none;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
}

/* ==========================================================================
   Bottom Navigation
   ========================================================================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  height: var(--nav-height);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding: 0 10px;
}

.nav-item {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.nav-icon {
  font-size: 1.25rem;
  margin-bottom: 2px;
}

.nav-label {
  font-size: 0.68rem;
  font-weight: 600;
}

.nav-item.active {
  color: var(--primary-dark);
}

.nav-item.active .nav-icon {
  transform: scale(1.15);
}

/* ==========================================================================
   Modals & Dialogs
   ========================================================================== */
.app-dialog {
  border: none;
  border-radius: var(--radius-lg);
  background: transparent;
  padding: 0;
  max-width: 500px;
  width: 90%;
  margin: auto;
  box-shadow: var(--shadow-lg);
}

.app-dialog::backdrop {
  background: rgba(44, 37, 35, 0.45);
  backdrop-filter: blur(4px);
}

.dialog-content {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  padding: 24px;
  max-height: 90vh;
  overflow-y: auto;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.dialog-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1;
}

.dialog-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-main);
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-app);
  font-size: 0.85rem;
  font-family: var(--font-sans);
  color: var(--text-main);
  outline: none;
}

.form-input:focus,
.form-textarea:focus {
  border-color: var(--border-focus);
  background: #FFFFFF;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}

.right-buttons {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.btn-secondary-compact {
  background: var(--bg-app);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger-compact {
  background: var(--danger-light);
  border: 1px solid rgba(217, 83, 79, 0.3);
  color: var(--danger-red);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
