/* ============================================================
   TrésoPass — Feuille de style principale
   ============================================================ */

/* ------------------------------------------------------------
   0. VARIABLES CSS
   ------------------------------------------------------------ */
:root {
    --font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #7c3aed;
    --success: #16a34a;
    --warning: #d97706;
    --error: #dc2626;
    --info: #0284c7;
    --success-light: #dcfce7;
    --warning-light: #fef3c7;
    --error-light: #fee2e2;
    --info-light: #e0f2fe;
    --bg: #f6f7fb;
    --bg-card: #ffffff;
    --bg-sidebar: #111827;
    --bg-sidebar-hover: #1f2937;
    --text: #172033;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --border: #e5e7eb;
    --border-strong: #cbd5e1;
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 8px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, .10);
    --shadow-xl: 0 18px 60px rgba(15, 23, 42, .18);
    --transition: .18s ease;
    --sidebar-w: 260px;
    --header-h: 68px;
    --content-max: 1120px;
}

/* ------------------------------------------------------------
   1. RESET & BASE
   ------------------------------------------------------------ */
*, *::before, *::after {
    box-sizing: border-box;
    margin:     0;
    padding:    0;
}

html {
    font-size:   16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family:      var(--font);
    font-size:        1rem;
    line-height:      1.6;
    color:            var(--text);
    background-color: var(--bg);
    min-height:       100vh;
}

img, video {
    max-width: 100%;
    height:    auto;
    display:   block;
}

a {
    color:           var(--primary);
    text-decoration: none;
    transition:      color var(--transition);
}
a:hover { color: var(--primary-dark); text-decoration: underline; }

button { font-family: inherit; cursor: pointer; }

ul, ol { padding-left: 1.5rem; }

hr {
    border:     none;
    border-top: 1px solid var(--border);
    margin:     1.5rem 0;
}

code, pre {
    font-family: var(--font-mono);
    font-size:   0.875em;
}

code {
    background: var(--border);
    padding:    0.15em 0.4em;
    border-radius: var(--radius-sm);
}

/* ------------------------------------------------------------
   2. LAYOUT PRINCIPAL (sidebar + content)
   ------------------------------------------------------------ */
.app-layout {
    display:    flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width:      var(--sidebar-w);
    background: var(--bg-sidebar);
    color:      #e2e8f0;
    display:    flex;
    flex-direction: column;
    position:   fixed;
    top:        0; left: 0; bottom: 0;
    z-index:    100;
    transition: transform var(--transition);
    overflow-y: auto;
}

.sidebar-logo {
    display:     flex;
    align-items: center;
    gap:         0.75rem;
    padding:     1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
    font-weight: 700;
    font-size:   1.1rem;
    color:       #fff;
    text-decoration: none;
}
.sidebar-logo:hover { text-decoration: none; color: #fff; }
.sidebar-logo span { font-size: 1.5rem; }

.sidebar-section {
    padding: 1rem 0.75rem 0.5rem;
}
.sidebar-section-title {
    font-size:      0.7rem;
    font-weight:    600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color:          #64748b;
    padding:        0 0.75rem 0.5rem;
}

.sidebar-nav { list-style: none; padding: 0; }
.sidebar-nav li { margin: 2px 0; }
.sidebar-nav a {
    display:       flex;
    align-items:   center;
    gap:           0.65rem;
    padding:       0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    color:         #cbd5e1;
    font-size:     0.9rem;
    transition:    background var(--transition), color var(--transition);
    text-decoration: none;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--bg-sidebar-hover);
    color:      #fff;
    text-decoration: none;
}
.sidebar-nav a .nav-icon { font-size: 1rem; min-width: 1.2rem; text-align: center; }
.sidebar-nav a .nav-badge {
    margin-left:  auto;
    background:   var(--primary);
    color:        #fff;
    font-size:    0.7rem;
    padding:      0.1em 0.5em;
    border-radius: 99px;
    font-weight:  600;
}

.sidebar-footer {
    margin-top:  auto;
    padding:     1rem 0.75rem;
    border-top:  1px solid rgba(255,255,255,.08);
    font-size:   0.8rem;
    color:       #64748b;
}
.sidebar-user {
    display:     flex;
    align-items: center;
    gap:         0.6rem;
    margin-bottom: 0.75rem;
}
.sidebar-avatar {
    width:           34px;
    height:          34px;
    border-radius:   50%;
    background:      var(--primary);
    color:           #fff;
    display:         flex;
    align-items:     center;
    justify-content: center;
    font-weight:     700;
    font-size:       0.85rem;
    flex-shrink:     0;
}

/* ---- Zone principale ---- */
.main-wrapper {
    margin-left:  var(--sidebar-w);
    flex:         1;
    display:      flex;
    flex-direction: column;
    min-height:   100vh;
}

/* ---- Header ---- */
.main-header {
    height:          var(--header-h);
    background:      var(--bg-card);
    border-bottom:   1px solid var(--border);
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    padding:         0 2rem;
    position:        sticky;
    top:             0;
    z-index:         90;
    gap:             1rem;
}

.header-left { display: flex; align-items: center; gap: 1rem; }
.header-title { font-weight: 600; font-size: 1rem; color: var(--text); }
.header-subtitle { font-size: 0.8rem; color: var(--text-muted); }

.header-right {
    display:     flex;
    align-items: center;
    gap:         0.75rem;
}

/* Bouton menu mobile */
.menu-toggle {
    display:         none;
    background:      none;
    border:          none;
    font-size:       1.4rem;
    color:           var(--text);
    padding:         0.25rem;
    border-radius:   var(--radius-sm);
    cursor:          pointer;
}

/* ---- Contenu ---- */
.main-content {
    flex:    1;
    padding: 2rem;
    max-width: calc(var(--content-max) + 4rem);
    width: 100%;
    margin: 0 auto;
}

.main-content.wide { max-width: 1200px; }

/* ---- Footer ---- */
.main-footer {
    padding:      1rem 2rem;
    border-top:   1px solid var(--border);
    text-align:   center;
    font-size:    0.8rem;
    color:        var(--text-muted);
    background:   var(--bg-card);
}

/* Navigation utilisée par les pages actuelles */
.navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    min-height: 68px;
    padding: .85rem 2rem;
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
}
.navbar-brand a,
.navbar-user {
    display: flex;
    align-items: center;
    gap: .7rem;
}
.navbar-brand a {
    color: var(--text);
    font-weight: 800;
    text-decoration: none;
}
.brand-emoji { font-size: 1.45rem; }
.brand-name { letter-spacing: 0; }
.navbar-user { flex-wrap: wrap; justify-content: flex-end; }
.user-greeting { color: var(--text-muted); font-size: .9rem; }
.role-badge {
    display: inline-flex;
    margin-left: .4rem;
    padding: .15rem .45rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
}
.role-trainer { background: #ede9fe; color: #5b21b6; }
.role-student { background: #dbeafe; color: #1d4ed8; }

.footer {
    margin-top: 2rem;
    padding: 1.25rem 2rem;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: .85rem;
}
.footer-inner {
    max-width: var(--content-max);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.hero {
    margin: -2rem -2rem 2rem;
    padding: 3rem 2rem;
    background: linear-gradient(135deg, #0f766e 0%, #2563eb 58%, #4338ca 100%);
    color: #fff;
}
.hero-inner {
    max-width: var(--content-max);
    margin: 0 auto;
}
.hero h1 {
    font-size: clamp(1.9rem, 4vw, 3rem);
    line-height: 1.1;
    margin-bottom: .75rem;
}
.hero-sub {
    max-width: 720px;
    margin-bottom: 1.25rem;
    color: rgba(255,255,255,.86);
}
.quick-links,
.tutorials-section,
.category-block {
    margin-bottom: 2rem;
}
.section-header,
.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.section-header p {
    color: var(--text-muted);
    margin-top: .2rem;
}
.home-page .quick-links-grid {
    padding: 0;
}
.home-page .quick-link-card {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.home-page .quick-link-card:hover {
    color: var(--text);
    border-color: var(--primary);
    background: #fff;
}
.category-title {
    margin: 1rem 0;
    font-size: 1rem;
    color: var(--text-muted);
}
.tutorials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}
.tutorial-card {
    display: flex;
    gap: 1rem;
    padding: 1.1rem;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
}
.tutorial-card:hover {
    text-decoration: none;
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}
.tc-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    background: #eef2ff;
    font-size: 1.4rem;
    flex: 0 0 auto;
}
.tc-body h4 { margin-bottom: .25rem; }
.tc-body p { color: var(--text-muted); font-size: .9rem; margin-bottom: .75rem; }
.tc-meta {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    color: var(--text-muted);
    font-size: .78rem;
    margin-bottom: .5rem;
}
.progress-bar-mini,
.global-progress-bar {
    position: relative;
    overflow: hidden;
    height: 10px;
    border-radius: 999px;
    background: #e2e8f0;
}
.progress-bar-fill,
.global-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #0f766e, var(--primary));
    border-radius: inherit;
    transition: width var(--transition);
}
.global-progress-bar {
    height: 24px;
}
.global-progress-pct {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: .78rem;
    font-weight: 800;
}
.global-progress-label {
    margin-top: .45rem;
    color: var(--text-muted);
    text-align: center;
    font-size: .86rem;
}

.tutorial-main {
    max-width: 940px;
    margin: 0 auto;
    padding: 2rem;
}
.tutorial-header {
    margin-bottom: 1.5rem;
}
.back-link {
    display: inline-flex;
    margin-bottom: .8rem;
    color: var(--text-muted);
}
.steps-container {
    margin-top: 1.5rem;
}
.step-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}
.step-hidden { display: none; }
.step-done { display: none; }
.step-enter { animation: slideDown .25s ease; }
.step-type-badge,
.badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .22rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
}
.step-type-badge {
    margin-bottom: .75rem;
    background: #eef2ff;
    color: #3730a3;
}
.step-title {
    margin-bottom: 1rem;
    font-size: 1.45rem;
}
.step-content {
    margin-bottom: 1.25rem;
}
.step-content > * + * {
    margin-top: .75rem;
}
.info-table,
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.info-table th,
.info-table td,
.data-table th,
.data-table td {
    padding: .75rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}
.data-table th {
    background: #f8fafc;
    font-size: .78rem;
    color: var(--text-muted);
    text-transform: uppercase;
}
.table-wrap {
    overflow-x: auto;
}
.example-box,
.warning-box,
.info-box {
    padding: .9rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #f8fafc;
}
.warning-box { background: var(--warning-light); border-color: #fcd34d; }
.info-box { background: var(--info-light); border-color: #7dd3fc; }
.step-checklist,
.step-links {
    margin: 1.25rem 0;
}
.checklist-item {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    padding: .75rem;
    margin-top: .5rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
}
.checklist-item.checked {
    border-color: #86efac;
    background: var(--success-light);
}
.checklist-warning {
    color: #92400e;
    background: var(--warning-light);
    border-radius: var(--radius);
    padding: .75rem;
    margin-top: 1rem;
}
.step-navigation,
.modal-actions,
.actions-cell {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .65rem;
    flex-wrap: wrap;
}
.steps-dots {
    display: flex;
    justify-content: center;
    gap: .45rem;
    margin: 1rem 0;
}
.step-dot {
    width: 12px;
    height: 12px;
    border: 0;
    border-radius: 999px;
    background: #cbd5e1;
}
.dot-active { background: var(--primary); }
.dot-done { background: var(--success); }
.final-screen {
    text-align: center;
    padding: 1rem 0;
}
.final-trophy {
    font-size: 3rem;
}
.confetti-wrap {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}
.confetti-piece {
    position: absolute;
    top: -2rem;
    animation: confettiFall 3.4s ease-in forwards;
}
@keyframes confettiFall {
    to { transform: translateY(520px) rotate(360deg); opacity: 0; }
}
.content-preview {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: #f8fafc;
}
.checklist-edit-item,
.links-edit-item,
.form-inline-grid {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
    gap: .6rem;
    align-items: end;
    margin-top: .6rem;
}
.form-inline-grid {
    grid-template-columns: repeat(4, minmax(160px, 1fr));
}
.steps-edit-list {
    display: grid;
    gap: .7rem;
    margin-bottom: 1rem;
}
.step-edit-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
}
.step-edit-item.dragging {
    opacity: .65;
}
.step-edit-handle {
    color: var(--text-muted);
    cursor: grab;
}
.step-edit-info {
    flex: 1;
    display: grid;
    gap: .25rem;
}
.badge-success { background: var(--success-light); color: #166534; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-error { background: var(--error-light); color: #991b1b; }
.badge-type-prerequisites,
.badge-prerequisites { background: #ecfeff; color: #155e75; }
.badge-type-action,
.badge-action { background: #eef2ff; color: #3730a3; }
.badge-type-info,
.badge-info { background: var(--info-light); color: #075985; }
.badge-type-final,
.badge-final { background: #fef3c7; color: #92400e; }

@media (max-width: 760px) {
    .navbar,
    .footer-inner,
    .page-header,
    .section-header-row {
        align-items: flex-start;
        flex-direction: column;
    }
    .main-content,
    .tutorial-main {
        padding: 1rem;
    }
    .hero {
        margin: -1rem -1rem 1.5rem;
    }
    .checklist-edit-item,
    .links-edit-item,
    .form-inline-grid {
        grid-template-columns: 1fr;
    }
    .step-edit-item {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* ------------------------------------------------------------
   3. PAGE D'ACCUEIL (pas de sidebar)
   ------------------------------------------------------------ */
.landing-page {
    background: linear-gradient(135deg, #1e3a5f 0%, #1e293b 50%, #0f172a 100%);
    min-height: 100vh;
    display:    flex;
    flex-direction: column;
}

.landing-header {
    display:         flex;
    justify-content: space-between;
    align-items:     center;
    padding:         1.5rem 3rem;
    border-bottom:   1px solid rgba(255,255,255,.08);
}
.landing-logo {
    font-size:   1.4rem;
    font-weight: 800;
    color:       #fff;
    display:     flex;
    align-items: center;
    gap:         0.6rem;
    text-decoration: none;
}
.landing-logo:hover { text-decoration: none; color: #fff; }

.landing-hero {
    flex:            1;
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    justify-content: center;
    text-align:      center;
    padding:         4rem 2rem;
    gap:             1.5rem;
}
.landing-hero h1 {
    font-size:   clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    color:       #fff;
    line-height: 1.15;
    max-width:   700px;
}
.landing-hero h1 span { color: #60a5fa; }
.landing-hero p {
    font-size: clamp(1rem, 2vw, 1.2rem);
    color:     #94a3b8;
    max-width: 540px;
}

.landing-cta {
    display:   flex;
    gap:       1rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 1rem;
}

/* Grille de liens utiles */
.quick-links-grid {
    display:               grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap:                   1rem;
    padding:               2rem 3rem 3rem;
    max-width:             1000px;
    margin:                0 auto;
    width:                 100%;
}
.quick-link-card {
    background:    rgba(255,255,255,.05);
    border:        1px solid rgba(255,255,255,.1);
    border-radius: var(--radius-lg);
    padding:       1.5rem 1rem;
    text-align:    center;
    color:         #e2e8f0;
    text-decoration: none;
    transition:    background var(--transition), transform var(--transition), border-color var(--transition);
    display:       flex;
    flex-direction: column;
    align-items:   center;
    gap:           0.6rem;
}
.quick-link-card:hover {
    background:     rgba(255,255,255,.1);
    border-color:   rgba(255,255,255,.25);
    transform:      translateY(-3px);
    text-decoration: none;
    color:          #fff;
}
.quick-link-card .ql-icon { font-size: 2rem; }
.quick-link-card .ql-label { font-weight: 600; font-size: 0.9rem; }
.quick-link-card .ql-desc  { font-size: 0.75rem; color: #64748b; }

/* ------------------------------------------------------------
   4. PAGE DE CONNEXION
   ------------------------------------------------------------ */
.login-page {
    min-height:      100vh;
    display:         flex;
    align-items:     center;
    justify-content: center;
    background:      linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
    padding:         1.5rem;
}

.login-card {
    background:    var(--bg-card);
    border-radius: var(--radius-lg);
    padding:       2.5rem;
    width:         100%;
    max-width:     420px;
    box-shadow:    var(--shadow-xl);
}

.login-card .login-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}
.login-card .login-logo .logo-icon { font-size: 3rem; }
.login-card .login-logo h1         { font-size: 1.5rem; font-weight: 800; margin-top: 0.5rem; }
.login-card .login-logo p          { color: var(--text-muted); font-size: 0.875rem; }

/* ------------------------------------------------------------
   5. BOUTONS
   ------------------------------------------------------------ */
.btn {
    display:         inline-flex;
    align-items:     center;
    justify-content: center;
    gap:             0.4rem;
    padding:         0.6rem 1.25rem;
    font-size:       0.9rem;
    font-weight:     500;
    border-radius:   var(--radius);
    border:          2px solid transparent;
    cursor:          pointer;
    transition:      background var(--transition), color var(--transition),
                     border-color var(--transition), transform 0.1s, box-shadow var(--transition);
    text-decoration: none;
    white-space:     nowrap;
    font-family:     inherit;
    line-height:     1.4;
    user-select:     none;
}
.btn:hover         { text-decoration: none; transform: translateY(-1px); }
.btn:active        { transform: translateY(0); }
.btn:disabled      { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; box-shadow: 0 4px 12px rgba(37,99,235,.35); }

.btn-secondary  { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: #6d28d9; color: #fff; }

.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; color: #fff; }

.btn-danger   { background: var(--error); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }

.btn-warning  { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #b45309; color: #fff; }

.btn-outline {
    background:   transparent;
    border-color: var(--border-strong);
    color:        var(--text);
}
.btn-outline:hover {
    background:  var(--bg);
    border-color: var(--primary);
    color:        var(--primary);
}

.btn-ghost {
    background:   transparent;
    border-color: transparent;
    color:        var(--text-muted);
}
.btn-ghost:hover { background: var(--border); color: var(--text); }

.btn-sm  { padding: 0.35rem 0.8rem;  font-size: 0.8rem;  }
.btn-lg  { padding: 0.85rem 1.75rem; font-size: 1.05rem; }
.btn-xl  { padding: 1rem 2.2rem;     font-size: 1.15rem; border-radius: var(--radius-lg); }

.btn-block { width: 100%; }

.btn-icon {
    padding: 0.5rem;
    border-radius: 50%;
    min-width: 36px;
    min-height: 36px;
}

/* ------------------------------------------------------------
   6. FORMULAIRES
   ------------------------------------------------------------ */
.form-group {
    display:        flex;
    flex-direction: column;
    gap:            0.4rem;
    margin-bottom:  1.25rem;
}
.form-group:last-of-type { margin-bottom: 0; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

label {
    font-size:   0.875rem;
    font-weight: 600;
    color:       var(--text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="search"],
select,
textarea {
    width:         100%;
    padding:       0.6rem 0.9rem;
    font-size:     0.9rem;
    font-family:   inherit;
    line-height:   1.5;
    color:         var(--text);
    background:    var(--bg-card);
    border:        1.5px solid var(--border-strong);
    border-radius: var(--radius);
    transition:    border-color var(--transition), box-shadow var(--transition);
    outline:       none;
    appearance:    none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow:   0 0 0 3px rgba(37,99,235,.12);
}
input::placeholder, textarea::placeholder { color: var(--text-light); }

textarea { resize: vertical; min-height: 120px; }

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat:   no-repeat;
    background-position: right 0.8rem center;
    padding-right:       2.2rem;
}

.form-hint {
    font-size:  0.78rem;
    color:      var(--text-muted);
    margin-top: 0.15rem;
}

.form-error {
    font-size:  0.8rem;
    color:      var(--error);
    font-weight: 500;
}

/* Checkbox personnalisé */
.checkbox-label {
    display:     flex;
    align-items: flex-start;
    gap:         0.6rem;
    cursor:      pointer;
    font-weight: 400;
    font-size:   0.9rem;
    user-select: none;
}
.checkbox-label input[type="checkbox"] {
    width:         18px;
    height:        18px;
    min-width:     18px;
    border-radius: 4px;
    accent-color:  var(--primary);
    margin-top:    2px;
    cursor:        pointer;
}

/* ------------------------------------------------------------
   7. ALERTES
   ------------------------------------------------------------ */
.alert {
    display:       flex;
    align-items:   flex-start;
    gap:           0.75rem;
    padding:       0.9rem 1rem;
    border-radius: var(--radius);
    font-size:     0.875rem;
    margin-bottom: 1rem;
    border:        1px solid transparent;
    animation:     slideDown 0.3s ease;
    line-height:   1.5;
}
.alert-success { background: var(--success-light); border-color: #86efac; color: #166534; }
.alert-error   { background: var(--error-light);   border-color: #fca5a5; color: #991b1b; }
.alert-warning { background: var(--warning-light); border-color: #fcd34d; color: #92400e; }
.alert-info    { background: var(--info-light);    border-color: #7dd3fc; color: #075985; }

.alert-dismissible {
    justify-content: space-between;
}
.alert-close {
    background: none;
    border:     none;
    cursor:     pointer;
    color:      inherit;
    opacity:    0.6;
    font-size:  1rem;
    flex-shrink: 0;
    padding:    0;
    line-height: 1;
}
.alert-close:hover { opacity: 1; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------
   8. CARTES ET SECTIONS
   ------------------------------------------------------------ */
.dashboard-section {
    background:    var(--bg-card);
    border:        1px solid var(--border);
    border-radius: var(--radius-lg);
    padding:       1.75rem;
    margin-bottom: 1.5rem;
    box-shadow:    var(--shadow);
}
.dashboard-section h2 {
    font-size:     1.1rem;
    font-weight:   700;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    display:       flex;
    align-items:   center;
    gap:           0.5rem;
}

.card {
    background:    var(--bg-card);
    border:        1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow:    var(--shadow);
    overflow:      hidden;
    transition:    box-shadow var(--transition), transform var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-header {
    padding:       1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display:       flex;
    align-items:   center;
    justify-content: space-between;
    gap:           1rem;
}
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-body      { padding: 1.5rem; }
.card-footer    { padding: 1rem 1.5rem; border-top: 1px solid var(--border); background: var(--bg); }

/* Page header (titre + actions) */
.page-header {
    display:         flex;
    justify-content: space-between;
    align-items:     flex-start;
    gap:             1rem;
    margin-bottom:   1.75rem;
    flex-wrap:       wrap;
}
.page-header h1 {
    font-size:   1.6rem;
    font-weight: 800;
    line-height: 1.2;
}
.page-header p {
    color:     var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* Grille de stats */
.stats-grid {
    display:               grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap:                   1rem;
    margin-bottom:         1.5rem;
}
.stat-card {
    background:    var(--bg-card);
    border:        1px solid var(--border);
    border-radius: var(--radius-lg);
    padding:       1.25rem;
    box-shadow:    var(--shadow);
    display:       flex;
    align-items:   center;
    gap:           1rem;
}
.stat-icon {
    font-size:       1.75rem;
    width:           52px;
    height:          52px;
    border-radius:   var(--radius);
    display:         flex;
    align-items:     center;
    justify-content: center;
    flex-shrink:     0;
}
.stat-icon.blue   { background: var(--primary-light); }
.stat-icon.green  { background: var(--success-light); }
.stat-icon.purple { background: var(--secondary-light); }
.stat-icon.yellow { background: var(--warning-light); }

.stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ------------------------------------------------------------
   9. TABLEAUX
   ------------------------------------------------------------ */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

table {
    width:           100%;
    border-collapse: collapse;
    font-size:       0.875rem;
}

thead th {
    background:    var(--bg);
    padding:       0.75rem 1rem;
    text-align:    left;
    font-weight:   600;
    font-size:     0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color:         var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space:   nowrap;
}

tbody td {
    padding:       0.8rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover         { background: var(--bg); }

/* ------------------------------------------------------------
   10. BADGES
   ------------------------------------------------------------ */
.badge {
    display:       inline-flex;
    align-items:   center;
    gap:           0.25rem;
    padding:       0.2em 0.65em;
    border-radius: 99px;
    font-size:     0.75rem;
    font-weight:   600;
    white-space:   nowrap;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-error   { background: var(--error-light);   color: var(--error);   }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info    { background: var(--info-light);    color: var(--info);    }
.badge-gray    { background: var(--border);        color: var(--text-muted); }
.badge-primary { background: var(--primary-light); color: var(--primary); }

/* ------------------------------------------------------------
   11. BARRE DE PROGRESSION (tutoriel)
   ------------------------------------------------------------ */
.progress-bar-wrap {
    position:      sticky;
    bottom:        0;
    z-index:       80;
    background:    var(--bg-card);
    border-top:    1px solid var(--border);
    padding:       0.85rem 1.5rem;
    display:       flex;
    align-items:   center;
    gap:           1rem;
    box-shadow:    0 -2px 10px rgba(0,0,0,.06);
}

.progress-meta {
    display:    flex;
    align-items: center;
    gap:         0.5rem;
    flex-shrink: 0;
    font-size:   0.82rem;
    color:       var(--text-muted);
    min-width:   120px;
}
.progress-meta strong { color: var(--text); font-weight: 700; }

.progress-track {
    flex:          1;
    height:        10px;
    background:    var(--border);
    border-radius: 99px;
    overflow:      hidden;
    position:      relative;
}
.progress-fill {
    height:        100%;
    background:    linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 99px;
    transition:    width 0.5s cubic-bezier(.4,0,.2,1);
    min-width:     4px;
}

.progress-pct {
    font-weight:  700;
    font-size:    0.9rem;
    color:        var(--primary);
    min-width:    42px;
    text-align:   right;
    flex-shrink:  0;
}

/* ------------------------------------------------------------
   12. ÉTAPES DE TUTORIEL (step-cards)
   ------------------------------------------------------------ */
.steps-container { padding-bottom: 100px; }

.step-card {
    background:    var(--bg-card);
    border:        1px solid var(--border);
    border-radius: var(--radius-lg);
    padding:       2rem;
    margin-bottom: 1rem;
    box-shadow:    var(--shadow);
}

/* Masquage / affichage */
.step-hidden { display: none; }
.step-done   { display: none; }
.step-active { display: block; }

/* Animation d'entrée */
.step-enter {
    animation: stepSlideIn 0.35s cubic-bezier(.4,0,.2,1);
}
@keyframes stepSlideIn {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* En-tête de l'étape */
.step-header {
    display:       flex;
    align-items:   center;
    gap:           1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.step-icon {
    font-size:       1.75rem;
    width:           54px;
    height:          54px;
    border-radius:   var(--radius-lg);
    display:         flex;
    align-items:     center;
    justify-content: center;
    flex-shrink:     0;
}
.step-icon.type-prerequisites { background: var(--info-light);     }
.step-icon.type-info          { background: var(--primary-light);  }
.step-icon.type-action        { background: var(--warning-light);  }
.step-icon.type-final         { background: var(--success-light);  }

.step-title-wrap h2 {
    font-size:   1.25rem;
    font-weight: 700;
}
.step-type-label {
    font-size:   0.75rem;
    font-weight: 600;
    color:       var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Contenu de l'étape */
.step-content { margin-bottom: 1.5rem; line-height: 1.75; }
.step-content h3 { font-size: 1rem; font-weight: 700; margin: 1.25rem 0 0.4rem; }
.step-content h4 { font-size: 0.9rem; font-weight: 600; margin: 1rem 0 0.3rem; }
.step-content p  { margin-bottom: 0.75rem; }
.step-content ul,
.step-content ol { margin-bottom: 0.75rem; }
.step-content li { margin-bottom: 0.25rem; }
.step-content a  { color: var(--primary); }

/* Image illustrative */
.step-image {
    margin:        1.5rem 0;
    text-align:    center;
}
.step-image img {
    max-width:     100%;
    border-radius: var(--radius-lg);
    border:        2px solid var(--border);
    box-shadow:    var(--shadow-md);
    cursor:        zoom-in;
    transition:    transform var(--transition);
}
.step-image img:hover { transform: scale(1.01); }
.step-image figcaption {
    font-size:  0.8rem;
    color:      var(--text-muted);
    margin-top: 0.5rem;
}

/* Lightbox image */
.lightbox-overlay {
    position:   fixed;
    inset:      0;
    background: rgba(0,0,0,.85);
    display:    flex;
    align-items: center;
    justify-content: center;
    z-index:    999;
    cursor:     zoom-out;
    animation:  fadeIn 0.2s ease;
}
.lightbox-overlay img {
    max-width:     92vw;
    max-height:    90vh;
    border-radius: var(--radius);
    box-shadow:    var(--shadow-xl);
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Checklist prérequis */
.checklist-list { list-style: none; padding: 0; margin: 1rem 0; }
.checklist-item {
    display:       flex;
    align-items:   flex-start;
    gap:           0.75rem;
    padding:       0.85rem 1rem;
    border:        1.5px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    cursor:        pointer;
    transition:    background var(--transition), border-color var(--transition);
}
.checklist-item:hover { background: var(--bg); border-color: var(--primary); }
.checklist-item.checked {
    background:   var(--success-light);
    border-color: #86efac;
}
.checklist-item input[type="checkbox"] {
    width:  20px;
    height: 20px;
    min-width: 20px;
    margin-top: 1px;
    accent-color: var(--success);
    cursor: pointer;
}
.checklist-item-label {
    flex:        1;
    font-size:   0.9rem;
    line-height: 1.5;
}
.checklist-item-link {
    font-size:   0.78rem;
    color:       var(--primary);
    white-space: nowrap;
}
.checklist-progress-text {
    font-size:   0.82rem;
    color:       var(--text-muted);
    margin-top:  0.5rem;
    font-style:  italic;
}
.checklist-warning {
    color:         var(--error);
    font-size:     0.875rem;
    font-weight:   500;
    padding:       0.6rem 0.9rem;
    background:    var(--error-light);
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
    display:       none;
}
.checklist-warning.shake {
    animation: shake 0.5s ease;
}
@keyframes shake {
    0%,100% { transform: translateX(0); }
    20%     { transform: translateX(-6px); }
    40%     { transform: translateX(6px); }
    60%     { transform: translateX(-4px); }
    80%     { transform: translateX(4px); }
}

/* Liens utiles dans les étapes */
.step-links {
    display:   flex;
    flex-wrap: wrap;
    gap:       0.5rem;
    margin:    1rem 0;
}
.step-link-btn {
    display:       inline-flex;
    align-items:   center;
    gap:           0.4rem;
    padding:       0.45rem 0.9rem;
    background:    var(--primary-light);
    color:         var(--primary);
    border:        1px solid #bfdbfe;
    border-radius: var(--radius);
    font-size:     0.82rem;
    font-weight:   600;
    text-decoration: none;
    transition:    background var(--transition);
}
.step-link-btn:hover {
    background: var(--primary);
    color:      #fff;
    text-decoration: none;
}

/* Boutons navigation étape */
.step-actions {
    display:         flex;
    gap:             0.75rem;
    align-items:     center;
    flex-wrap:       wrap;
    justify-content: space-between;
    padding-top:     1.25rem;
    border-top:      1px solid var(--border);
    margin-top:      1rem;
}
.step-actions-right { display: flex; gap: 0.75rem; }

/* Étape finale */
.step-card[data-type="final"] {
    border:     2px solid #86efac;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    text-align: center;
    position:   relative;
    overflow:   hidden;
}
.step-final-emoji {
    font-size:   4rem;
    display:     block;
    margin:      1rem auto;
    animation:   bounce 1s ease infinite;
}
@keyframes bounce {
    0%,100% { transform: translateY(0); }
    50%     { transform: translateY(-12px); }
}
.step-final-title {
    font-size:   2rem;
    font-weight: 800;
    color:       var(--success);
    margin:      0.5rem 0;
}

/* Confetti animation */
.confetti-wrap {
    position:  absolute;
    inset:     0;
    pointer-events: none;
    overflow:  hidden;
}
.confetti-piece {
    position:  absolute;
    top:       -40px;
    animation: confettiFall 3s ease-in forwards;
}
@keyframes confettiFall {
    to { top: 110%; opacity: 0; transform: rotate(360deg); }
}

/* ------------------------------------------------------------
   13. INTERFACE FORMATEUR — Éditeur tuto/étapes
   ------------------------------------------------------------ */
.edit-form h2 {
    font-size:     1rem;
    font-weight:   700;
    color:         var(--text);
    margin-bottom: 1.25rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border);
}

.content-preview {
    margin-top:    0.75rem;
    padding:       1rem 1.25rem;
    background:    var(--bg);
    border:        1px dashed var(--border-strong);
    border-radius: var(--radius);
    font-size:     0.9rem;
    line-height:   1.75;
    min-height:    60px;
}

.checklist-edit-item,
.links-edit-item {
    display:   flex;
    gap:       0.5rem;
    margin-bottom: 0.4rem;
    align-items: center;
    flex-wrap: wrap;
}
.checklist-edit-item input,
.links-edit-item input { flex: 1; min-width: 160px; }

.current-image-wrap { margin-bottom: 0.75rem; }

/* Drag & drop réordonnancement des étapes */
.steps-sortable { list-style: none; padding: 0; }

.step-sort-item {
    display:       flex;
    align-items:   center;
    gap:           0.75rem;
    background:    var(--bg-card);
    border:        1px solid var(--border);
    border-radius: var(--radius);
    padding:       0.75rem 1rem;
    margin-bottom: 0.4rem;
    cursor:        grab;
    transition:    box-shadow var(--transition), border-color var(--transition);
    user-select:   none;
}
.step-sort-item:active  { cursor: grabbing; box-shadow: var(--shadow-lg); }
.step-sort-item.dragging {
    opacity:        0.5;
    border-color:   var(--primary);
    border-style:   dashed;
}
.step-sort-item.drag-over {
    border-color:   var(--success);
    background:     var(--success-light);
}

.step-sort-handle { color: var(--text-light); font-size: 1.2rem; cursor: grab; }
.step-sort-info   { flex: 1; }
.step-sort-title  { font-weight: 600; font-size: 0.875rem; }
.step-sort-type   { font-size: 0.75rem; color: var(--text-muted); }
.step-sort-actions { display: flex; gap: 0.4rem; }

/* ------------------------------------------------------------
   14. MODALE DE CONFIRMATION
   ------------------------------------------------------------ */
.modal-overlay {
    position:   fixed;
    inset:      0;
    background: rgba(0,0,0,.5);
    display:    flex;
    align-items: center;
    justify-content: center;
    z-index:    500;
    padding:    1rem;
    animation:  fadeIn 0.15s ease;
}
.modal-box {
    background:    var(--bg-card);
    border-radius: var(--radius-lg);
    padding:       2rem;
    max-width:     440px;
    width:         100%;
    box-shadow:    var(--shadow-xl);
    animation:     slideDown 0.2s ease;
}
.modal-box h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: 0.75rem; }
.modal-box p  { color: var(--text-muted); margin-bottom: 1.5rem; line-height: 1.6; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; flex-wrap: wrap; }

/* ------------------------------------------------------------
   15. TOOLTIPS
   ------------------------------------------------------------ */
[data-tooltip] {
    position: relative;
}
[data-tooltip]::after {
    content:       attr(data-tooltip);
    position:      absolute;
    bottom:        calc(100% + 6px);
    left:          50%;
    transform:     translateX(-50%);
    background:    var(--text);
    color:         #fff;
    padding:       0.3em 0.7em;
    border-radius: var(--radius-sm);
    font-size:     0.75rem;
    white-space:   nowrap;
    pointer-events: none;
    opacity:       0;
    transition:    opacity 0.2s;
    z-index:       200;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ------------------------------------------------------------
   16. RESPONSIVE
   ------------------------------------------------------------ */
@media (max-width: 768px) {

    .main-wrapper { margin-left: 0; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    .sidebar.open { transform: translateX(0); }

    .menu-toggle { display: flex; }

    .sidebar-overlay {
        display:    block;
        position:   fixed;
        inset:      0;
        background: rgba(0,0,0,.45);
        z-index:    99;
        animation:  fadeIn 0.2s ease;
    }

    .main-content { padding: 1.25rem; }
    .main-header  { padding: 0 1.25rem; }

    .quick-links-grid { padding: 1.5rem; }
    .landing-header   { padding: 1rem 1.5rem; }

    .step-actions { flex-direction: column; align-items: stretch; }
    .step-actions-right { flex-direction: column; }
    .step-actions .btn  { width: 100%; justify-content: center; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    .form-row { grid-template-columns: 1fr; }

    .page-header { flex-direction: column; }

    .checklist-edit-item,
    .links-edit-item { flex-direction: column; }
    .checklist-edit-item input,
    .links-edit-item input { min-width: 100%; }

    .progress-bar-wrap { padding: 0.65rem 1rem; gap: 0.5rem; }
    .progress-meta { min-width: unset; }

    .login-card { padding: 1.75rem 1.25rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .landing-hero h1 { font-size: 1.75rem; }
    .step-card  { padding: 1.25rem; }
    .dashboard-section { padding: 1.25rem; }
    .modal-box { padding: 1.5rem; }
}

/* ------------------------------------------------------------
   17. UTILITAIRES
   ------------------------------------------------------------ */
.hidden       { display: none !important; }
.sr-only      { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-error   { color: var(--error); }
.text-warning { color: var(--warning); }
.fw-bold      { font-weight: 700; }
.fw-normal    { font-weight: 400; }
.mt-1  { margin-top: 0.5rem;  }
.mt-2  { margin-top: 1rem;    }
.mt-3  { margin-top: 1.5rem;  }
.mb-1  { margin-bottom: 0.5rem;  }
.mb-2  { margin-bottom: 1rem;    }
.mb-3  { margin-bottom: 1.5rem;  }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem;   }
.d-flex        { display: flex; }
.align-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap     { flex-wrap: wrap; }
.w-full        { width: 100%; }

/* Scrollbar personnalisée (Webkit) */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* Focus visible pour accessibilité */
:focus-visible {
    outline:        2px solid var(--primary);
    outline-offset: 2px;
}

/* Sélection */
::selection { background: var(--primary-light); color: var(--primary-dark); }
