:root {
  --bg: #000000;
  --surface: #111111;
  --surface-hover: #1f1f1f;
  --border: rgba(255,255,255,0.1);
  --border-focus: rgba(255,255,255,0.3);
  --text: #ededed;
  --text-muted: #888888;
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.1);
  
  --color-matin: #FBBF24;
  --color-repas: #10B981;
  --color-soir: #3B82F6;

  --spring: cubic-bezier(0.175, 0.885, 0.32, 1.15);
  --smooth: cubic-bezier(0.25, 1, 0.5, 1);
  --shadow-float: 0 20px 40px rgba(0,0,0,0.5), 0 1px 3px rgba(0,0,0,0.8) inset;
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center;
  padding-bottom: 120px;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Header */
.app-header {
  width: 100%; max-width: 1000px;
  padding: 32px 24px;
}
.logo-area { font-weight: 500; font-size: 1.1rem; color: var(--text-muted); }
.logo-area span { color: var(--text); }

/* Main */
.app-main { width: 100%; max-width: 900px; padding: 0 24px; display: flex; flex-direction: column; gap: 48px; }

/* Sections */
.section-title { font-size: 1.2rem; font-weight: 500; margin-bottom: 24px; color: var(--text); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 24px; padding: 32px;
}

/* Inputs & Setup */
.input-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px; margin-bottom: 32px; }
.input-group { display: flex; flex-direction: column; gap: 8px; }
.input-group label { font-size: 0.85rem; font-weight: 500; color: var(--text-muted); }

input[type="number"], input[type="text"], select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 12px 16px; border-radius: 12px; font-size: 1rem;
  transition: all 0.2s var(--smooth);
}
input[type="number"]:focus, input[type="text"]:focus, select:focus {
  outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 2px rgba(255,255,255,0.1);
}

/* Small Segmented Control */
.segmented-control {
  display: flex; background: var(--bg); padding: 4px; border-radius: 12px; border: 1px solid var(--border);
}
.segmented-control .segment {
  flex: 1; text-align: center; padding: 8px 12px; cursor: pointer;
  font-size: 0.9rem; font-weight: 500; color: var(--text-muted);
  border-radius: 8px; transition: all 0.2s;
}
.segmented-control .segment.active { background: var(--surface-hover); color: var(--text); }

/* Children List Setup */
.child-setup-row {
  display: flex; gap: 16px; align-items: center; margin-bottom: 16px;
  background: var(--bg); padding: 16px; border-radius: 16px; border: 1px solid var(--border);
}

/* Big Segmented Control (Mode Choice) */
.big-segmented-control {
  display: flex; background: var(--surface); padding: 6px;
  border-radius: 24px; border: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.big-segmented-control .segment {
  flex: 1; padding: 24px; text-align: center; cursor: pointer;
  position: relative; z-index: 1; transition: color 0.3s;
}
.big-segmented-control .seg-title { font-size: 1.1rem; font-weight: 500; color: var(--text-muted); margin-bottom: 4px; transition: color 0.3s; }
.big-segmented-control .seg-desc { font-size: 0.85rem; color: rgba(255,255,255,0.3); transition: color 0.3s; }
.big-segmented-control .segment.active .seg-title { color: #000; }
.big-segmented-control .segment.active .seg-desc { color: rgba(0,0,0,0.6); }

.seg-indicator {
  position: absolute; top: 6px; bottom: 6px; left: 6px;
  background: var(--text); border-radius: 18px;
  transition: transform 0.4s var(--spring), width 0.4s var(--spring);
  z-index: 0;
}

/* Children Switcher (Tabs) */
.children-switcher {
  display: flex; background: var(--surface); padding: 4px;
  border-radius: 99px; width: fit-content; border: 1px solid var(--border);
  position: relative; margin: 0 auto 32px auto;
}
.child-tab {
  padding: 8px 24px; border-radius: 99px; cursor: pointer;
  font-size: 0.95rem; font-weight: 500; color: var(--text-muted);
  transition: color 0.3s; position: relative; z-index: 1;
}
.child-tab:hover { color: var(--text); }
.child-tab.active { color: #000; }
.tab-highlight {
  position: absolute; top: 4px; bottom: 4px; left: 4px;
  background: var(--text); border-radius: 99px;
  transition: transform 0.4s var(--spring), width 0.4s var(--spring);
  z-index: 0;
}

/* View Containers */
.view-container { display: none; opacity: 0; transition: opacity 0.3s; }
.view-container.active { display: block; opacity: 1; }

/* Flexible Calendar (V2 Style) */
.calendar-container { display: flex; flex-direction: column; gap: 24px; }
.month-header { display: flex; justify-content: space-between; align-items: center; }
.month-title { font-size: 1.5rem; font-weight: 500; letter-spacing: -0.03em; }
.month-nav { display: flex; gap: 8px; }
.nav-arrow {
  width: 32px; height: 32px; border-radius: 8px; background: var(--surface);
  border: 1px solid var(--border); color: var(--text);
  display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s;
}
.nav-arrow:hover { background: var(--surface-hover); transform: scale(1.05); }
.nav-arrow:active { transform: scale(0.95); }

.grid-header { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 12px; }
.day-label { text-align: center; font-size: 0.75rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.grid-body { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.cell {
  aspect-ratio: 1; border-radius: 16px; background: var(--surface);
  border: 1px solid transparent; cursor: pointer; position: relative;
  display: flex; flex-direction: column; justify-content: space-between; padding: 12px;
  transition: all 0.3s var(--smooth); user-select: none;
}
.cell:hover:not(.empty) { background: var(--surface-hover); transform: translateY(-2px); }
.cell:active:not(.empty) { transform: scale(0.96); transition-duration: 0.1s; }
.cell.selected { background: rgba(255,255,255,0.05); box-shadow: 0 0 0 1px var(--text) inset; }
.cell-date { font-size: 1rem; font-weight: 500; color: var(--text-muted); transition: color 0.3s; }
.cell.selected .cell-date { color: var(--text); }
.cell.empty { background: transparent; cursor: default; }

.cell-data { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.data-pill { height: 6px; border-radius: 3px; width: 0; opacity: 0; transition: all 0.4s var(--spring); }
.cell.has-matin .data-pill.matin { width: 100%; opacity: 1; background: var(--color-matin); }
.cell.has-repas .data-pill.repas { width: 100%; opacity: 1; background: var(--color-repas); }
.cell.has-soir .data-pill.soir { width: 100%; opacity: 1; background: var(--color-soir); }

/* RED QUOTA ERROR STYLES */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.cell.error-quota { animation: shake 0.4s; box-shadow: 0 0 0 1px var(--error) inset; background: var(--error-bg); }
.child-tab.has-error::after {
  content: ''; position: absolute; top: 4px; right: 8px; width: 8px; height: 8px;
  background: var(--error); border-radius: 50%; box-shadow: 0 0 4px var(--error);
}

/* Action Bar (Global Price + Flex Actions) */
.action-bar-wrapper {
  position: fixed; bottom: 32px; left: 0; right: 0; display: flex; justify-content: center;
  pointer-events: none; z-index: 100;
}
.action-bar {
  background: rgba(20, 20, 20, 0.85); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border); padding: 8px 24px; border-radius: 30px;
  display: flex; align-items: center; gap: 24px; box-shadow: var(--shadow-float);
  pointer-events: auto;
}

.price-container { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; }
.price-amount { font-size: 1.4rem; font-weight: 600; color: var(--text); }
.price-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.flex-actions {
  display: flex; align-items: center; gap: 16px; border-left: 1px solid var(--border); padding-left: 24px;
  opacity: 0; transform: translateX(20px); transition: all 0.4s var(--spring); width: 0; overflow: hidden;
}
.flex-actions.visible { opacity: 1; transform: translateX(0); width: auto; overflow: visible; }

.selection-count { font-size: 0.85rem; font-weight: 500; color: var(--text-muted); white-space: nowrap; }
.action-group { display: flex; gap: 6px; }
.action-btn {
  background: transparent; color: var(--text); border: 1px solid transparent;
  padding: 8px 16px; border-radius: 12px; font-size: 0.85rem; font-weight: 500;
  cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 8px; position: relative;
}
.action-btn:hover { background: rgba(255,255,255,0.08); }
.action-btn:active { transform: scale(0.92); }

.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-matin { background: var(--color-matin); }
.dot-repas { background: var(--color-repas); }
.dot-soir { background: var(--color-soir); }

.action-close {
  background: rgba(255,255,255,0.05); width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: none; color: var(--text-muted); cursor: pointer; transition: all 0.2s;
}
.action-close:hover { background: rgba(255,255,255,0.1); color: var(--text); }

/* Popovers */
.slot-popover {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%) translateY(10px) scale(0.95);
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 8px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow-float);
  opacity: 0; pointer-events: none; transition: all 0.3s var(--spring); margin-bottom: 12px;
}
.action-btn.active-popover .slot-popover { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0) scale(1); }
.popover-item {
  background: transparent; border: none; color: var(--text); padding: 10px 16px; border-radius: 8px; text-align: left;
  font-size: 0.85rem; cursor: pointer; transition: background 0.2s; white-space: nowrap;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.popover-item:hover { background: rgba(255,255,255,0.05); }
.popover-item .check-icon { opacity: 0; transition: opacity 0.2s; }
.popover-item.checked .check-icon { opacity: 1; color: var(--text); }

/* Toasts */
.toast-container {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 1000; pointer-events: none;
}
.toast {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 12px 24px; border-radius: 99px; font-size: 0.9rem; font-weight: 500;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  animation: toastIn 0.4s var(--spring) forwards, toastOut 0.4s var(--spring) 3s forwards;
}
.toast.error { border-color: var(--error); color: #fff; background: var(--error); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-20px) scale(0.9); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(-20px) scale(0.9); } }



/* WIZARD STEPPER */
.stepper-nav {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin-bottom: 48px; width: 100%;
}
.step-btn {
  display: flex; align-items: center; gap: 12px; background: transparent; border: none;
  cursor: pointer; opacity: 0.5; transition: all 0.4s var(--spring);
}
.step-btn:hover { opacity: 0.8; }
.step-btn.active { opacity: 1; }
.step-num {
  width: 32px; height: 32px; border-radius: 50%; background: var(--surface);
  border: 1px solid var(--border); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; font-weight: 600;
  font-size: 0.85rem; transition: all 0.4s var(--spring);
}
.step-btn.active .step-num { background: var(--text); color: var(--bg); border-color: var(--text); box-shadow: 0 0 15px rgba(255,255,255,0.2); }
.step-label { font-size: 0.95rem; font-weight: 500; color: var(--text); transition: all 0.3s; }
.step-btn:not(.active) .step-label { color: var(--text-muted); }
.step-line { height: 1px; flex: 1; max-width: 60px; background: var(--border); transition: all 0.4s; }

/* WIZARD STEPS */
.wizard-step { display: none; opacity: 0; animation: stepFadeIn 0.5s var(--spring) forwards; }
.wizard-step.active { display: block; }
@keyframes stepFadeIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* REDESIGNED ROUTINE TABLES (Jakub Krehel Style) */
.table-wrap {
  background: rgba(17, 17, 17, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 24px; padding: 32px; margin-bottom: 32px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.slots-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.slots-table th { 
  padding: 0 16px 12px 16px; font-size: 0.75rem; text-transform: uppercase; 
  color: rgba(255,255,255,0.3); font-weight: 600; letter-spacing: 0.1em; text-align: center; border: none;
}
.slots-table th:first-child { text-align: left; }
.slots-table td { 
  background: rgba(255,255,255,0.02); padding: 12px 16px; 
  border-top: 1px solid rgba(255,255,255,0.02); border-bottom: 1px solid rgba(255,255,255,0.02);
  text-align: center; transition: all 0.2s;
}
.slots-table tr td:first-child { 
  border-left: 1px solid rgba(255,255,255,0.02); border-top-left-radius: 16px; border-bottom-left-radius: 16px;
  text-align: left; font-weight: 500; color: var(--text-muted);
}
.slots-table tr td:last-child { 
  border-right: 1px solid rgba(255,255,255,0.02); border-top-right-radius: 16px; border-bottom-right-radius: 16px; 
}
.slots-table tr:hover td { background: rgba(255,255,255,0.04); }

/* The Toggle Checkbox (Pill style) */
.routine-chk {
  appearance: none; -webkit-appearance: none;
  width: 44px; height: 24px; border-radius: 12px; background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1); cursor: pointer; position: relative;
  transition: all 0.3s var(--spring); margin: 0 auto; display: block;
}
.routine-chk::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  background: var(--text-muted); border-radius: 50%; transition: all 0.3s var(--spring);
}
.routine-chk:checked { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); }
.routine-chk:checked::after { transform: translateX(20px); background: var(--text); box-shadow: 0 0 10px rgba(255,255,255,0.2); }

/* Checkbox specific colors */
.routine-chk[data-period="matin"]:checked { background: rgba(251, 191, 36, 0.15); border-color: rgba(251, 191, 36, 0.3); }
.routine-chk[data-period="matin"]:checked::after { background: var(--color-matin); box-shadow: 0 0 10px rgba(251, 191, 36, 0.3); }

.routine-chk[data-period="repas"]:checked { background: rgba(16, 185, 129, 0.15); border-color: rgba(16, 185, 129, 0.3); }
.routine-chk[data-period="repas"]:checked::after { background: var(--color-repas); box-shadow: 0 0 10px rgba(16, 185, 129, 0.3); }

.routine-chk[data-period="soir"]:checked { background: rgba(59, 130, 246, 0.15); border-color: rgba(59, 130, 246, 0.3); }
.routine-chk[data-period="soir"]:checked::after { background: var(--color-soir); box-shadow: 0 0 10px rgba(59, 130, 246, 0.3); }



/* WIZARD STEPPER */
.stepper-nav {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin-bottom: 48px; width: 100%;
}
.step-btn {
  display: flex; align-items: center; gap: 12px; background: transparent; border: none;
  cursor: pointer; opacity: 0.5; transition: all 0.4s var(--spring);
}
.step-btn:hover { opacity: 0.8; }
.step-btn.active { opacity: 1; }
.step-num {
  width: 32px; height: 32px; border-radius: 50%; background: var(--surface);
  border: 1px solid var(--border); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; font-weight: 600;
  font-size: 0.85rem; transition: all 0.4s var(--spring);
}
.step-btn.active .step-num { background: var(--text); color: var(--bg); border-color: var(--text); box-shadow: 0 0 15px rgba(255,255,255,0.2); }
.step-label { font-size: 0.95rem; font-weight: 500; color: var(--text); transition: all 0.3s; }
.step-btn:not(.active) .step-label { color: var(--text-muted); }
.step-line { height: 1px; flex: 1; max-width: 60px; background: var(--border); transition: all 0.4s; }
.wizard-step { display: none; opacity: 0; animation: stepFadeIn 0.5s var(--spring) forwards; }
.wizard-step.active { display: block; }
@keyframes stepFadeIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }


/* REDESIGNED ROUTINE TABLES (Jakub Krehel Style) */
.table-wrap {
  background: rgba(17, 17, 17, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 24px; padding: 32px; margin-bottom: 32px; overflow-x: auto;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.slots-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.slots-table th { 
  padding: 0 16px 12px 16px; font-size: 0.75rem; text-transform: uppercase; 
  color: rgba(255,255,255,0.3); font-weight: 600; letter-spacing: 0.1em; text-align: center; border: none;
}
.slots-table th:first-child { text-align: left; }
.slots-table td { 
  background: rgba(255,255,255,0.02); padding: 12px 16px; 
  border-top: 1px solid rgba(255,255,255,0.02); border-bottom: 1px solid rgba(255,255,255,0.02);
  text-align: center; transition: all 0.2s;
}
.slots-table tr td:first-child { 
  border-left: 1px solid rgba(255,255,255,0.02); border-top-left-radius: 16px; border-bottom-left-radius: 16px;
  text-align: left; font-weight: 500; color: var(--text-muted);
}
.slots-table tr td:last-child { 
  border-right: 1px solid rgba(255,255,255,0.02); border-top-right-radius: 16px; border-bottom-right-radius: 16px; 
}
.slots-table tr:hover td { background: rgba(255,255,255,0.04); }

/* The Toggle Checkbox (Pill style) */
.routine-chk {
  appearance: none; -webkit-appearance: none;
  width: 44px; height: 24px; border-radius: 12px; background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1); cursor: pointer; position: relative;
  transition: all 0.3s var(--spring); margin: 0 auto; display: block;
}
.routine-chk::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  background: var(--text-muted); border-radius: 50%; transition: all 0.3s var(--spring);
}
.routine-chk:checked { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); }
.routine-chk:checked::after { transform: translateX(20px); background: var(--text); box-shadow: 0 0 10px rgba(255,255,255,0.2); }

.routine-chk[data-period="matin"]:checked { background: rgba(251, 191, 36, 0.15); border-color: rgba(251, 191, 36, 0.3); }
.routine-chk[data-period="matin"]:checked::after { background: var(--color-matin); box-shadow: 0 0 10px rgba(251, 191, 36, 0.3); }
.routine-chk[data-period="repas"]:checked { background: rgba(16, 185, 129, 0.15); border-color: rgba(16, 185, 129, 0.3); }
.routine-chk[data-period="repas"]:checked::after { background: var(--color-repas); box-shadow: 0 0 10px rgba(16, 185, 129, 0.3); }
.routine-chk[data-period="soir"]:checked { background: rgba(59, 130, 246, 0.15); border-color: rgba(59, 130, 246, 0.3); }
.routine-chk[data-period="soir"]:checked::after { background: var(--color-soir); box-shadow: 0 0 10px rgba(59, 130, 246, 0.3); }
