/* ═══════════════════════════════════════════
   Zayıflama Takip - Mobile-First CSS
   ═══════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #0891b2;
  --info-light: #cffafe;

  --bg: #f8fafc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-focus: var(--primary);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);

  --nav-height: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-height: 56px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  overflow-x: hidden;
}

/* ── Header ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--primary);
  color: #fff;
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  box-shadow: var(--shadow-md);
}

.app-header h1 {
  font-size: 1.125rem;
  font-weight: 600;
  flex: 1;
}

/* ── Bottom Navigation ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.625rem;
  font-weight: 500;
  min-height: 44px;
  min-width: 44px;
  cursor: pointer;
  transition: color 0.15s;
  -webkit-user-select: none;
  user-select: none;
}

.nav-item svg {
  width: 24px;
  height: 24px;
  stroke-width: 1.5;
}

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

.nav-item:active {
  opacity: 0.7;
}

/* ── Page Content ── */
.page {
  display: none;
  padding: 16px;
  max-width: 640px;
  margin: 0 auto;
  animation: fadeIn 0.2s ease;
}

.page.active {
  display: block;
}

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

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 12px;
}

/* ── Metric Cards ── */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  text-align: center;
}

.metric-card.wide {
  grid-column: 1 / -1;
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

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

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

/* ── Alerts ── */
.alert {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
  font-size: 0.875rem;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.alert-icon {
  flex-shrink: 0;
  font-size: 1.1rem;
  line-height: 1.3;
}

.alert-warning {
  background: var(--warning-light);
  color: #92400e;
  border-left: 3px solid var(--warning);
}

.alert-info {
  background: var(--info-light);
  color: #155e75;
  border-left: 3px solid var(--info);
}

.alert-success {
  background: var(--success-light);
  color: #166534;
  border-left: 3px solid var(--success);
}

.alert-danger {
  background: var(--danger-light);
  color: #991b1b;
  border-left: 3px solid var(--danger);
}

/* ── Forms ── */
.form-group {
  margin-bottom: 16px;
}

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

.form-input,
.form-select {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px; /* prevent iOS zoom */
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 36px;
}

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

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

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  cursor: pointer;
}

.form-check input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ── Stepper (for alcohol/coffee) ── */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-card);
}

.stepper-btn {
  width: 48px;
  height: 44px;
  border: none;
  background: var(--bg);
  color: var(--primary);
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  user-select: none;
  -webkit-user-select: none;
}

.stepper-btn:active {
  background: var(--primary-light);
}

.stepper-value {
  flex: 1;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  min-width: 40px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: 44px;
  transition: opacity 0.15s, transform 0.1s;
  user-select: none;
  -webkit-user-select: none;
}

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

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

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

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

.btn-success {
  background: var(--success);
  color: #fff;
  width: 100%;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.8125rem;
  min-height: 36px;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.btn-row .btn {
  flex: 1;
}

/* ── Toggle Group (Yes/No) ── */
.toggle-group {
  display: flex;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.toggle-option {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: none;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  user-select: none;
  -webkit-user-select: none;
}

.toggle-option.active {
  background: var(--primary);
  color: #fff;
}

.toggle-option:not(:last-child) {
  border-right: 1px solid var(--border);
}

/* ── Hunger Rating ── */
.hunger-group {
  display: flex;
  gap: 8px;
}

.hunger-btn {
  flex: 1;
  min-height: 44px;
  min-width: 44px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.hunger-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ── Measurement Cards (mobile) ── */
.measurement-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.measurement-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

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

.measurement-date {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
}

.measurement-weight {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary);
}

.measurement-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.measurement-detail-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Meal Plan ── */
.day-type-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.day-type-btn {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  min-height: 44px;
  transition: all 0.15s;
}

.day-type-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.meal-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
  border-left: 4px solid var(--primary);
}

.meal-time {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 6px;
}

.meal-text {
  font-size: 0.9375rem;
  color: var(--text);
  line-height: 1.5;
}

/* ── Chart Container ── */
.chart-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  margin-bottom: 8px;
}

/* ── Tables (desktop only) ── */
.table-container {
  display: none;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.data-table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-secondary);
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.data-table tr:hover td {
  background: var(--bg);
}

/* ── Toast Notifications ── */
.toast-container {
  position: fixed;
  top: calc(var(--header-height) + 12px);
  left: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 640px;
  margin: 0 auto;
}

.toast {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 12px 16px;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  animation: toastIn 0.3s ease;
  border-left: 4px solid var(--primary);
}

.toast-success { border-left-color: var(--success); }
.toast-warning { border-left-color: var(--warning); }
.toast-error   { border-left-color: var(--danger); }

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

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

/* ── Loading Spinner ── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
  color: var(--text-muted);
  gap: 10px;
}

/* ── Section Title ── */
.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 20px 0 12px;
}

/* ── Divider ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* ── Settings / Export specific ── */
.export-btn-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Weekly Summary Cards ── */
.weekly-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 10px;
}

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

.weekly-card-week {
  font-weight: 600;
  font-size: 0.875rem;
}

.weekly-card-delta {
  font-size: 0.875rem;
  font-weight: 600;
}

.delta-negative { color: var(--success); }
.delta-positive { color: var(--danger); }

.weekly-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════
   Desktop Breakpoint (≥768px)
   ═══════════════════════════════════════════ */
@media (min-width: 768px) {
  body {
    padding-bottom: 16px;
  }

  .bottom-nav {
    position: static;
    max-width: 640px;
    margin: 0 auto;
    height: auto;
    border-top: none;
    border-bottom: 1px solid var(--border);
    box-shadow: none;
    padding-bottom: 0;
  }

  .nav-item {
    flex-direction: row;
    gap: 6px;
    font-size: 0.8125rem;
    padding: 12px 8px;
  }

  .page {
    padding: 24px;
  }

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

  /* Show table, hide cards on desktop */
  .table-container {
    display: block;
  }

  .measurement-list.mobile-only {
    display: none;
  }

  .form-row {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .chart-container {
    aspect-ratio: 16 / 9;
  }

  .export-btn-group {
    flex-direction: row;
  }
}
