/**
 * Slides System Custom CSS - Global Website Customization
 * Personnalisation globale pour toutes les présentations du site
 * Utilise Montserrat et un thème violet/orange avec décorations arc-en-ciel
 */

/* Import de la police Montserrat depuis Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;800&display=swap');

/* ========================================
   VARIABLES CSS - THÈME GLOBAL
   ======================================== */

:root {
    /* Couleurs principales */
    --primary-color: #5b2c6f;        /* Violet foncé */
    --secondary-color: #d35400;      /* Orange */
    --tertiary-color: #8e44ad;       /* Magenta/Violet clair */
    --background-color: #ffffff;
    --text-color: #2c3e50;
    
    /* Couleurs pour les cards */
    --card-blue: #3498db;
    --card-orange: #e67e22;
    --card-purple: #9b59b6;
    --card-green: #27ae60;
    --card-red: #e74c3c;
    
    /* Couleurs des bordures */
    --border-blue: #3498db;
    --border-orange: #f39c12;
    --border-purple: #a569bd;
    
    /* Arrière-plans */
    --card-bg: #ffffff;
    --card-shadow: 0 4px 15px rgba(0,0,0,0.08);
    --notice-bg: #fff9e6;
    --notice-border: #f39c12;
    
    /* Typographie - Montserrat */
    --font-family: 'Montserrat', 'Segoe UI', 'Roboto', 'Arial', sans-serif;
    --font-family-mono: 'Consolas', 'Monaco', 'Courier New', monospace;
    --font-size-base: 20px;
    --font-size-h1: 3em;
    --font-size-h2: 2.4em;
    --font-size-h3: 1.9em;
    
    /* Espacements optimisés */
    --spacing-small: 10px;
    --spacing-medium: 20px;
    --spacing-large: 35px;
    
    /* Effets */
    --border-radius: 16px;
    --transition-speed: 0.3s;
}

/* Appliquer Montserrat partout SAUF code */
body, html {
    font-family: var(--font-family);
}

h1, h2, h3, h4, h5, h6,
p, span, div, section,
ul, ol, li,
table, thead, tbody, td, th,
a, button,
.slide, .card, .notice {
    font-family: var(--font-family);
}

/* Code et pre utilisent TOUJOURS une police monospace */
code, pre, pre *, .csv-content, .csv-content * {
    font-family: var(--font-family-mono) !important;
}

/* ========================================
   PERSONNALISATION DES SLIDES
   ======================================== */

.slide {
    background-color: var(--background-color);
    padding: 40px 100px 40px 100px;
    position: relative;
    justify-content: flex-start !important;
    align-items: center !important;
    overflow: hidden;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: 100vh;
    gap: 10px;
}

/* Zone de sécurité pour éviter les décorations */
.slide > * {
    max-width: calc(100% - 40px);
}

/* Contenu texte ne shrink pas, images/tables prennent l'espace restant */
.slide > h1,
.slide > h2,
.slide > h3,
.slide > p,
.slide > ul,
.slide > ol,
.slide > pre,
.slide > .notice {
    flex-shrink: 0;
    flex-grow: 0;
}

/* Images, tables, schémas prennent l'espace disponible */
.slide > .schema,
.slide > img,
.slide > svg,
.slide > iframe,
.slide > table {
    flex: 1 1 auto;
    min-height: 0;
}

/* Décorations arc-en-ciel dans les coins avec deco.png */
.slide::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 180px;
    height: 180px;
    background-image: url('deco.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: top left;
    transform: rotate(90deg);
    opacity: 0.6;
    pointer-events: none;
    z-index: -1;
}

.slide::after {
    content: '';
    position: fixed;
    bottom: 0;
    right: 0;
    width: 180px;
    height: 180px;
    background-image: url('deco.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: bottom right;
    transform: rotate(270deg);
    opacity: 0.6;
    pointer-events: none;
    z-index: -1;
}

/* Assurer que tout le contenu est au-dessus des décorations */
.slide > *,
.slide > *:not(::before):not(::after) {
    position: relative;
    z-index: 10;
}

/* Container global pour éviter overlap */
.presentation-container {
    position: relative;
    z-index: 1;
}

/* ========================================
   TYPOGRAPHIE
   ======================================== */

/* Titres - toujours positionnés en haut avec Montserrat */
.slide h1, .slide h2.with-subtitle {
    font-size: var(--font-size-h1);
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: var(--spacing-medium);
    text-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-top: 0;
    width: 100%;
    letter-spacing: -0.5px;
    flex-shrink: 0;
}

.slide h2 {
    font-size: var(--font-size-h2);
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: var(--spacing-small);
    margin-top: 0;
    letter-spacing: -0.3px;
    flex-shrink: 0;
}

.slide h3 {
    font-size: var(--font-size-h3);
    font-weight: 600;
    color: var(--secondary-color);
    margin-bottom: var(--spacing-small);
    flex-shrink: 0;
}

.slide p {
    font-size: 1.25em;
    line-height: 1.7;
    margin-bottom: var(--spacing-small);
    color: var(--text-color);
    font-weight: 400;
}

/* Strong et bold */
strong, b {
    font-weight: 700;
    font-size: 1.45em;
}

/* Bold inside list items should inherit list size */
li strong, li b {
    font-size: inherit;
}

/* Italic */
em, i {
    font-weight: 400;
    font-style: italic;
}

/* Sous-titre stylisé */
.slide h2.with-subtitle::after {
    content: '';
    display: block;
    width: 100px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    margin: var(--spacing-small) 0 0 0;
    border-radius: 2px;
}

/* ========================================
   TABLEAUX
   ======================================== */

table {
    border-collapse: collapse;
    margin-left: auto;
    margin-right: auto;
    margin-top: var(--spacing-medium);
    margin-bottom: var(--spacing-medium);
    font-size: 1.15em;
    box-shadow: var(--card-shadow);
    border-radius: var(--border-radius);
    overflow: auto;
    width: auto;
    min-width: 50%;
    display: table;
    max-height: 100%;
    flex: 1 1 auto;
}

/* Réaligner les listes, textes et divs à gauche, laisser tables et images centrées */
.slide ul,
.slide ol,
.slide p,
.slide h1,
.slide h2,
.slide h3,
.slide div:not(.schema):not(.side-by-side):not(.code-with-legend),
.slide pre:not(.code-with-legend pre),
.slide .notice,
.slide .card,
.slide .features-grid {
    align-self: flex-start;
    width: 100%;
}

/* Tables et images restent centrées */
.slide table,
.slide .schema,
.slide img:not(.slide-header img),
.slide > svg {
    align-self: center;
}

/* Scrollbars hidden globally - only show for code blocks */

thead {
    background: linear-gradient(135deg, var(--primary-color), var(--tertiary-color));
    color: white;
}

thead th {
    padding: 20px 18px;
    text-align: left;
    font-weight: 700;
    font-size: 1.15em;
}

tbody tr {
    background: white;
    border-bottom: 1px solid #ecf0f1;
    transition: background-color 0.2s;
}

tbody tr:hover {
    background-color: #f8f9fa;
}

tbody td {
    padding: 18px;
    color: var(--text-color);
    font-size: 1.05em;
    font-weight: 400;
}

tbody tr:last-child {
    border-bottom: none;
}

/* ========================================
   CODE ET PRE - Laisser highlight.js gérer les styles
   ======================================== */

/* Style minimal pour code inline uniquement */
code:not(pre code) {
    background: #f4f6f7;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: var(--font-family-mono) !important;
    font-size: 0.9em;
    color: var(--secondary-color);
}

/* Container pre - juste layout, pas de couleurs */
pre {
    padding: 0px;
    border: 1px solid #eee;
    border-radius: 3px;
    overflow: auto;
    margin: var(--spacing-medium) 0;
    font-family: var(--font-family-mono) !important;
    font-size: 1em;
    line-height: 1.4;
    box-shadow: var(--card-shadow);
    flex: 1 1 auto;
    max-height: 100%;
    min-height: 0;
}

/* Laisser highlight.js gérer complètement le code dans pre */
pre code,
pre code *,
pre span,
pre * {
    font-family: var(--font-family-mono) !important;
}

pre code {
    display: block;
}

/* Scrollbar pour pre */
pre::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

pre::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
}

pre::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
}

pre::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.5);
}

/* ========================================
   LISTES
   ======================================== */

ul, ol {
    margin-left: var(--spacing-large);
    margin-bottom: var(--spacing-small);
    margin-top: var(--spacing-small);
    padding-right: var(--spacing-medium);
    flex: 0 1 auto;
}

li {
    margin-bottom: 12px;
    line-height: 1.7;
    font-size: 1.45em;
    padding-right: var(--spacing-small);
    font-weight: 400;
}

p {
    font-size: 1.35em;
    line-height: 1.7;
    margin-bottom: 12px;
}

ul li::marker {
    color: var(--secondary-color);
    font-size: 1.1em;
}

/* Listes imbriquées légèrement plus petites */
li ul li, li ol li {
    font-size: 0.92em;
    margin-bottom: 8px;
}

/* Listes compactes pour slides avec beaucoup de contenu */
.slide.compact ul, .slide.compact ol {
    margin-bottom: var(--spacing-small);
}

.slide.compact li {
    margin-bottom: 6px;
    font-size: 1.05em;
    line-height: 1.5;
}

/* ========================================
   NOTICES / ALERTES
   ======================================== */

.notice {
    background: var(--notice-bg);
    border-left: 4px solid var(--notice-border);
    padding: var(--spacing-medium);
    border-radius: 8px;
    margin: var(--spacing-small) 0;
    font-size: 1.15em;
    line-height: 1.6;
    flex: 0 1 auto;
}

.notice strong {
    color: var(--secondary-color);
}

/* Supprimer les espaces vides inutiles */
.slide br {
    display: none;
}

/* ========================================
   CARTES (3 COLONNES)
   ======================================== */

.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-large);
    width: 100%;
    margin-top: var(--spacing-large);
    padding: var(--spacing-medium);
}

.card, .feature-item {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    padding: var(--spacing-large);
    border: 3px solid transparent;
    transition: all var(--transition-speed);
    position: relative;
    overflow: hidden;
}

/* Bordures colorées pour les cartes */
.card:nth-child(1), .feature-item:nth-child(1) {
    border-color: var(--border-blue);
}

.card:nth-child(2), .feature-item:nth-child(2) {
    border-color: var(--border-orange);
}

.card:nth-child(3), .feature-item:nth-child(3) {
    border-color: var(--border-purple);
}

.card:nth-child(4) {
    border-color: var(--card-green);
}

.card:nth-child(5) {
    border-color: var(--card-red);
}

.card:nth-child(6) {
    border-color: var(--border-blue);
}

.card:hover, .feature-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.15);
}

/* Titres dans les cartes avec couleurs correspondantes */
.card:nth-child(1) h3, .feature-item:nth-child(1) h3 {
    color: var(--card-blue);
}

.card:nth-child(2) h3, .feature-item:nth-child(2) h3 {
    color: var(--secondary-color);
}

.card:nth-child(3) h3, .feature-item:nth-child(3) h3 {
    color: var(--tertiary-color);
}

/* ========================================
   SCHÉMAS ET SVG
   ======================================== */

.schema {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: var(--spacing-medium) auto;
    width: 100%;
    overflow: visible;
    flex: 1 1 auto;
    min-height: 0;
}

.schema svg, .schema img {
    width: auto;
    height: 100%;
    max-width: 90%;
    max-height: 100%;
    object-fit: contain;
    margin: 0 auto;
    flex: 1 1 auto;
}

.schema cite {
    margin-top: var(--spacing-small);
    font-size: 0.9em;
    color: #7f8c8d;
    font-style: italic;
}

/* SVG directement dans les slides */
.slide > svg {
    width: auto;
    height: auto;
    max-width: 90%;
    max-height: 100%;
    margin: var(--spacing-medium) auto;
    display: block;
    flex: 1 1 auto;
    object-fit: contain;
}

/* Images centrées - prennent l'espace disponible */
.slide img:not(.slide-header img) {
    display: block;
    margin: var(--spacing-medium) auto;
    width: auto;
    height: auto;
    max-width: 90%;
    max-height: 100%;
    object-fit: contain;
    flex: 1 1 auto;
}

/* Iframes dans les slides - prennent l'espace restant */
.slide iframe {
    width: 100%;
    height: 100%;
    min-height: 400px;
    border: none;
    border-radius: var(--border-radius);
    margin: var(--spacing-medium) 0;
    flex: 1 1 auto;
}

/* ========================================
   CSV CONTENT
   ======================================== */

.csv-content {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: var(--spacing-medium);
    font-family: var(--font-family-mono) !important;
    font-size: 0.95em;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 500px;
    margin: var(--spacing-medium) 0;
    white-space: pre;
}

/* Tous les enfants de csv-content en monospace */
.csv-content * {
    font-family: var(--font-family-mono) !important;
}

.csv-content::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.csv-content::-webkit-scrollbar-track {
    background: #e9ecef;
    border-radius: 10px;
}

.csv-content::-webkit-scrollbar-thumb {
    background: #adb5bd;
    border-radius: 10px;
}

.csv-content::-webkit-scrollbar-thumb:hover {
    background: #6c757d;
}

/* ========================================
   CITATION
   ======================================== */

cite {
    display: block;
    margin-top: var(--spacing-small);
    font-size: 0.9em;
    color: #95a5a6;
    font-style: italic;
}

cite a {
    color: var(--secondary-color);
    text-decoration: none;
}

cite a:hover {
    text-decoration: underline;
}

/* ========================================
   SIDE BY SIDE
   ======================================== */

.side-by-side-wrapper {
    display: flex;
    flex-direction: row;
    gap: 2%;
    width: 100%;
    align-self: flex-start;
    flex-shrink: 0;
    flex-grow: 0;
}

.side-by-side {
    display: block;
    width: 48%;
    flex-shrink: 0;
    flex-grow: 0;
}

.side-by-side:last-child {
    margin-right: 0;
}

/* Pre blocks inside side-by-side can grow to use available space */
.side-by-side pre {
    flex: 1 1 auto;
    max-height: 100%;
    min-height: 0;
    margin: 10px 0;
}

/* ========================================
   CLASSES UTILITAIRES
   ======================================== */

.longtext {
    font-size: 1em;
    max-width: 1000px;
    margin: 0 auto;
    line-height: 1.8;
}

.text-center {
    text-align: center;
}

.slide.full-height {
    justify-content: flex-start;
    padding-top: 40px;
}

body {
    font-size: var(--font-size-base);
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media screen and (max-width: 1024px) {
    .features-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-medium);
    }

    .slide {
        padding: 40px 70px;
        overflow-x: auto;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    li {
        font-size: 1.2em;
    }
    
    table {
        width: auto;
        min-width: 400px;
        display: table;
    }
    
    /* Décorations plus petites en tablet */
    .slide::before,
    .slide::after {
        width: 140px;
        height: 140px;
        opacity: 0.5;
    }
}

@media screen and (max-width: 768px) {
    :root {
        --font-size-h1: 2.2em;
        --font-size-h2: 1.8em;
        --font-size-h3: 1.5em;
        --spacing-large: 25px;
        --font-size-base: 18px;
    }

    .slide {
        padding: 80px 70px 60px 70px;
        min-height: 100vh;
        position: relative;
        display: flex !important;
        flex-direction: column;
        align-items: center;
        opacity: 1 !important;
        overflow-y: visible !important;
        overflow-x: auto;
        /* Hide scrollbars */
        scrollbar-width: none;
        -ms-overflow-style: none;
        /* Ensure white background covers previous slide */
        background-color: #ffffff;
        /* Proper stacking */
        z-index: 1;
        /* Isolation to prevent overlap */
        isolation: isolate;
    }

    /* Title slide mobile optimization */
    .title-slide {
        padding: 20px 15px !important;
        min-height: 100vh;
        justify-content: space-between !important;
    }

    .title-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 10px 0;
    }

    .title-slide .main-title {
        font-size: 1.4em !important;
        line-height: 1.2;
        margin-bottom: 10px !important;
        margin-top: 0 !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    .title-slide .subtitle {
        font-size: 1em !important;
        margin: 10px 0 !important;
        line-height: 1.3;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .title-slide .lecture-number {
        font-size: 1em !important;
        margin: 15px 0 8px 0 !important;
    }

    .title-slide .lecture-description {
        font-size: 0.9em !important;
        line-height: 1.4;
        margin: 8px 0 !important;
    }

    .title-footer {
        flex-direction: column;
        align-items: center !important;
        gap: 10px;
        margin-top: 15px;
        padding-bottom: 10px;
    }

    .title-footer .logos {
        margin-bottom: 5px;
    }

    .title-footer .way-up-logo {
        max-height: 35px !important;
        width: auto;
    }

    .title-footer .cc-info {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 8px;
    }

    .title-footer .cc-logo {
        max-width: 70px;
        height: auto;
    }

    .title-footer .cc-text {
        font-size: 0.65em;
    }

    .title-footer .cc-text p {
        margin: 2px 0;
        font-size: 0.85em;
        line-height: 1.3;
    }

    .title-footer .cc-text a {
        word-break: break-word;
    }

    .slide::-webkit-scrollbar {
        display: none;
    }

    /* Add extra spacing to first element to prevent title overlap */
    .slide > h1:first-child,
    .slide > h2:first-child {
        margin-top: 0;
        padding-top: 10px;
    }

    /* Cacher complètement les décorations en mobile */
    .slide::before,
    .slide::after {
        display: none;
    }
    
    /* Zone de sécurité plus petite en mobile */
    .slide > * {
        max-width: calc(100% - 20px);
    }

    table {
        font-size: 0.9em;
        width: auto;
        min-width: 280px;
        display: table;
    }

    thead th, tbody td {
        padding: 12px 10px;
    }

    pre {
        font-size: 0.95em;
        padding: 20px;
        max-height: none;
        overflow-x: auto;
        overflow-y: visible;
    }
    
    /* Forcer monospace en mobile aussi */
    pre, pre *, code, code * {
        font-family: var(--font-family-mono) !important;
    }

    li {
        font-size: 1.15em;
        margin-bottom: 12px;
    }

    .side-by-side-wrapper {
        flex-direction: column;
        gap: 0;
    }

    .side-by-side {
        display: block;
        width: 100%;
        margin-right: 0;
        margin-bottom: var(--spacing-medium);
    }

    .schema img, .schema svg {
        width: auto;
        height: auto;
    }
    
    .slide iframe {
        height: 400px;
        width: 100%;
    }
    
    /* Images en mobile */
    .slide img:not(.slide-header img) {
        max-width: 100%;
        width: auto;
    }
    
    /* Réaligner les textes à gauche en mobile */
    .slide ul,
    .slide ol,
    .slide p,
    .slide h1,
    .slide h2,
    .slide h3,
    .slide pre:not(.code-with-legend pre),
    .slide .notice {
        align-self: flex-start;
        width: 100%;
    }
    
    /* Tables et images centrées en mobile */
    .slide table,
    .slide .schema,
    .slide img:not(.slide-header img) {
        align-self: center;
    }
}

/* ========================================
   CODE CALLOUTS & LEGENDS
   ======================================== */

/* Callout numbers in code - using Unicode circled numbers */
.code-callout {
    display: inline-block;
    color: var(--secondary-color);
    font-weight: 700;
    font-size: 1.1em;
    margin: 0 2px;
    font-family: var(--font-family-mono) !important;
    vertical-align: baseline;
}

/* Container for code block + legend side-by-side */
.code-with-legend {
    display: flex !important;
    flex-direction: row !important;
    gap: 20px;
    width: 100% !important;
    align-items: flex-start !important;
    margin: var(--spacing-medium) 0 !important;
    flex-shrink: 0 !important;
    align-self: flex-start !important;
}

/* Code block takes ~60% of width with scrollbar if needed */
.code-with-legend pre {
    flex: 1 1 60% !important;
    margin: 0 !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: 60% !important;
    overflow: auto !important;
    max-height: none !important;
}

/* Legend takes ~40% of width */
.code-legend {
    flex: 0 0 38% !important;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0 !important;
    font-family: var(--font-family);
    font-size: 0.95em;
    line-height: 1.6;
    align-self: flex-start;
    max-width: 38%;
}

/* Individual legend items */
.code-legend-item {
    margin-bottom: 10px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.code-legend-item:last-child {
    margin-bottom: 0;
}

/* Circled number in legend */
.code-legend-number {
    color: var(--secondary-color);
    font-weight: 700;
    font-size: 1.05em;
    flex-shrink: 0;
    min-width: 20px;
}

/* Legend text */
.code-legend-text {
    color: var(--text-color);
    font-weight: 400;
    flex: 1;
}

/* Ensure container aligns properly in slides */
.slide .code-with-legend {
    align-self: flex-start;
    width: 100%;
}

/* Mobile responsive adjustments - stack vertically */
@media screen and (max-width: 768px) {
    .code-with-legend {
        flex-direction: column !important;
        gap: 15px;
    }

    .code-with-legend pre {
        flex: 1 1 auto !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .code-legend {
        flex: 1 1 auto !important;
        width: 100% !important;
        max-width: 100% !important;
        font-size: 0.9em;
        padding: 0;
    }

    .code-callout {
        font-size: 1.05em;
    }
}
