/* ============================================
   MJ Pack — Style global mobile-first
   Navigation pyramidale : résumé en haut, détails en profondeur
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

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

:root {
  --bg:        #0a0e27;
  --bg-card:   #111536;
  --bg-input:  #161b40;
  --border:    #1e2548;
  --text:      #e0e6f0;
  --text-muted:#6a7290;
  --text-dim:  #4a5280;
  --accent:    #818cf8;
  --green:     #4ade80;
  --orange:    #fb923c;
  --red:       #ef4444;
  --yellow:    #facc15;
  --blue:      #38bdf8;
  --radius:    14px;
  --radius-sm: 10px;
  --max-w:     480px;
}

html { font-size: 16px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  max-width: var(--max-w);
  margin: 0 auto;
  padding-bottom: 80px;
  -webkit-font-smoothing: antialiased;
}

/* Desktop override */
@media (min-width: 768px) {
  body { max-width: 1200px; }
  body.dashboard-mode { max-width: 1400px; padding: 0 24px 40px; }
}

/* ===== HEADER ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 39, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-title {
  font-size: 1.1em;
  font-weight: 800;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.header-back {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1.4em;
  cursor: pointer;
  padding: 4px 8px;
  display: none;
}
.header-back.visible { display: block; }
.header-user {
  font-size: 0.75em;
  color: var(--text-muted);
  font-weight: 500;
}

/* ===== NAV BOTTOM (mobile) ===== */
.nav-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(10, 14, 39, 0.97);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 6px 0 env(safe-area-inset-bottom, 8px);
  max-width: var(--max-w);
  margin: 0 auto;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  border-radius: 10px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.6em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.nav-item .nav-icon { font-size: 1.8em; }
.nav-item.active { color: var(--accent); }
.nav-item .badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--red);
  color: white;
  font-size: 0.7em;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

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

/* ===== PAGES (pyramidal) ===== */
.page {
  display: none;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}
.page.active { display: block; }

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

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.card-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  flex-shrink: 0;
}
.card-title {
  font-size: 0.95em;
  font-weight: 700;
}
.card-subtitle {
  font-size: 0.72em;
  color: var(--text-muted);
}
.card-clickable { cursor: pointer; transition: border-color 0.2s; }
.card-clickable:hover { border-color: var(--accent); }

/* ===== BOUTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85em;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}
.btn-primary {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
}
.btn-primary:hover { opacity: 0.9; }
.btn-green {
  background: rgba(74, 222, 128, 0.15);
  color: var(--green);
  border: 1px solid rgba(74, 222, 128, 0.3);
}
.btn-red {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
}
.btn-sm { padding: 8px 14px; font-size: 0.75em; width: auto; }

/* ===== DICTÉE (gros bouton central) ===== */
.dictee-zone {
  text-align: center;
  padding: 30px 16px;
}
.dictee-btn {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 3px solid var(--green);
  background: rgba(74, 222, 128, 0.08);
  color: var(--green);
  font-size: 2.5em;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.dictee-btn:hover { background: rgba(74, 222, 128, 0.15); transform: scale(1.05); }
.dictee-btn.recording {
  border-color: var(--red);
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 20px rgba(239, 68, 68, 0); }
}
.dictee-label {
  font-size: 0.85em;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.dictee-client {
  font-size: 0.75em;
  color: var(--accent);
  font-weight: 600;
}

/* ===== TEXTAREA ===== */
.textarea {
  width: 100%;
  min-height: 120px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9em;
  resize: vertical;
  outline: none;
}
.textarea:focus { border-color: var(--accent); }

/* ===== INPUT ===== */
.input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9em;
  outline: none;
}
.input:focus { border-color: var(--accent); }
.input-group { margin-bottom: 12px; }
.input-label {
  display: block;
  font-size: 0.72em;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== SEARCH BAR ===== */
.search-bar {
  position: relative;
  margin-bottom: 14px;
}
.search-bar input {
  width: 100%;
  padding: 12px 14px 12px 40px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.85em;
  outline: none;
}
.search-bar input:focus { border-color: var(--accent); }
.search-bar::before {
  content: '🔍';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9em;
}

/* ===== ALERTES BADGES ===== */
.alerte-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.65em;
  font-weight: 700;
}
.alerte-rouge { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.alerte-orange { background: rgba(251, 146, 60, 0.15); color: var(--orange); }
.alerte-jaune { background: rgba(250, 204, 21, 0.15); color: var(--yellow); }
.alerte-vert { background: rgba(74, 222, 128, 0.15); color: var(--green); }

/* ===== LISTES ===== */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.list-item:hover { border-color: var(--accent); }
.list-item-icon {
  font-size: 1.4em;
  flex-shrink: 0;
}
.list-item-content { flex: 1; min-width: 0; }
.list-item-title {
  font-size: 0.85em;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item-sub {
  font-size: 0.7em;
  color: var(--text-muted);
}
.list-item-arrow {
  color: var(--text-dim);
  font-size: 1.1em;
}

/* ===== KPI ROW ===== */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.kpi-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
}
.kpi-value {
  font-size: 1.4em;
  font-weight: 800;
  color: var(--accent);
}
.kpi-label {
  font-size: 0.6em;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ===== SECTION HEADERS ===== */
.section-header {
  font-size: 0.7em;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin: 20px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ===== LOADING ===== */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== RAPPORT VIEWER ===== */
.rapport-frame {
  width: 100%;
  border: none;
  border-radius: var(--radius);
  background: white;
  min-height: 400px;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.8em;
  font-weight: 600;
  z-index: 1000;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s;
  pointer-events: none;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(20px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(-50%) translateY(20px); } }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 2.5em; margin-bottom: 12px; }
.empty-state .empty-text { font-size: 0.85em; }

/* ===== TAB BAR ===== */
.tab-bar {
  display: flex;
  gap: 4px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 14px;
  overflow-x: auto;
}
.tab-item {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.72em;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.tab-item.active {
  background: var(--accent);
  color: white;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-card);
  border-radius: 20px 20px 0 0;
  padding: 24px 16px;
  width: 100%;
  max-width: var(--max-w);
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-screen.hidden { display: none; }
.login-container {
  text-align: center;
  padding: 24px;
  width: 100%;
  max-width: 340px;
}
.login-logo {
  font-size: 3em;
  margin-bottom: 8px;
}
.login-title {
  font-size: 1.6em;
  font-weight: 800;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}
.login-subtitle {
  font-size: 0.85em;
  color: var(--text-muted);
  margin-bottom: 28px;
}
.login-select-group {
  margin-bottom: 24px;
  text-align: left;
}
.login-label {
  display: block;
  font-size: 0.7em;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.login-select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9em;
  outline: none;
  cursor: pointer;
}
.login-select:focus { border-color: var(--accent); }
.login-select option { background: var(--bg-card); color: var(--text); }

.login-pin-label {
  font-size: 0.7em;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}
.login-pin-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 8px;
}
.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  transition: all 0.15s;
}
.pin-dot.filled {
  background: var(--accent);
  border-color: var(--accent);
}
.pin-dot.error {
  border-color: var(--red);
  background: var(--red);
  animation: shake 0.4s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.login-error {
  font-size: 0.78em;
  color: var(--red);
  min-height: 24px;
  margin-bottom: 4px;
  font-weight: 600;
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 260px;
  margin: 0 auto;
}
.pin-key {
  width: 100%;
  aspect-ratio: 1.4;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 1.4em;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pin-key:active {
  background: var(--accent);
  color: white;
  transform: scale(0.95);
}
.pin-key-empty {
  border: none;
  background: none;
  cursor: default;
}
.pin-key-delete {
  font-size: 1.2em;
  color: var(--text-muted);
}
.pin-key-delete:active {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
}

/* ===== PYRAMID BUTTONS (navigation pyramidale) ===== */
.pyramid-grid {
  display: grid;
  gap: 12px;
  padding: 16px;
  height: calc(100vh - 120px);
  align-content: center;
}
.pyramid-3 {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr 1fr 1fr;
}
.pyramid-4 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  height: auto;
  min-height: 280px;
}
.pyramid-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.2s;
  min-height: 100px;
  position: relative;
}
.pyramid-btn:active { transform: scale(0.97); }
.pyramid-icon {
  font-size: 2.8em;
  line-height: 1;
}
.pyramid-4 .pyramid-icon { font-size: 2.2em; }
.pyramid-label {
  font-size: 1.1em;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-family: inherit;
}
.pyramid-4 .pyramid-label { font-size: 0.85em; }

/* Couleurs des boutons pyramidaux */
.pyramid-green {
  border-color: rgba(74, 222, 128, 0.4);
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.08), var(--bg-card));
  color: var(--green);
}
.pyramid-green:active { border-color: var(--green); }
.pyramid-accent {
  border-color: rgba(129, 140, 248, 0.4);
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.08), var(--bg-card));
  color: var(--accent);
}
.pyramid-accent:active { border-color: var(--accent); }
.pyramid-red {
  border-color: rgba(239, 68, 68, 0.4);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), var(--bg-card));
  color: var(--red);
}
.pyramid-red:active { border-color: var(--red); }
.pyramid-blue {
  border-color: rgba(56, 189, 248, 0.4);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.08), var(--bg-card));
  color: var(--blue);
}
.pyramid-blue:active { border-color: var(--blue); }
.pyramid-yellow {
  border-color: rgba(250, 204, 21, 0.4);
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.08), var(--bg-card));
  color: var(--yellow);
}
.pyramid-yellow:active { border-color: var(--yellow); }
.pyramid-orange {
  border-color: rgba(251, 146, 60, 0.4);
  background: linear-gradient(135deg, rgba(251, 146, 60, 0.08), var(--bg-card));
  color: var(--orange);
}
.pyramid-orange:active { border-color: var(--orange); }

/* Badge sur bouton pyramidal */
.pyramid-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--red);
  color: white;
  font-size: 0.75em;
  font-weight: 800;
  min-width: 24px;
  height: 24px;
  border-radius: 12px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

/* Footer sous les boutons pyramidaux */
.pyramid-footer {
  text-align: center;
  padding: 8px 16px;
}
.pyramid-footer-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.75em;
  font-family: inherit;
  cursor: pointer;
  padding: 8px 16px;
}
.pyramid-footer-btn:active { color: var(--text-muted); }

/* ===== CLIENT HEADER CARD ===== */
.client-header-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0 8px;
}
.client-header-icon { font-size: 2em; }
.client-header-name {
  font-size: 1.05em;
  font-weight: 800;
}
.client-header-sub {
  font-size: 0.75em;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== DATA ROWS (fiche client) ===== */
.data-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.data-row:last-child { border-bottom: none; }
.data-label {
  font-size: 0.75em;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.data-value {
  font-size: 0.85em;
  font-weight: 600;
  color: var(--text);
}
