/* ---------- Design system Coremed (aligné renderer/styles.css) ---------- */
:root {
  --bg: #ffffff;
  --text: #0a0a0a;
  --muted: #7b7b7b;
  --muted-2: #a7a7a7;
  --border: #e9e9e9;
  --border-2: #f0f0f0;
  --card: #ffffff;
  --orange: #ff6b35;
  --orange-soft: #fff5f2;
  --green: #2e7d32;
  --red: #c53a2e;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  --r: 12px;
  --focus: 0 0 0 3px rgba(255, 107, 53, 0.18);
  /* Touch: zone de tap minimum recommandée mobile */
  --touch-min: 44px;
  /* Safe area pour encoche / barre d’état */
  --safe-top: env(safe-area-inset-top, 0);
  --safe-right: env(safe-area-inset-right, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
  --safe-left: env(safe-area-inset-left, 0);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "Rethink Sans", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  padding-bottom: var(--safe-bottom);
}

/* ---------- Écrans (visibilité gérée par app.js via hidden + style.display) ---------- */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}
.screen:not([hidden]) {
  display: flex;
}
.screen--login,
.screen--forbidden,
.screen--form {
  flex-direction: column;
}

/* ---------- LOGIN ---------- */
.screen--login {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.login-hero {
  padding: calc(28px + var(--safe-top)) 20px 24px;
  color: #fff;
  background: linear-gradient(180deg, #f7bf57 0%, #f3a24a 35%, #f57a35 100%);
  text-align: center;
  flex-shrink: 0;
}

.login-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
  user-select: none;
}

.login-brand .logo {
  flex-shrink: 0;
}

.login-brand .name {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
}

.login-pitch {
  margin: 0;
  font-size: 13px;
  opacity: 0.95;
  font-weight: 500;
}

.login-panel {
  flex: 1;
  padding: 24px 20px 32px;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  margin-top: -16px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
  min-width: 0;
}

.login-panel .h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
}

.login-panel .sub {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 20px;
}

.login-form .field {
  margin-bottom: 16px;
}

.label-sm {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #3c3c3c;
  margin-bottom: 6px;
}

.input {
  width: 100%;
  min-height: var(--touch-min);
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

.input::placeholder {
  color: var(--muted-2);
}

.input:focus {
  border-color: rgba(255, 107, 53, 0.55);
  box-shadow: var(--focus);
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.password-wrap .input {
  padding-right: 48px;
}
.pwd-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 8px;
  font-size: 18px;
  line-height: 1;
  border-radius: 4px;
}
.pwd-toggle:hover {
  color: var(--text);
}
.pwd-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.pwd-toggle svg {
  display: block;
}

.input--date {
  max-width: 100%;
}

/* Date picker custom : trigger + fenêtre de choix au style de l’app */
.date-picker-wrap {
  position: relative;
  width: 100%;
}
.date-picker-wrap .date-picker__native {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}
.date-picker-trigger {
  width: 100%;
  min-height: var(--touch-min);
  padding: 12px 36px 12px 14px;
  font-size: 16px;
  text-align: left;
  outline: none;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  font-family: inherit;
}
.date-picker-trigger:hover {
  border-color: #ddd;
}
.date-picker-trigger:focus {
  border-color: rgba(255, 107, 53, 0.55);
  box-shadow: var(--focus);
}
.date-picker-trigger::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--muted);
  pointer-events: none;
}
.date-picker-dropdown {
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  min-width: 220px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  z-index: 100;
  display: none;
  padding: 8px;
  font-size: 13px;
}
.date-picker-wrap.is-open .date-picker-dropdown {
  display: block;
}
.date-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 8px;
}
.date-picker-nav {
  width: 26px;
  height: 26px;
  border: 0;
  background: var(--border-2);
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.date-picker-nav:hover {
  background: var(--orange-soft);
  color: var(--orange);
}
.date-picker-nav:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.date-picker-title {
  font-weight: 600;
  color: var(--text);
  min-width: 110px;
  font-size: 12px;
  text-align: center;
}
.date-picker-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  margin-bottom: 4px;
}
.date-picker-weekday {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.date-picker-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
}
.date-picker-day {
  aspect-ratio: 1;
  min-width: 24px;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  transition: background 0.1s, color 0.1s;
  border: none;
  background: transparent;
  outline: none;
  box-shadow: none;
}
.date-picker-day:hover {
  background: var(--orange-soft);
  color: var(--orange);
}
.date-picker-day.other-month {
  color: var(--muted-2);
}
.date-picker-day.today {
  font-weight: 700;
  color: var(--orange);
}
.date-picker-day.today:hover {
  background: var(--orange-soft);
}
.date-picker-day.selected {
  background: var(--orange);
  color: #fff;
}
.date-picker-day.selected:hover {
  background: var(--orange);
  color: #fff;
  filter: brightness(1.05);
}
.date-picker-day:focus-visible {
  outline: none;
  box-shadow: none;
}

.login-form .error {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--red);
  display: none;
}

.login-form .error:not([hidden]) {
  display: block;
}

.login-form .btn {
  margin-top: 8px;
  width: 100%;
  min-height: var(--touch-min);
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--orange);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.06s ease;
}

.login-form .btn:hover {
  filter: brightness(1.05);
}

.login-form .btn:active {
  transform: translateY(1px);
}

.login-form .btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.login-form .btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* ---------- FORBIDDEN ---------- */
.screen--forbidden {
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.forbidden-hero {
  padding: calc(28px + var(--safe-top)) 20px 24px;
  color: #fff;
  background: linear-gradient(180deg, #f57a35 0%, #e55a2b 100%);
  text-align: center;
  flex-shrink: 0;
}

.forbidden-panel {
  flex: 1;
  padding: 24px 20px 32px;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  margin-top: -16px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
  text-align: center;
}

.forbidden-panel .h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text);
}

.forbidden-panel .sub {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 24px;
  line-height: 1.45;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-min);
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  color: var(--orange);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-ghost:hover {
  background: var(--orange-soft);
  border-color: rgba(255, 107, 53, 0.3);
}

.btn-ghost:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

/* ---------- FORMULAIRE (écran déclaration) — pleine hauteur, mobile + PC ---------- */
.screen--form {
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
}

.form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + var(--safe-top));
  padding-left: calc(16px + var(--safe-left));
  padding-right: calc(16px + var(--safe-right));
  background: #fff;
  border-bottom: 1px solid var(--border-2);
  flex-shrink: 0;
}

.form-header-inner {
  min-width: 0;
}

.brand-mini {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--orange);
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 2px;
}

.brand-mini .logo {
  flex-shrink: 0;
}

.user-info {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.form-header .btn-ghost {
  flex-shrink: 0;
  min-height: 40px;
  padding: 8px 14px;
  font-size: 14px;
}

.form-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 16px 28px;
  padding-left: calc(16px + var(--safe-left));
  padding-right: calc(16px + var(--safe-right));
  padding-bottom: calc(28px + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.form-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}

.form-welcome {
  flex-shrink: 0;
  padding: 0 0 24px;
  margin-bottom: 8px;
}

.form-welcome-title {
  margin: 0 0 8px;
  font-size: clamp(22px, 5vw, 26px);
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.form-welcome-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  color: var(--muted);
}

.form-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 22px;
  box-shadow: var(--shadow);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.cleaning-form .field {
  margin-bottom: 18px;
}

.cleaning-form .field-zones {
  margin-bottom: 22px;
}

.cleaning-form .label-sm {
  margin-bottom: 8px;
}

.hint {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
}

.zones-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.zones-list label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: var(--touch-min);
  padding: 12px 16px;
  background: var(--orange-soft);
  border: 1px solid rgba(255, 107, 53, 0.25);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  margin: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.zones-list label:hover {
  background: #ffebe6;
  border-color: var(--orange);
}

.zones-list label:active {
  background: #ffe0d6;
}

.zones-list input {
  width: 20px;
  height: 20px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--orange);
  cursor: pointer;
}

.zones-list input:checked + span {
  font-weight: 600;
  color: var(--orange);
}

.cleaning-form .error {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--red);
  display: none;
}

.cleaning-form .error:not([hidden]) {
  display: block;
}

.btn-submit {
  width: 100%;
  min-height: var(--touch-min);
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--orange);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.06s ease;
  margin-top: 4px;
}

.btn-submit:hover {
  filter: brightness(1.05);
}

.btn-submit:active {
  transform: translateY(1px);
}

.btn-submit:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.btn-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.success {
  margin: 16px 0 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--green);
  display: none;
}

.success:not([hidden]) {
  display: block;
}

/* ---------- Toasts (notifications) ---------- */
.toast-container {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: calc(100vw - 32px);
  width: 100%;
  pointer-events: none;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}
.toast {
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(0, 0, 0, 0.06);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.toast--show {
  opacity: 1;
  transform: translateY(0);
}
.toast--info {
  background: #fff;
  color: var(--text);
  border-color: rgba(255, 107, 53, 0.25);
}
.toast--success {
  background: #e7f4e8;
  color: var(--green);
  border-color: rgba(46, 125, 50, 0.3);
}
.toast--error {
  background: #ffebee;
  color: var(--red);
  border-color: rgba(197, 58, 46, 0.3);
}

/* ---------- Modal confirmation ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-left: calc(20px + var(--safe-left));
  padding-right: calc(20px + var(--safe-right));
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.modal-overlay.modal-overlay--visible {
  opacity: 1;
  pointer-events: auto;
}
.modal-card {
  background: var(--card);
  border-radius: var(--r);
  padding: 24px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  transform: scale(0.96);
  transition: transform 0.2s ease;
}
.modal-overlay.modal-overlay--visible .modal-card {
  transform: scale(1);
}
.modal-title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.modal-summary {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}
.modal-summary strong {
  color: var(--text);
}
.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}
.modal-actions .btn {
  min-height: var(--touch-min);
}

/* ---------- Desktop : pleine largeur/hauteur, expérience cohérente ---------- */
@media (min-width: 640px) {
  .form-body {
    max-width: 480px;
  }
  .form-welcome-title {
    font-size: 26px;
  }
  .form-welcome-text {
    font-size: 16px;
  }
}

@media (min-width: 900px) {
  .screen--login {
    flex-direction: row;
    align-items: stretch;
  }
  .login-hero {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
    border-radius: 0;
  }
  .login-panel {
    flex: 0 0 auto;
    width: min(420px, 45vw);
    margin-top: 0;
    border-radius: 0;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 48px 40px;
  }
  .login-panel .h1 {
    font-size: 22px;
  }
  .login-panel .sub {
    font-size: 13px;
    margin-bottom: 24px;
  }
  .screen--forbidden {
    flex-direction: row;
    align-items: stretch;
  }
  .forbidden-hero {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
  }
  .forbidden-panel {
    flex: 0 0 auto;
    width: min(420px, 45vw);
    margin-top: 0;
    border-radius: 0;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 40px;
    text-align: center;
  }
  .form-main {
    padding: 28px 24px 32px;
  }
  .form-body {
    max-width: 520px;
  }
  .form-welcome {
    padding-bottom: 28px;
    margin-bottom: 12px;
  }
  .form-card {
    padding: 28px;
  }
}

