/**
 * AdyStation — CSS Foundation
 * Design tokens, variables, responsive breakpoints, component base styles.
 */

/* ═══════════════════════════════════════
   RESET
   ═══════════════════════════════════════ */

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

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

input, textarea, select, button {
  font-family: inherit;
  font-size: 16px; /* iOS zoom prevention */
}

/* ═══════════════════════════════════════
   DESIGN TOKENS
   ═══════════════════════════════════════ */

:root {
  /* Core palette */
  --bg: #F8F5F0;
  --bg-white: #FFFFFF;
  --border: #EAE6E0;
  --meta: #A8A3A0;
  --text: #1F2937;
  --pipe: #CBC6BE;
  --warm-grey: #8A8178;

  /* Fonts */
  --font-family: 'Inter', sans-serif;
  --font-body: 13px;
  --font-small: 11px;
  --font-xs: 9px;
  --font-label: 12px;
  --font-heading: 18px;
  --font-subheading: 15px;
  --font-input: 16px;

  /* Spacing */
  --pad: 14px;
  --pad-sm: 8px;
  --radius: 10px;
  --radius-sm: 8px;
  --radius-pill: 20px;
  --radius-round: 50%;

  /* Transitions */
  --transition-fast: 0.12s ease;
  --transition: 0.2s ease;

  /* Status colours */
  --color-success: #2D8C4E;
  --color-warning: #B8960F;
  --color-error: #C62828;
  --color-info: #1565C0;

  --color-success-soft: #E6F4EA;
  --color-warning-soft: #FFF8E1;
  --color-error-soft: #FEF2F2;
  --color-info-soft: #E8F0FE;

  --color-success-border: #C4E5CC;
  --color-warning-border: #F5E6A3;
  --color-error-border: #FECACA;
  --color-info-border: #C3D7F7;

  /* Calendar colours */
  --color-cal-work: #1A73E8;
  --color-cal-work-soft: #E8F0FE;
  --color-cal-personal: #00838F;
  --color-cal-personal-soft: #E0F7FA;

  /* Module colours */
  --color-daily: #1F2937;
  --color-bible: #2B4094;
  --color-bible-soft: #D4D8F0;
  --color-wardrobe: #CC3200;
  --color-wardrobe-soft: #F5DDD4;
  --color-workout: #9E1B34;
  --color-workout-soft: #F5D4DA;
  --color-collections: #A0522D;
  --color-collections-soft: #F0E0D4;
  --color-inventory: #5A9E6A;
  --color-inventory-soft: #E4F4E5;
  --color-kitchen: #2D8C4E;
  --color-kitchen-soft: #D4F0DD;
  --color-split: #FF91AF;
  --color-split-soft: #FFE8EF;
  --color-travel: #7FBFB0;
  --color-travel-soft: #DDF0EB;
  --color-language: #020202;
  --color-language-soft: #E0E0E0;
  --color-health: #C4727F;
  --color-health-soft: #F5E4E7;
  --color-timber: #9E8E6A;
  --color-timber-soft: #EDE8DF;
  --color-finance: #43B3AE;
  --color-finance-soft: #D6F0EE;
  --color-car: #43B3AE;
  --color-car-soft: #D6F0EE;
  --color-property: #6B5B73;
  --color-property-soft: #E8E0EC;
  --color-planner: #0014A8;
  --color-planner-soft: #D4D8F0;
  --color-claims: #43B3AE;
  --color-claims-soft: #D6F0EE;

  /* FAB entry label colours */
  --color-stretch: #800080;
  --color-task: #2B4094;
  --color-wake: #E8A830;
  --color-sleep: #3A5BA0;

  /* FAB icon colour */
  --color-fab-icon: #1F2937;

  /* Bottom nav icon colour */
  --color-nav-icon: #020202;
}

/* Desktop responsive */
@media (min-width: 768px) {
  :root {
    --font-body: 15px;
    --font-small: 13px;
    --font-label: 14px;
    --font-heading: 22px;
    --font-subheading: 17px;
  }
}

/* Module colour data attributes */
[data-module] {
  --module-color: var(--text);
  --module-soft: var(--bg);
}
[data-module="bible"]      { --module-color: var(--color-bible);      --module-soft: var(--color-bible-soft); }
[data-module="wardrobe"]   { --module-color: var(--color-wardrobe);   --module-soft: var(--color-wardrobe-soft); }
[data-module="workout"]    { --module-color: var(--color-workout);    --module-soft: var(--color-workout-soft); }
[data-module="collections"]{ --module-color: var(--color-collections);--module-soft: var(--color-collections-soft); }
[data-module="inventory"]  { --module-color: var(--color-inventory);  --module-soft: var(--color-inventory-soft); }
[data-module="kitchen"]    { --module-color: var(--color-kitchen);    --module-soft: var(--color-kitchen-soft); }
[data-module="split"]      { --module-color: var(--color-split);      --module-soft: var(--color-split-soft); }
[data-module="travel"]     { --module-color: var(--color-travel);     --module-soft: var(--color-travel-soft); }
[data-module="language"]   { --module-color: var(--color-language);   --module-soft: var(--color-language-soft); }
[data-module="health"]     { --module-color: var(--color-health);     --module-soft: var(--color-health-soft); }
[data-module="timber"]     { --module-color: var(--color-timber);     --module-soft: var(--color-timber-soft); }
[data-module="finance"]    { --module-color: var(--color-finance);    --module-soft: var(--color-finance-soft); }
[data-module="car"]        { --module-color: var(--color-car);        --module-soft: var(--color-car-soft); }
[data-module="property"]   { --module-color: var(--color-property);   --module-soft: var(--color-property-soft); }
[data-module="planner"]    { --module-color: var(--color-planner);    --module-soft: var(--color-planner-soft); }
[data-module="claims"]     { --module-color: var(--color-claims);     --module-soft: var(--color-claims-soft); }

/* ═══════════════════════════════════════
   LAYOUT SHELL
   ═══════════════════════════════════════ */

#app {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  background: var(--bg);
}

@media (min-width: 768px) {
  #app {
    max-width: 720px;
  }
}

/* Module containers — hidden by default, toggled with .active */
.module-container {
  display: none;
  padding-bottom: 80px; /* space for bottom nav */
}

.module-container.active {
  display: block;
}

/* ═══════════════════════════════════════
   MODULE HEADER
   ═══════════════════════════════════════ */

.module-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
}

.module-header-inner {
  padding: 10px var(--pad);
  background: var(--module-soft);
  border-bottom: 2px solid var(--module-color);
  display: flex;
  align-items: center;
  gap: 8px;
}

.module-header .squirrel {
  font-size: 20px;
  display: inline-block;
  transform: scaleX(-1);
  cursor: pointer;
  line-height: 1;
}

.module-header .module-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--module-color);
}

/* ═══════════════════════════════════════
   TAB BAR
   ═══════════════════════════════════════ */

.tab-bar {
  display: flex;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.tab-bar .tab {
  flex: 1;
  padding: 7px 10px;
  font-size: 10px;
  cursor: pointer;
  text-align: center;
  font-weight: 400;
  color: #9CA3AF;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
}

.tab-bar .tab.active {
  font-weight: 600;
  color: var(--module-color);
  border-bottom-color: var(--module-color);
}

/* ═══════════════════════════════════════
   BOTTOM NAV
   ═══════════════════════════════════════ */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 6px 0 4px;
  z-index: 20;
}

@media (min-width: 768px) {
  .bottom-nav {
    max-width: 720px;
  }
}

.bottom-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  padding: 4px 12px;
}

.bottom-nav .nav-item .nav-label {
  font-size: 9px;
  color: var(--meta);
}

.bottom-nav .nav-item.active .nav-label {
  color: var(--color-nav-icon);
  font-weight: 600;
}

/* ═══════════════════════════════════════
   FAB
   ═══════════════════════════════════════ */

.fab {
  position: fixed;
  bottom: 52px;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 25;
  transition: transform var(--transition-fast);
}

.fab:active {
  transform: translateX(-50%) scale(0.92);
}

.fab.open {
  transform: translateX(-50%) rotate(45deg);
}

/* FAB pill strip — confirmed artifact layout: 7 icons in a row */
.fab-pills {
  position: fixed;
  bottom: 108px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  justify-content: space-between;
  z-index: 24;
  width: calc(100% - 32px);
  max-width: 360px;
  background: var(--bg-white);
  border-radius: 16px;
  padding: 12px 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  border: 1px solid var(--border);
}

.fab-pills.open {
  display: flex;
}

.fab-pill {
  padding: 6px 2px;
  border-radius: var(--radius);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.fab-pill:active {
  background: var(--border);
}

/* ═══════════════════════════════════════
   COMMON COMPONENTS
   ═══════════════════════════════════════ */

/* Section label */
.section-label {
  padding: 8px var(--pad) 4px;
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--module-color);
  letter-spacing: 0.03em;
}

/* List row */
.list-row {
  display: flex;
  align-items: center;
  padding: 8px var(--pad);
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.list-row .row-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--module-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
}

/* Checkbox */
.checkbox {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  flex-shrink: 0;
  cursor: pointer;
  border: 1.5px solid var(--pipe);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.checkbox.checked {
  border-color: var(--module-color);
  background: var(--module-color);
}

/* Form input */
.form-input {
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: var(--font-input);
  outline: none;
  background: var(--bg-white);
}

.form-input:focus {
  border-color: var(--module-color);
}

/* Form label */
.form-label {
  font-size: var(--font-xs);
  color: var(--meta);
  font-weight: 600;
  letter-spacing: 0.03em;
  display: block;
  margin-bottom: 4px;
}

/* Button */
.btn {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  border: none;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.btn:active {
  opacity: 0.85;
}

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

.btn-secondary {
  background: var(--bg-white);
  color: var(--module-color);
  border: 1px solid var(--module-color);
}

.btn-danger {
  background: var(--color-error-soft);
  color: var(--color-error);
  border: 1px solid var(--color-error-border);
}

/* Pill selector */
.pill-row {
  display: flex;
  gap: 4px;
}

.pill {
  flex: 1;
  padding: 8px 0;
  border-radius: var(--radius-pill);
  font-size: 10px;
  text-align: center;
  cursor: pointer;
  font-weight: 400;
  background: var(--bg-white);
  color: var(--text);
  border: 1px solid var(--border);
  transition: all var(--transition-fast);
}

.pill.active {
  font-weight: 600;
  background: var(--module-color);
  color: #fff;
  border-color: var(--module-color);
}

/* Status badge */
.status-badge {
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 8px;
  font-weight: 600;
}

.status-badge.success { background: var(--color-success-soft); color: var(--color-success); border: 1px solid var(--color-success-border); }
.status-badge.warning { background: var(--color-warning-soft); color: var(--color-warning); border: 1px solid var(--color-warning-border); }
.status-badge.error   { background: var(--color-error-soft);   color: var(--color-error);   border: 1px solid var(--color-error-border); }

/* Sync banner */
.sync-banner {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 var(--pad);
  font-size: 10px;
  font-weight: 500;
}

/* Thousands separator utility — applied via JS */

/* ═══════════════════════════════════════
   FAB PILL ICONS (SVG + label layout)
   ═══════════════════════════════════════ */

.fab-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.fab-pill svg {
  flex-shrink: 0;
}

.fab-pill-label {
  font-size: 7px;
  font-weight: 600;
  color: var(--color-fab-icon);
  letter-spacing: 0.02em;
}

/* FAB pill selected state (applied by JS) */
.fab-pill.selected {
  background: #E6FAF8;
  border: 1.5px solid #4DD0C8;
}

.fab-pill.selected svg {
  stroke: #4DD0C8;
}

.fab-pill.selected .fab-pill-label {
  color: #4DD0C8;
}

/* ═══════════════════════════════════════
   SCROLL WHEEL TIME PICKER
   ═══════════════════════════════════════ */

.ady-scroll-col::-webkit-scrollbar {
  display: none;
}

.ady-scroll-col {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* ═══════════════════════════════════════
   QUANTITY STEPPER
   ═══════════════════════════════════════ */

.stepper {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-white);
  height: 38px;
}

.stepper-btn {
  width: 32px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  user-select: none;
  -webkit-user-select: none;
  border: none;
  background: transparent;
  font-family: var(--font-family);
}

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

.stepper-btn.disabled {
  color: var(--border);
  cursor: default;
}

.stepper-btn.disabled:active {
  background: transparent;
}

.stepper-btn:first-child {
  border-right: 1px solid var(--border);
}

.stepper-btn:last-child {
  border-left: 1px solid var(--border);
}

.stepper-value {
  flex: 1;
  min-width: 36px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-input);
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-family);
}

.stepper.compact {
  width: 90px;
}

/* ═══════════════════════════════════════
   FORM FIELD ROWS
   ═══════════════════════════════════════ */

.field-row {
  display: flex;
  gap: 6px;
}

.field-row > * {
  flex: 1;
  min-width: 0;
}

/* ═══════════════════════════════════════
   TOGGLE SWITCH
   ═══════════════════════════════════════ */

.toggle {
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: var(--border);
  cursor: pointer;
  position: relative;
  transition: background var(--transition-fast);
  flex-shrink: 0;
}

.toggle.on {
  background: var(--module-color);
}

.toggle-knob {
  width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: left var(--transition-fast);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle.on .toggle-knob {
  left: 20px;
}

/* ═══════════════════════════════════════
   BACK HEADER (FAB form sub-views)
   ═══════════════════════════════════════ */

.back-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.back-header-chevron {
  cursor: pointer;
  padding: 4px 0;
  display: flex;
  align-items: center;
}

.back-header-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* ═══════════════════════════════════════
   MULTI-SELECT PILLS
   ═══════════════════════════════════════ */

.multi-pill-row {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.multi-pill {
  flex: 1;
  padding: 8px 0;
  border-radius: var(--radius-pill);
  font-size: 10px;
  text-align: center;
  cursor: pointer;
  font-weight: 400;
  background: var(--bg-white);
  color: var(--text);
  border: 1px solid var(--border);
  transition: all var(--transition-fast);
  font-family: var(--font-family);
}

.multi-pill.active {
  font-weight: 600;
}

/* ═══════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════ */

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

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

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ═══════════════════════════════════════
   SAFE AREAS (iOS notch)
   ═══════════════════════════════════════ */

.bottom-nav {
  padding-bottom: max(4px, env(safe-area-inset-bottom));
}

.module-header {
  padding-top: env(safe-area-inset-top);
}
