/* ===== Assistant Rapport — mobile first ===== */

:root {
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --primary-light: #dbeafe;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 14px rgba(15, 23, 42, 0.05);
  --tabbar-h: 62px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ===== Vues ===== */

.view {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.view-full {
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 100%);
}

#main-view {
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
  background: var(--bg);
}

/* ===== Auth ===== */

.auth-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 22px;
  width: 100%;
  max-width: 420px;
}

.auth-logo { font-size: 44px; text-align: center; }

.auth-card h1 {
  margin: 8px 0 0;
  font-size: 24px;
  text-align: center;
}

.auth-sub {
  margin: 4px 0 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.auth-tabs {
  display: flex;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 18px;
}

.auth-tab {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 10px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.auth-tab.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
}

.auth-form { display: flex; flex-direction: column; gap: 14px; }

/* ===== Header ===== */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  background: var(--primary);
  color: #fff;
}

.app-title { font-weight: 700; font-size: 17px; }

.app-header .btn-ghost {
  color: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.35);
}

/* ===== Contenu / pages ===== */

.app-content {
  flex: 1;
  padding: 16px 14px calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
}

.page-title { font-size: 20px; margin: 4px 0 14px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.card-title { margin: 0 0 12px; font-size: 16px; }
.card-hint { font-weight: 400; font-size: 12px; color: var(--muted); }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

/* ===== Champs ===== */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field > span,
.field > label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.field small { font-weight: 400; }

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 12px;
  font-size: 16px; /* empeche le zoom auto sur iOS */
  background: #fff;
  color: var(--text);
  font-family: inherit;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}

.field textarea {
  resize: vertical;
  min-height: 64px;
}

/* ===== Mot de passe : afficher / masquer ===== */

.input-wrap {
  position: relative;
}

.input-wrap input {
  padding-right: 48px;
}

.pwd-toggle {
  position: absolute;
  right: 2px;
  top: 0;
  bottom: 0;
  width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 8px;
  padding: 0;
}

.pwd-toggle:hover {
  color: var(--text);
}

.pwd-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.pwd-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pwd-toggle .ico-eye-off { display: none; }
.pwd-toggle.is-visible .ico-eye { display: none; }
.pwd-toggle.is-visible .ico-eye-off { display: block; }

/* ===== Boutons ===== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: var(--bg);
  color: var(--text);
  transition: filter 0.15s ease, background 0.15s ease;
  min-height: 44px; /* cible tactile */
}

.btn:active { filter: brightness(0.92); }

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

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

.btn-outline {
  background: transparent;
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
  border-color: transparent;
}

.btn-block { width: 100%; }
.btn-lg { padding: 15px 16px; font-size: 17px; }
.btn-sm { padding: 7px 12px; font-size: 14px; min-height: 36px; }

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.btn-row .btn { flex: 1; }

/* ===== Taches ===== */

.task-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  background: #f8fafc;
}

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

.task-card-head strong { font-size: 14px; color: var(--primary); }

.task-remove {
  border: 0;
  background: var(--danger-light);
  color: var(--danger);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.task-card .field:last-child { margin-bottom: 0; }

.card-head .card-title { margin-bottom: 8px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 360px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* ===== Badges / erreurs ===== */

.badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}

.form-error {
  background: var(--danger-light);
  color: var(--danger);
  font-size: 14px;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 0 12px;
}

.form-hint {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin: 10px 0 0;
}

/* ===== Historique ===== */

.history-item {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 12px;
}

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

.history-id {
  font-weight: 700;
  font-size: 15px;
  word-break: break-all;
}

.history-period { color: var(--muted); font-size: 14px; margin-top: 2px; }

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

.status {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.status-generating { background: var(--warning-light); color: var(--warning); }
.status-ready { background: var(--success-light); color: var(--success); }
.status-failed { background: var(--danger-light); color: var(--danger); }

.history-error {
  background: var(--danger-light);
  color: var(--danger);
  font-size: 13px;
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 10px;
  word-break: break-word;
}

.history-warning {
  background: var(--warning-light);
  color: var(--warning);
  font-size: 13px;
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 10px;
}

.history-tasks {
  margin: 12px 0 0;
  padding-left: 20px;
  font-size: 14px;
}

.history-tasks li { margin-bottom: 6px; }

/* ===== Tabbar ===== */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  z-index: 30;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  background: transparent;
  padding: 9px 4px 8px;
  min-height: var(--tabbar-h);
  cursor: pointer;
  color: var(--muted);
  font-family: inherit;
}

.tab-icon { font-size: 20px; line-height: 1; }

.tab-label { font-size: 11px; font-weight: 600; }

.tab-item.active { color: var(--primary); }

.tab-item.active .tab-label { font-weight: 700; }

/* ===== Toast ===== */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 100;
  max-width: calc(100% - 32px);
  text-align: center;
  animation: toast-in 0.25s ease;
}

.toast.toast-error { background: var(--danger); }
.toast.toast-success { background: var(--success); }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ===== Grand ecran (tablette) ===== */

@media (min-width: 560px) {
  body { background: #e2e8f0; }
  #main-view { box-shadow: 0 0 40px rgba(15, 23, 42, 0.12); min-height: 100dvh; }
}


.history-tasks .remark {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

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

/* ===== Profil ===== */

.profile-email {
  font-weight: 600;
  margin: 0 0 14px;
  color: var(--primary);
  word-break: break-all;
}


/* ===== Bibliotheque de taches : selection dans le rapport ===== */

.library-intro {
  text-align: left;
  margin: 0 0 10px;
}

.library-picker {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: #f8fafc;
}

.library-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  max-height: 280px;
  overflow-y: auto;
}

.lib-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  cursor: pointer;
}

.lib-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.lib-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
}

.lib-desc {
  font-weight: 600;
  word-break: break-word;
}

.lib-resultat { align-self: flex-start; }

.lib-remark {
  color: var(--muted);
  font-size: 13px;
  word-break: break-word;
}

.library-empty {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 12px 0;
}

/* ===== Bandeau d edition d'un rapport ===== */

.edit-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--warning-light);
  color: var(--warning);
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

/* ===== Onglet Taches ===== */

.lib-task-item {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 12px;
}

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

.lib-task-desc {
  font-weight: 600;
  font-size: 15px;
  word-break: break-word;
}

.lib-task-remark {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
  word-break: break-word;
}

.lib-task-date {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.btn-row-wrap { flex-wrap: wrap; }
.btn-row-wrap .btn { flex: 1 1 45%; }
.btn-row-wrap label.btn { cursor: pointer; }

.resultat-Fait { background: var(--success-light); color: var(--success); }
.resultat-En_cours { background: var(--warning-light); color: var(--warning); }
.resultat-En_attente { background: var(--primary-light); color: var(--primary); }
/* ===== Selecteur : tache deja presente dans le rapport ===== */

.lib-item-added {
  opacity: 0.65;
  background: var(--bg);
}

.lib-item input[type="checkbox"]:disabled {
  opacity: 0.5;
}

.lib-added {
  align-self: flex-start;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}
/* ===== Taches : selection multiple (checklist) ===== */

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  margin-bottom: 12px;
}

.bulk-bar .btn { flex: 0 0 auto; }

.lib-task-check {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--primary);
  flex-shrink: 0;
  cursor: pointer;
}