/* ============================================================================
   Sakeena - Mobile-First Calm Medical UI (RTL Arabic)
   ============================================================================ */
:root {
  --bg: #f4f8f7;
  --surface: #ffffff;
  --surface-soft: #eef6f4;
  --text: #0f172a;
  --text-muted: #526370;
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-soft: #ccfbf1;
  --safe: #059669;
  --safe-bg: #ecfdf5;
  --caution: #d97706;
  --caution-bg: #fffbeb;
  --avoid: #dc2626;
  --avoid-bg: #fef2f2;
  --border: #e2ecea;
  --shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
  --radius: 18px;
  --nav-h: 72px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Cairo", "Tajawal", system-ui, -apple-system, sans-serif;
  direction: rtl;
  line-height: 1.55;
  overflow-x: hidden;
}

.app-shell {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: calc(var(--nav-h) + 22px);
  position: relative;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(244, 248, 247, 0.92);
  backdrop-filter: blur(12px);
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #14b8a6);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.25);
}

.brand-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

.brand-sub {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-muted);
}

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

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 7px 11px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

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

/* Main Content */
.tab-panel {
  display: none;
  padding: 14px 14px 10px;
  animation: fadeIn 0.22s ease;
}

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

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

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

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

.card-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 7px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}

.badge-safe { background: var(--safe-bg); color: var(--safe); }
.badge-caution { background: var(--caution-bg); color: var(--caution); }
.badge-avoid { background: var(--avoid-bg); color: var(--avoid); }
.badge-primary { background: var(--primary-soft); color: var(--primary-dark); }

/* Top Quick Analyzer Card */
.analyzer-card {
  background: linear-gradient(180deg, #ffffff 0%, #f0fdfa 100%);
  border: 1.5px solid #99f6e4;
}

.analyzer-input-wrap {
  position: relative;
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.text-input {
  width: 100%;
  border: 1.5px solid var(--border);
  background: #fff;
  border-radius: 13px;
  padding: 11px 13px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.text-input:focus {
  border-color: var(--primary);
}

.btn {
  border: none;
  border-radius: 13px;
  padding: 10px 15px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.12s ease, opacity 0.15s;
}

.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-soft { background: var(--surface-soft); color: var(--primary-dark); border: 1px solid #cce7e2; }
.btn-warn { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.btn-danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 10px; }
.btn-block { width: 100%; }

.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 13px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
  z-index: 40;
  overflow: hidden;
  display: none;
}

.autocomplete-list.open { display: block; }

.autocomplete-item {
  padding: 9px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
}

.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--surface-soft); }

.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

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

/* Analyzer Result Box */
.analysis-result {
  margin-top: 12px;
  border-radius: 14px;
  padding: 12px;
  border: 1.5px solid var(--border);
  background: #fff;
}

.analysis-result.status-safe { border-color: #a7f3d0; background: #f0fdf4; }
.analysis-result.status-caution { border-color: #fde68a; background: #fffbeb; }
.analysis-result.status-avoid { border-color: #fecaca; background: #fef2f2; }

.matched-food-row {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 8px 10px;
  margin-top: 8px;
  font-size: 12.5px;
}

.rescue-box {
  margin-top: 10px;
  background: #fff;
  border: 1px dashed #0d9488;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12.5px;
}

.rescue-box ul {
  margin: 6px 0 0;
  padding-right: 18px;
}

.rescue-box li { margin-bottom: 4px; }

.adjust-box {
  margin-top: 10px;
  background: linear-gradient(135deg, #ecfeff, #f0fdfa);
  border: 1.5px solid #5eead4;
  border-radius: 13px;
  padding: 11px 12px;
  font-size: 12.5px;
}

/* Fasting Gap & Stats Strip */
.stats-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 11px 12px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 11.5px;
  color: var(--text-muted);
  display: block;
}

.stat-val {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin-top: 2px;
}

/* Days Scroller */
.days-bar {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 10px;
  scrollbar-width: none;
}

.days-bar::-webkit-scrollbar { display: none; }

.day-pill {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 12px;
  padding: 7px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.day-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.25);
}

/* Meal Station Cards */
.meal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 13px;
  margin-bottom: 11px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s, background 0.2s;
}

.meal-card.done {
  background: #f0fdf4;
  border-color: #86efac;
}

.meal-card.adjusted {
  border-color: #2dd4bf;
  box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.2);
}

.meal-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.meal-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.meal-time {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--primary-dark);
  background: var(--primary-soft);
  padding: 2px 8px;
  border-radius: 8px;
}

.meal-slot-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.meal-title {
  margin: 4px 0;
  font-size: 14.5px;
  font-weight: 800;
  color: var(--text);
}

.meal-desc {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.meal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.alt-drawer {
  margin-top: 9px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-soft);
  font-size: 12px;
  color: var(--primary-dark);
  display: none;
}

.alt-drawer.open { display: block; }

.check-circle {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  background: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 15px;
  color: transparent;
}

.meal-card.done .check-circle {
  background: var(--safe);
  border-color: var(--safe);
  color: #fff;
}

/* Colon Simulator */
.sim-stage {
  background: radial-gradient(circle at 50% 45%, #f0fdfa 0%, #e6f4f1 100%);
  border: 1px solid #cce7e2;
  border-radius: 18px;
  padding: 12px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.colon-svg {
  width: 100%;
  max-width: 310px;
  height: auto;
  display: block;
  margin: 0 auto;
}

.colon-tube {
  fill: none;
  stroke: #e07a6d;
  stroke-width: 28;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.35s ease;
}

.colon-inner {
  fill: none;
  stroke: #f5b7ae;
  stroke-width: 16;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 8 10;
}

.mode-calm .colon-tube { stroke: #14b8a6; animation: calmWave 3.5s ease-in-out infinite; }
.mode-calm .colon-inner { stroke: #99f6e4; animation: flowSlow 5s linear infinite; }

.mode-gap .colon-tube { stroke: #f59e0b; animation: spasmPulse 1.3s ease-in-out infinite; }
.mode-gap .colon-inner { stroke: #fde68a; animation: flowFast 1.6s linear infinite; }

.mode-trigger .colon-tube { stroke: #ef4444; animation: strongSpasm 0.75s ease-in-out infinite; }
.mode-trigger .colon-inner { stroke: #fecaca; animation: flowFast 1s linear infinite; }

.mode-caffeine .colon-tube { stroke: #f97316; animation: spasmPulse 0.95s ease-in-out infinite; }
.mode-caffeine .colon-inner { stroke: #fed7aa; animation: flowFast 1.2s linear infinite; }

.gas-bubble {
  fill: #fff;
  opacity: 0.85;
  transform-box: fill-box;
  transform-origin: center;
}

.mode-calm .gas-bubble { opacity: 0.25; animation: bubbleGentle 4s ease-in-out infinite; }
.mode-gap .gas-bubble { fill: #fef3c7; animation: bubbleBounce 1.4s ease-in-out infinite; }
.mode-trigger .gas-bubble { fill: #fee2e2; animation: bubblePop 0.85s ease-in-out infinite; }
.mode-caffeine .gas-bubble { fill: #ffedd5; animation: bubbleBounce 1s ease-in-out infinite; }

.sound-wave {
  fill: none;
  stroke: #dc2626;
  stroke-width: 2.5;
  opacity: 0;
}

.mode-gap .sound-wave,
.mode-trigger .sound-wave,
.mode-caffeine .sound-wave {
  animation: soundRipple 1.4s ease-out infinite;
}

.mode-calm .sound-wave { opacity: 0; animation: none; }

@keyframes calmWave {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.015); }
}

@keyframes spasmPulse {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(0.96, 1.03); }
  70% { transform: scale(1.03, 0.97); }
}

@keyframes strongSpasm {
  0%, 100% { transform: translateX(0) scale(1); }
  25% { transform: translateX(-2px) scale(0.95, 1.04); }
  50% { transform: translateX(2px) scale(1.04, 0.96); }
  75% { transform: translateX(-1px) scale(0.97, 1.02); }
}

@keyframes flowSlow { to { stroke-dashoffset: -36; } }
@keyframes flowFast { to { stroke-dashoffset: -72; } }

@keyframes bubbleGentle {
  0%, 100% { transform: translateY(0) scale(0.9); }
  50% { transform: translateY(-4px) scale(1.05); }
}

@keyframes bubbleBounce {
  0%, 100% { transform: translate(0, 0) scale(0.85); }
  50% { transform: translate(4px, -7px) scale(1.25); }
}

@keyframes bubblePop {
  0%, 100% { transform: scale(0.8); opacity: 0.7; }
  50% { transform: scale(1.45); opacity: 1; }
}

@keyframes soundRipple {
  0% { opacity: 0.9; transform: scale(0.85); }
  100% { opacity: 0; transform: scale(1.35); }
}

.hotspot-dot {
  cursor: pointer;
  fill: #0f172a;
  stroke: #fff;
  stroke-width: 2.5;
}

/* Breathing Coach */
.breath-circle {
  width: 112px;
  height: 112px;
  margin: 12px auto;
  border-radius: 50%;
  background: radial-gradient(circle, #5eead4, #0d9488);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  transition: transform 0.9s ease;
  box-shadow: 0 8px 24px rgba(13, 148, 136, 0.3);
}

/* Water Tracker */
.water-widget {
  display: flex;
  align-items: center;
  gap: 16px;
}

.bottle {
  width: 64px;
  height: 118px;
  border: 3px solid var(--primary);
  border-radius: 14px 14px 18px 18px;
  position: relative;
  overflow: hidden;
  background: #f0fdfa;
  flex: 0 0 64px;
}

.bottle-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, #38bdf8, #0284c7);
  transition: height 0.4s ease;
}

/* Guide Food List */
.food-grid {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.food-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 12px;
  background: #fff;
}

.food-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.food-item-name {
  font-weight: 800;
  font-size: 14px;
}

.food-item-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Reminder Row */
.reminder-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

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

.time-input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  height: var(--nav-h);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  z-index: 40;
  padding: 6px 4px;
}

.nav-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  border-radius: 12px;
}

.nav-btn span.nav-ico { font-size: 19px; line-height: 1; }

.nav-btn.active {
  color: var(--primary);
  background: var(--surface-soft);
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 60;
  max-width: 90%;
  text-align: center;
}

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

/* Form helpers */
.form-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.select-input {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 9px 10px;
  font-family: inherit;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  font-weight: 700;
}

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

.free-log-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 11px;
  background: var(--surface-soft);
  margin-top: 6px;
  font-size: 12.5px;
}
