/* ===========================================
   TPP ASE VAUD — DESIGN SYSTEM 2.1
   =========================================== */

:root {
  --bg:           #F8FAFC;
  --bg-dots:      rgba(13, 148, 136, 0.05);
  --surface:      #FFFFFF;
  --surface-muted: #F1F5F9;
  --border:       #CBD5E1;
  --border-focus: #0D9488;
  --text:         #0F172A;
  --text-muted:   #334155;
  --text-soft:    #64748B;
  
  --primary:      #0D9488; 
  --primary-glow: rgba(13, 148, 136, 0.15);
  --accent:       #2563EB;
  --secondary:    #7C3AED;
  
  --success:      #10B981;
  --danger:       #EF4444;
  --warning:      #F59E0B;
  
  --radius:       16px;
  --radius-sm:    10px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.05);
  --shadow:       0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -4px rgba(0,0,0,0.05);
  --shadow-lg:    0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
  
  --font-main:    'Plus Jakarta Sans', sans-serif;
  --font-titles:  'Outfit', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font-main);
  background: var(--bg);
  background-image: radial-gradient(var(--bg-dots) 1px, transparent 1px), radial-gradient(var(--bg-dots) 1px, transparent 1px);
  background-size: 20px 20px; background-position: 0 0, 10px 10px;
  color: var(--text); line-height: 1.6; min-height: 100vh;
}

.app-header {
  background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); padding: 1rem 2rem; position: sticky; top: 0; z-index: 1000;
}
.header-content { max-width: 1200px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; }
.brand { display: flex; align-items: center; gap: 1rem; }
.logo-circle {
  width: 42px; height: 42px; background: var(--primary); color: #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-family: var(--font-titles); font-weight: 800; font-size: 1.1rem;
}
.brand h1 { font-family: var(--font-titles); font-size: 1.3rem; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }

.lang-select { padding: 0.5rem; border-radius: 8px; border: 1px solid var(--border); font-weight: 600; font-size: 0.8rem; cursor: pointer; }

.steps-nav { display: flex; justify-content: center; align-items: center; padding: 1.5rem; max-width: 900px; margin: 0 auto; gap: 0.5rem; }
.step-btn {
  display: flex; align-items: center; gap: 0.8rem; padding: 0.6rem 1.2rem; border-radius: 100px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-soft); cursor: pointer;
  transition: all 0.3s; font-family: var(--font-titles); font-weight: 600;
}
.step-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 4px 16px var(--primary-glow); }
.step-btn.done { border-color: var(--success); color: var(--success); }
.step-num { width: 22px; height: 22px; background: var(--surface-muted); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; }
.step-btn.active .step-num { background: rgba(255,255,255,0.2); color: #fff; }
.step-divider { width: 20px; height: 2px; background: var(--border); }

.app-main { max-width: 1100px; margin: 0 auto; padding: 1rem 1.5rem 4rem; }
.step-section { display: none; animation: slideUp 0.3s ease-out; }
.step-section.active { display: block; }

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

.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; margin-bottom: 2rem; box-shadow: var(--shadow); }
.form-card h2 { font-family: var(--font-titles); font-size: 1.25rem; font-weight: 700; margin-bottom: 1.5rem; display: flex; align-items: center; gap: 12px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group.full-width { grid-column: 1 / -1; }
label { font-size: 0.85rem; font-weight: 700; color: var(--text-muted); }
input, select, textarea {
  padding: 0.75rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--border);
  font-family: inherit; font-size: 0.95rem; color: var(--text); background: #fff; transition: all 0.2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-glow); outline: none; }
input.error { border-color: var(--danger); background: #fef2f2; }

.domaine-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1rem; }
.domaine-btn {
  background: #fff; border: 2px solid var(--border); border-radius: var(--radius-sm);
  padding: 1.2rem 0.5rem; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; transition: all 0.2s;
}
.domaine-btn:hover { border-color: var(--primary); transform: translateY(-2px); }
.domaine-btn.selected { border-color: var(--primary); color: var(--primary); box-shadow: 0 8px 20px var(--primary-glow); }
.domaine-code { font-family: var(--font-titles); font-weight: 800; font-size: 1.1rem; }
.domaine-nom { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; text-align: center; }

#err-domaine { font-size: 0.85rem; color: var(--danger); font-weight: 700; text-align: center; display: block; margin-top: 1rem; }
.error-shake { animation: shake 0.4s both; border: 2px solid var(--danger) !important; }
@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  30%, 70% { transform: translate3d(-3px, 0, 0); }
  40%, 60% { transform: translate3d(3px, 0, 0); }
}

/* --- Timeline Improved --- */
.timeline-track {
  height: 84px; background: #fefefe; border-radius: 18px; border: 3px solid #cbd5e1;
  display: flex; overflow: hidden; margin-bottom: 5px; position: relative;
  box-shadow: inset 0 4px 8px rgba(15,23,42,0.08);
}
.timeline-seg.pres { 
  background: repeating-linear-gradient(45deg, #94a3b8, #94a3b8 10px, #cbd5e1 10px, #cbd5e1 20px); 
  border-right: 2px solid #64748b;
}
.timeline-seg.prep { 
  background: repeating-linear-gradient(45deg, #64748b, #64748b 10px, #94a3b8 10px, #94a3b8 20px); 
  border-right: 2px solid #475569;
}
.timeline-seg.entr { 
  background: repeating-linear-gradient(45deg, #475569, #475569 10px, #64748b 10px, #64748b 20px); 
}
.timeline-seg.missions-zone { flex: 1; display: flex; background: #fff; border-inline: 4px solid #1e293b; }

.timeline-legend { 
  display: flex; justify-content: center; flex-wrap: wrap; gap: 1.5rem; margin-top: 25px; 
}
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.75rem; font-weight: 700; color: #475569; }
.legend-item .dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.1); }
.legend-item.pres .dot { background: #94a3b8; }
.legend-item.m1 .dot { background: #0D9488; }
.legend-item.m2 .dot { background: #2563EB; }
.legend-item.m3 .dot { background: #7C3AED; }
.legend-item.prep .dot { background: #64748b; }
.legend-item.entr .dot { background: #475569; }
.mission-block {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 1rem; border-right: 1px solid rgba(255,255,255,0.3);
  text-shadow: 0 1px 2px rgba(0,0,0,0.3); transition: filter 0.2s;
}
.mission-block:hover { filter: brightness(1.1); }
.timeline-labels { height: 25px; position: relative; margin-top: 10px; }
.seg-time { 
  position: absolute; font-size: 12px; font-weight: 800; color: #1e293b; background: #fff;
  padding: 2px 6px; border-radius: 4px; border: 1px solid #cbd5e1; transform: translateX(-50%);
}

/* --- Phase 2 Layout --- */
.builder-layout { display: flex; flex-direction: column; gap: 2rem; }
.sequences-zone { flex: 1; min-height: 400px; }
.time-counter { padding: 1.5rem; background: #fff; border: 1px solid var(--border); border-radius: 12px; display: flex; align-items: center; justify-content: center; gap: 2rem; margin-bottom: 2rem; }
.time-counter span { font-size: 2rem; font-weight: 900; }
.time-counter .ok { color: var(--success); }
.time-counter .over { color: var(--danger); }

.missions-summary { 
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); 
  gap: 1.5rem; 
  margin-top: 2rem; padding-top: 2rem; border-top: 2px solid var(--border); margin-bottom: 2rem;
}
.mission-card-horiz {
  background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 1.5rem;
  display: flex; flex-direction: column; gap: 1rem; box-shadow: var(--shadow);
}
.mission-card-header { display: flex; justify-content: space-between; align-items: center; }
.mission-card-title { font-size: 0.75rem; font-weight: 800; color: var(--text-soft); text-transform: uppercase; letter-spacing: 1px; }
.mission-duration-badge { font-weight: 900; font-size: 1rem; padding: 4px 10px; border-radius: 6px; background: #f1f5f9; }
.mission-duration-badge.ok { color: #fff; background: var(--success); }
.mission-duration-badge.err { color: #fff; background: var(--danger); }
.mission-name-small { font-weight: 800; font-size: 1rem; color: #1e293b; }
.mission-static-desc { font-size: 0.8rem; color: #64748b; line-height: 1.5; height: 3em; overflow: hidden; }
.mission-objective-select { width: 100%; border: 1px solid var(--border); padding: 0.8rem; border-radius: 8px; font-size: 0.85rem; }

.sequences-list { display: flex; flex-direction: column; gap: 0.75rem; }
.mission-info-notice {
  background: #f0f9ff; border-left: 4px solid #0ea5e9; padding: 0.75rem 1rem;
  border-radius: 8px; font-size: 0.82rem; color: #0369a1; margin-bottom: 1rem;
  font-style: italic;
}
.seq-card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.25rem;
  display: flex; align-items: center; gap: 1.25rem; box-shadow: var(--shadow-sm); transition: all 0.2s;
}
.seq-card:hover { transform: translateX(4px); border-color: var(--primary); box-shadow: var(--shadow); }
.seq-mission-badge { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 900; font-size: 1.1rem; flex-shrink: 0; }
.seq-info { flex: 1; min-width: 0; }
.seq-title { font-weight: 800; font-size: 0.95rem; color: #1e293b; margin-bottom: 2px; }
.seq-description-text { font-size: 0.85rem; color: #475569; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seq-meta { color: #94a3b8; font-size: 0.78rem; font-weight: 600; }
.seq-time-info { font-weight: 900; font-size: 0.95rem; color: #1e293b; white-space: nowrap; flex-shrink: 0; }

/* --- Modal & Toggle --- */
.wifi-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.toggle-switch { display: inline-block; width: 50px; height: 26px; cursor: pointer; position: relative; }
.toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track { position: absolute; inset: 0; background: #cbd5e1; border-radius: 100px; transition: 0.3s; }
.toggle-thumb { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: 0.3s; }
input:checked + .toggle-track { background: var(--primary); }
input:checked + .toggle-track .toggle-thumb { transform: translateX(24px); }

.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.6); backdrop-filter: blur(8px); display: none; align-items: center; justify-content: center; z-index: 2000; }
.modal-overlay.visible { display: flex; }
.modal { 
  background: #fff; border-radius: 24px; padding: 2.5rem; width: 100%; max-width: 600px; 
  box-shadow: var(--shadow-lg); animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); 
  display: flex; flex-direction: column; gap: 1.5rem;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.9) translateY(20px); } }

.modal-form-group { display: flex; flex-direction: column; gap: 0.5rem; }
.modal-form-group.full-width { width: 100%; }
#seq-description { min-height: 120px; resize: vertical; width: 100%; }
.step-actions { display: flex; justify-content: center; gap: 1rem; margin-top: 2rem; }

.mission-radios { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 0.5rem; }
.mission-radio { display: none; }
.mission-radio-label { 
  border: 2px solid var(--border); border-radius: 16px; padding: 1.5rem 0.5rem; display: flex; flex-direction: column; align-items: center; gap: 10px; cursor: pointer; transition: 0.2s; background: #f8fafc;
}
.mission-radio-label .m-badge { font-family: var(--font-titles); font-weight: 900; font-size: 1rem; color: #1e293b; text-align: center; line-height: 1.3; }
.mission-radio-label .m-label { text-align: center; font-size: 0.7rem; font-weight: 600; color: var(--text-soft); line-height: 1.3; }
.mission-radio:checked + .mission-radio-label { border-color: var(--primary); background: #fff; box-shadow: 0 8px 24px var(--primary-glow); }
.mission-radio:checked + .mission-radio-label .m-badge { color: var(--primary); }
.mission-radio:checked + .mission-radio-label .m-label { color: var(--primary); }

.btn-primary, .btn-secondary, .btn-pdf, .btn-add-sequence { font-family: var(--font-titles); font-weight: 800; padding: 1rem 2rem; border-radius: 12px; cursor: pointer; border: none; transition: 0.2s; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px var(--primary-glow); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 20px var(--primary-glow); }
.btn-add-sequence { background: #fff; border: 2px dashed var(--border); color: #64748b; width: 100%; margin-bottom: 2rem; }
.btn-add-sequence:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-glow); }

.btn-pdf { background: #ef4444; color: #fff; width: 100%; font-size: 1.1rem; }
.btn-pdf:disabled { opacity: 0.3; cursor: not-allowed; }

.check-item { display: flex; align-items: center; gap: 1.2rem; padding: 1.2rem; border-radius: 16px; border: 1px solid var(--border); margin-bottom: 1rem; }
.check-item.ok { background: #f0fdf4; border-color: #bbf7d0; }
.check-item.err { background: #fef2f2; border-color: #fecaca; }

.preview-segment { padding: 1.2rem; border-left: 6px solid var(--border); background: #fff; margin-bottom: 0.8rem; border-radius: 0 12px 12px 0; box-shadow: var(--shadow-sm); }
.preview-segment.pres { border-left-color: #94a3b8; }
.preview-segment.prep { border-left-color: #64748b; }
.preview-segment.entr { border-left-color: #475569; }

/* --- Step 3 Validation Banner --- */
.validation-confirm-banner {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 1.5rem 2rem; border-radius: 16px; margin-bottom: 2rem;
  border: 2px solid transparent;
}
.validation-confirm-banner.ok {
  background: #f0fdf4; border-color: #86efac;
}
.validation-confirm-banner.err {
  background: #fffbeb; border-color: #fde68a;
}
.confirm-icon { font-size: 2.5rem; flex-shrink: 0; }
.confirm-text { display: flex; flex-direction: column; gap: 4px; }
.confirm-text strong { font-size: 1.15rem; font-weight: 800; color: #1e293b; }
.confirm-text span { font-size: 0.9rem; color: #475569; }

/* --- PDF Notice --- */
.pdf-notice {
  background: #fefce8; border: 1px solid #fde68a; border-left: 4px solid #f59e0b;
  padding: 1rem 1.25rem; border-radius: 8px; margin: 1.5rem 0 1rem;
  font-size: 0.85rem; color: #92400e; line-height: 1.6; font-style: italic;
}
.pdf-zone { margin-top: 1rem; }
