/* ===========================================
   Baby Feeding Tracker - Style
   =========================================== */

:root {
  --bg: #fff5f7;
  --bg-card: #ffffff;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --accent: #ec4899;
  --accent-light: #fce7f3;
  --accent-dark: #db2777;
  --accent-glow: rgba(236, 72, 153, 0.15);
  --success: #10b981;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --border: #fbd5e0;
  --border-light: #fef1f6;
  --shadow-sm: 0 1px 2px rgba(236,72,153,0.06);
  --shadow-md: 0 4px 16px rgba(236,72,153,0.12);
  --shadow-lg: 0 8px 30px rgba(236,72,153,0.16);
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'Rubik', -apple-system, BlinkMacSystemFont, sans-serif;
}

[hidden] { display: none !important; }

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  direction: rtl;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== Auth Screen ===== */
#auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, #fff5f7 0%, #fce7f3 40%, #fbcfe8 100%);
}

.auth-card {
  background: var(--bg-card);
  border-radius: 24px;
  padding: 48px 40px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(236,72,153,0.15);
  max-width: 360px;
  width: 100%;
  border: 1px solid var(--border-light);
}

/* ===== SVG Icons ===== */
.icon {
  display: inline-block;
  vertical-align: middle;
  fill: none;
  stroke: currentColor;
}

.icon-lg {
  width: 56px;
  height: 56px;
}

.icon-header {
  width: 24px;
  height: 24px;
  color: var(--accent-dark);
}

.icon-btn {
  width: 22px;
  height: 22px;
}

.icon-btn-sm {
  width: 18px;
  height: 18px;
}

.icon-group {
  width: 16px;
  height: 16px;
}

.icon-edit-hint {
  width: 14px;
  height: 14px;
}

.auth-icon {
  margin-bottom: 16px;
  color: var(--accent);
  filter: drop-shadow(0 4px 8px rgba(236,72,153,0.2));
}

.auth-card h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 20px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 32px;
}

.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
}

.google-btn:hover {
  background: #f9fafb;
  box-shadow: var(--shadow-sm);
}

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, #ffffff 0%, #fff5f7 100%);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.header-icon {
  font-size: 24px;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-dark);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-secondary);
}

.logout-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.logout-btn:hover {
  background: #f3f4f6;
}

/* ===== Timer Card ===== */
.timer-card {
  margin: 20px 16px;
  padding: 28px 24px;
  background: linear-gradient(135deg, #ec4899 0%, #f472b6 50%, #db2777 100%);
  border-radius: 20px;
  text-align: center;
  color: white;
  box-shadow: 0 8px 30px rgba(236,72,153,0.3);
  position: relative;
  overflow: hidden;
  transition: background 0.5s, box-shadow 0.5s;
}

.timer-card--warning {
  background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 50%, #d97706 100%);
  box-shadow: 0 8px 30px rgba(245,158,11,0.3);
}

.timer-card--danger {
  background: linear-gradient(135deg, #ef4444 0%, #f87171 50%, #dc2626 100%);
  box-shadow: 0 8px 30px rgba(239,68,68,0.3);
}

.timer-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -30%;
  width: 200px;
  height: 200px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}

.timer-card::after {
  content: '';
  position: absolute;
  bottom: -40%;
  left: -20%;
  width: 160px;
  height: 160px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
}

.timer-label {
  font-size: 14px;
  opacity: 0.9;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.timer-value {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.timer-detail {
  font-size: 14px;
  opacity: 0.9;
  margin-top: 8px;
  position: relative;
  z-index: 1;
}

/* ===== Action Buttons ===== */
.actions {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--accent-dark);
  box-shadow: 0 6px 20px rgba(236,72,153,0.3);
}

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

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  background: var(--accent-light);
  color: var(--accent-dark);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-ghost:hover {
  background: #f3f4f6;
}

.btn-danger {
  background: none;
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--danger);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover {
  background: var(--danger-light);
}

.btn-small {
  padding: 10px 24px;
  font-size: 15px;
}

/* ===== Time Picker ===== */
.time-picker {
  padding: 0 16px;
  margin-bottom: 20px;
}

.time-picker-inner {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.time-picker label {
  display: block;
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.time-input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 20px;
  text-align: center;
  color: var(--text-primary);
  direction: ltr;
  margin-bottom: 12px;
}

.time-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.notes-input {
  width: 100%;
  padding: 10px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.notes-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.notes-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

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

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

/* ===== Today Section ===== */
.today-section {
  padding: 0 16px 32px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.feedings-list {
  display: flex;
  flex-direction: column;
}

/* ===== Timeline ===== */
.timeline {
  display: flex;
  flex-direction: column;
}

.timeline-row {
  display: flex;
  align-items: stretch;
  gap: 12px;
  min-height: 64px;
}

.timeline-spine {
  width: 36px;
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* הקו האנכי */
.timeline-spine::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  background: var(--border);
}

/* בשורה הראשונה — הקו מתחיל מהמרכז ולא מלמעלה */
.timeline-spine--first::before {
  top: 50%;
}

/* בשורה האחרונה — הקו נגמר במרכז ולא בתחתית */
.timeline-spine--last::before {
  bottom: 50%;
}

.timeline-dot {
  position: relative;
  z-index: 1;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--bg), 0 2px 6px rgba(0,0,0,0.08);
}

/* צבעי נקודות לפי שעת היום */
.timeline-dot--morning { background: #f59e0b; }
.timeline-dot--noon    { background: #f97316; }
.timeline-dot--evening { background: #ec4899; }
.timeline-dot--night   { background: #6366f1; }

/* פער בין האכלות */
.timeline-gap {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 32px;
}

.timeline-gap-spine {
  width: 36px;
  flex-shrink: 0;
  position: relative;
}

.timeline-gap-spine::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  background: var(--border);
}

.timeline-gap-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--accent-light);
  border-radius: 12px;
  padding: 3px 12px;
}

/* פער ארוך (יותר מ-4 שעות) — צבע אזהרה עדין */
.timeline-gap--long .timeline-gap-label {
  background: #fef3c7;
  color: #b45309;
}

/* ===== Time Groups (legacy — לא בשימוש בטיימליין החדש) ===== */
.time-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.time-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
  margin-bottom: 2px;
}

.time-group-icon {
  display: flex;
  align-items: center;
}

.time-group-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.time-group-count {
  background: var(--accent-light);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
}

/* פס צבעוני בצד כל שורה */
.feeding-item {
  border-right: 3px solid transparent;
}

.feeding-item--morning { border-right-color: #f59e0b; }
.feeding-item--noon { border-right-color: #f97316; }
.feeding-item--evening { border-right-color: #ec4899; }
.feeding-item--night { border-right-color: #6366f1; }

/* צבע רקע עדין לכותרות */
.time-group--morning .time-group-header .time-group-label { color: #b45309; }
.time-group--noon .time-group-header .time-group-label { color: #c2410c; }
.time-group--evening .time-group-header .time-group-label { color: #be185d; }
.time-group--night .time-group-header .time-group-label { color: #4338ca; }

.time-group--morning .time-group-icon { color: #b45309; }
.time-group--noon .time-group-icon { color: #c2410c; }
.time-group--evening .time-group-icon { color: #be185d; }
.time-group--night .time-group-icon { color: #4338ca; }

.time-group--morning .time-group-count { background: #fef3c7; color: #b45309; }
.time-group--noon .time-group-count { background: #ffedd5; color: #c2410c; }
.time-group--evening .time-group-count { background: #fce7f3; color: #be185d; }
.time-group--night .time-group-count { background: #e0e7ff; color: #4338ca; }

.feeding-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--border-light);
}

.feeding-item:hover {
  border-color: var(--accent-light);
  box-shadow: var(--shadow-md);
  background: linear-gradient(135deg, #ffffff 0%, #fff5f7 100%);
}

.feeding-item:active {
  transform: scale(0.99);
}

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

.feeding-time {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  direction: ltr;
}

.feeding-user {
  font-size: 14px;
  color: var(--text-secondary);
}

.feeding-note {
  font-size: 13px;
  color: var(--accent);
}

.feeding-edit-hint {
  color: var(--border);
  display: flex;
  align-items: center;
}

.empty-state {
  text-align: center;
  padding: 32px;
  color: var(--text-secondary);
  font-size: 15px;
}

/* ===== Date Navigation ===== */
.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.date-nav-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-secondary);
  padding: 0;
}

.date-nav-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.date-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.date-nav-btn:disabled:hover {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-secondary);
}

.icon-nav {
  width: 18px;
  height: 18px;
}

.date-display {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 180px;
  text-align: center;
}

/* ===== Daily Summary ===== */
.daily-summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  margin-top: 16px;
}

.summary-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.summary-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.summary-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
}

.summary-divider {
  width: 1px;
  height: 36px;
  background: var(--border);
  margin: 0 16px;
}

/* ===== Swipe to Delete ===== */
.swipe-container {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
  flex: 1;
  min-width: 0;
  align-self: center;
}

.swipe-delete-bg {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 80px;
  background: var(--danger);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  gap: 4px;
}

.swipe-delete-bg .icon {
  width: 16px;
  height: 16px;
  stroke: white;
}

.swipe-container .feeding-item {
  position: relative;
  z-index: 1;
  transition: transform 0.2s ease;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 28px 24px;
  max-width: 340px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.modal-card h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  text-align: center;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.modal-actions .btn-danger {
  margin-right: auto;
}

/* ===== Responsive ===== */
@media (min-width: 480px) {
  #app-view {
    max-width: 480px;
    margin: 0 auto;
  }
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  z-index: 200;
  animation: toast-in 0.3s ease, toast-out 0.3s ease 2.2s;
  box-shadow: 0 6px 20px rgba(236,72,153,0.3);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to { opacity: 0; transform: translateX(-50%) translateY(20px); }
}

/* ===== Dark Mode (21:00 - 06:00) ===== */
body.dark-mode {
  --bg: #1a1a2e;
  --bg-card: #16213e;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --accent: #f472b6;
  --accent-light: #2d1f3d;
  --accent-dark: #f9a8d4;
  --accent-glow: rgba(244, 114, 182, 0.2);
  --border: #2d3748;
  --border-light: #1e293b;
  --danger: #f87171;
  --danger-light: #3b1a1a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
}

body.dark-mode #auth-view {
  background: linear-gradient(160deg, #1a1a2e 0%, #16213e 40%, #0f172a 100%);
}

body.dark-mode .header {
  background: linear-gradient(135deg, #16213e 0%, #1a1a2e 100%);
  border-bottom-color: var(--border);
}

body.dark-mode .google-btn {
  background: #1e293b;
  border-color: var(--border);
  color: var(--text-primary);
}

body.dark-mode .google-btn:hover {
  background: #2d3748;
}

body.dark-mode .logout-btn:hover {
  background: #2d3748;
}

body.dark-mode .btn-ghost:hover {
  background: #2d3748;
}

body.dark-mode .timer-card {
  background: linear-gradient(135deg, #be185d 0%, #ec4899 50%, #a21caf 100%);
}

body.dark-mode .timer-card--warning {
  background: linear-gradient(135deg, #b45309 0%, #f59e0b 50%, #92400e 100%);
}

body.dark-mode .timer-card--danger {
  background: linear-gradient(135deg, #b91c1c 0%, #ef4444 50%, #991b1b 100%);
}

body.dark-mode .feeding-item:hover {
  background: linear-gradient(135deg, #16213e 0%, #1e293b 100%);
}

body.dark-mode .toast {
  background: linear-gradient(135deg, #be185d 0%, #a21caf 100%);
}

body.dark-mode .time-input {
  background: #1e293b;
  color: var(--text-primary);
}

body.dark-mode .notes-input {
  background: #1e293b;
  color: var(--text-primary);
}

body.dark-mode .modal-overlay {
  background: rgba(0,0,0,0.6);
}

body.dark-mode .time-group--morning .time-group-header .time-group-label { color: #fbbf24; }
body.dark-mode .time-group--noon .time-group-header .time-group-label { color: #fb923c; }
body.dark-mode .time-group--evening .time-group-header .time-group-label { color: #f9a8d4; }
body.dark-mode .time-group--night .time-group-header .time-group-label { color: #a5b4fc; }

body.dark-mode .time-group--morning .time-group-icon { color: #fbbf24; }
body.dark-mode .time-group--noon .time-group-icon { color: #fb923c; }
body.dark-mode .time-group--evening .time-group-icon { color: #f9a8d4; }
body.dark-mode .time-group--night .time-group-icon { color: #a5b4fc; }

body.dark-mode .time-group--morning .time-group-count { background: #422006; color: #fbbf24; }
body.dark-mode .time-group--noon .time-group-count { background: #431407; color: #fb923c; }
body.dark-mode .time-group--evening .time-group-count { background: #2d1f3d; color: #f9a8d4; }
body.dark-mode .time-group--night .time-group-count { background: #1e1b4b; color: #a5b4fc; }

body.dark-mode .summary-value { color: var(--accent); }

/* Timeline — dark mode */
body.dark-mode .timeline-spine::before,
body.dark-mode .timeline-gap-spine::before {
  background: var(--border);
}

body.dark-mode .timeline-dot {
  box-shadow: 0 0 0 4px var(--bg), 0 2px 6px rgba(0,0,0,0.4);
}

body.dark-mode .timeline-dot--morning { background: #fbbf24; }
body.dark-mode .timeline-dot--noon    { background: #fb923c; }
body.dark-mode .timeline-dot--evening { background: #f472b6; }
body.dark-mode .timeline-dot--night   { background: #818cf8; }

body.dark-mode .timeline-gap-label {
  background: var(--accent-light);
  color: var(--accent-dark);
}

body.dark-mode .timeline-gap--long .timeline-gap-label {
  background: #422006;
  color: #fbbf24;
}
