/* ============ CURSANOVA APPRENTISSAGE — STYLES ============ */
/* Identité visuelle Cursanova : bleu profond + or
   Polices : Inter pour le texte, Manrope pour les titres */

:root {
  --c-bg: #f5f7fb;
  --c-surface: #ffffff;
  --c-surface-2: #fafbff;
  --c-border: #e5e9f2;
  --c-text: #0f172a;
  --c-text-muted: #475569;
  --c-text-soft: #64748b;
  --c-primary: #1e3a8a;
  --c-primary-dark: #172554;
  --c-primary-light: #e0e7ff;
  --c-accent: #c8a96a; /* or doux */
  --c-accent-dark: #a18649;
  --c-danger: #dc2626;
  --c-success: #059669;
  --c-warning: #d97706;
  --c-info: #0284c7;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 2px 8px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.08), 0 4px 8px rgba(15, 23, 42, 0.05);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============ BASE ============ */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  font-family: 'Manrope', 'Inter', sans-serif;
  font-weight: 700;
  color: var(--c-text);
  margin: 0;
  letter-spacing: -0.02em;
}

h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
h4 { font-size: 15px; }

a { color: var(--c-primary); text-decoration: none; }
a:hover { color: var(--c-primary-dark); }

/* ============ LAYOUT ============ */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--c-primary-dark) 0%, var(--c-primary) 100%);
  color: white;
  padding: 24px 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  padding: 0 24px 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 20px;
}

.sidebar-brand-logo {
  font-family: 'Manrope', sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}

.sidebar-brand-accent {
  color: var(--c-accent);
}

.sidebar-brand-tagline {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.6);
}

.sidebar-nav {
  padding: 0 12px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: rgba(255, 255, 255, 0.85);
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.sidebar-link.active {
  background: rgba(200, 169, 106, 0.18);
  color: white;
  font-weight: 600;
}

.sidebar-link-icon {
  width: 18px;
  height: 18px;
  opacity: 0.8;
}

.main {
  padding: 32px 40px;
  max-width: 100%;
  overflow-x: hidden;
}

.main-narrow {
  max-width: 1100px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 20px;
  flex-wrap: wrap;
}

.page-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.page-subtitle {
  color: var(--c-text-muted);
  font-size: 14px;
  margin-top: 4px;
}

/* ============ CARDS ============ */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 20px;
}

.card-elevated {
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.card-header h3 {
  margin: 0;
}

.card-section {
  padding: 16px 0;
  border-top: 1px solid var(--c-border);
}

.card-section:first-of-type {
  border-top: none;
  padding-top: 0;
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--c-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--c-primary-dark);
  color: white;
}

.btn-accent {
  background: var(--c-accent);
  color: var(--c-primary-dark);
}

.btn-accent:hover {
  background: var(--c-accent-dark);
  color: white;
}

.btn-secondary {
  background: var(--c-surface);
  color: var(--c-text);
  border-color: var(--c-border);
}

.btn-secondary:hover {
  background: var(--c-surface-2);
  border-color: #cbd5e1;
}

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

.btn-ghost:hover {
  background: var(--c-surface-2);
  color: var(--c-text);
}

.btn-danger {
  background: var(--c-danger);
  color: white;
}

.btn-danger:hover {
  background: #b91c1c;
  color: white;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
}

.btn-full {
  width: 100%;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
}

/* ============ FORMS ============ */
.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
  .form-row-2, .form-row-3, .form-row-4 {
    grid-template-columns: 1fr;
  }
}

.label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.label-hint {
  font-weight: 400;
  color: var(--c-text-soft);
  font-size: 12px;
  margin-left: 4px;
}

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: white;
  color: var(--c-text);
  transition: all var(--transition);
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.input[readonly], .input[disabled] {
  background: var(--c-surface-2);
  cursor: not-allowed;
  color: var(--c-text-muted);
}

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

.checkbox-group, .radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.checkbox-label, .radio-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}

.checkbox-label input, .radio-label input {
  width: 16px;
  height: 16px;
  accent-color: var(--c-primary);
}

.help {
  font-size: 12px;
  color: var(--c-text-soft);
  margin-top: 4px;
  font-style: italic;
}

.form-error {
  color: var(--c-danger);
  font-size: 12px;
  margin-top: 4px;
}

/* ============ IA BADGE / TOOLTIP ============ */
/* Petite icône IA à côté d'un champ pré-rempli automatiquement,
   au hover : affiche la justification du choix */
.ia-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, var(--c-accent) 0%, var(--c-primary) 100%);
  color: white;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  position: relative;
  user-select: none;
}

.ia-badge::before {
  content: "AI";
}

.ia-badge:hover .ia-tooltip {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.ia-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--c-primary-dark);
  color: white;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.5;
  font-weight: 400;
  width: 280px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition);
  text-align: left;
  box-shadow: var(--shadow-lg);
}

.ia-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: var(--c-primary-dark) transparent transparent transparent;
}

.ia-tooltip-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--c-accent);
}

/* ============ STATUS BADGES ============ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-neutral { background: #e2e8f0; color: #475569; }
.badge-accent { background: rgba(200, 169, 106, 0.18); color: var(--c-accent-dark); }

/* ============ TABLES ============ */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-text-soft);
  padding: 10px 16px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface-2);
}

.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--c-border);
  font-size: 14px;
  vertical-align: middle;
}

.table tr:hover td {
  background: var(--c-surface-2);
}

.table tr:last-child td {
  border-bottom: none;
}

/* ============ SIGNATURE PAD ============ */
.signature-wrapper {
  border: 2px dashed var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface-2);
  padding: 8px;
  position: relative;
  transition: all var(--transition);
}

.signature-wrapper:hover {
  border-color: var(--c-primary);
  background: white;
}

.signature-canvas {
  display: block;
  width: 100%;
  height: 200px;
  background: white;
  border-radius: var(--radius-sm);
  cursor: crosshair;
  touch-action: none;
}

.signature-toolbar {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: space-between;
}

.signature-hint {
  text-align: center;
  color: var(--c-text-soft);
  font-size: 13px;
  font-style: italic;
  margin-top: 12px;
}

/* ============ ALERT ============ */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14px;
}

.alert-info { background: #eff6ff; color: #1e3a8a; border-left: 3px solid #3b82f6; }
.alert-success { background: #ecfdf5; color: #065f46; border-left: 3px solid #10b981; }
.alert-warning { background: #fffbeb; color: #92400e; border-left: 3px solid #f59e0b; }
.alert-danger { background: #fef2f2; color: #991b1b; border-left: 3px solid #ef4444; }

.alert-icon { flex-shrink: 0; font-size: 18px; }

/* ============ KPIs ============ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.kpi-card {
  background: white;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-text-soft);
  font-weight: 600;
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 800;
  font-family: 'Manrope', sans-serif;
  color: var(--c-text);
  letter-spacing: -0.02em;
}

.kpi-trend {
  font-size: 12px;
  color: var(--c-success);
  margin-top: 4px;
}

/* ============ MODAL ============ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 200ms ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 20px 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--c-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--c-text-muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

/* ============ STEPPER ============ */
.stepper {
  display: flex;
  align-items: center;
  margin-bottom: 32px;
  gap: 4px;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text-soft);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
}

.step-active {
  background: var(--c-primary);
  color: white;
  border-color: var(--c-primary);
}

.step-done {
  background: var(--c-primary-light);
  color: var(--c-primary-dark);
  border-color: var(--c-primary-light);
}

.step-line {
  flex: 1;
  height: 2px;
  background: var(--c-border);
  min-width: 20px;
}

.step-line-done {
  background: var(--c-primary);
}

/* ============ PUBLIC FORM LAYOUT (entreprise / élève / signature) ============ */
.public-shell {
  min-height: 100vh;
  background: linear-gradient(135deg, #f5f7fb 0%, #eef2f9 100%);
  padding: 32px 20px;
}

.public-wrapper {
  max-width: 800px;
  margin: 0 auto;
}

.public-header {
  text-align: center;
  margin-bottom: 32px;
}

.public-brand {
  font-family: 'Manrope', sans-serif;
  font-size: 32px;
  font-weight: 800;
  color: var(--c-primary-dark);
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.public-brand-accent {
  color: var(--c-accent);
}

.public-subtitle {
  color: var(--c-text-muted);
  font-size: 15px;
}

/* ============ EMPTY STATE ============ */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--c-text-soft);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: 8px;
}

.empty-description {
  font-size: 14px;
  max-width: 400px;
  margin: 0 auto 20px;
}

/* ============ COPY-LINK FIELD ============ */
.copy-field {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 12px;
}

.copy-field input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: inherit;
  color: var(--c-text-muted);
  outline: none;
}

/* ============ DIVIDER ============ */
.divider {
  height: 1px;
  background: var(--c-border);
  margin: 24px 0;
}

.section-title {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-primary);
  font-weight: 700;
  margin: 28px 0 14px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--c-primary-light);
}

.section-title:first-child {
  margin-top: 0;
}

/* ============ MOBILE ============ */
@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: relative;
    height: auto;
  }
  .main {
    padding: 20px;
  }
  h1 { font-size: 22px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}

/* ============ UTILITIES ============ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-muted { color: var(--c-text-muted); }
.text-soft { color: var(--c-text-soft); }
.text-success { color: var(--c-success); }
.text-warning { color: var(--c-warning); }
.text-danger { color: var(--c-danger); }
.text-primary { color: var(--c-primary); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.cursor-pointer { cursor: pointer; }
