:root {
    --primary-color: #0066cc;
    --secondary-color: #004d99;
    --background-color: #f8f9fa;
    --code-bg: #f1f1f1;
    --text-color: #333;
    --border-color: #dee2e6;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

h1 {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

h2 {
    color: var(--secondary-color);
    margin-top: 30px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

h3 {
    color: var(--secondary-color);
}

h3.normal {
    font-weight: normal;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 20px auto;
    border: 1px solid var(--border-color);
    border-radius: 5px;
}

pre,
code {
    background-color: var(--code-bg);
    border-radius: 5px;
    font-family: 'Courier New', Courier, monospace;
}

pre {
    padding: 15px;
    overflow-x: auto;
    border: 1px solid var(--border-color);
}

code {
    padding: 2px 5px;
}

.note {
    background-color: #e2f0ff;
    border-left: 5px solid var(--primary-color);
    padding: 10px 15px;
    margin: 20px 0;
    border-radius: 0 5px 5px 0;
}

.warning {
    background-color: #fff3cd;
    border-left: 5px solid #ffc107;
    padding: 10px 15px;
    margin: 20px 0;
    border-radius: 0 5px 5px 0;
}

table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
    background: #fff;
    font-size: 1em;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

table,
th,
td {
    border: 1px solid var(--border-color);
}

th,
td {
    padding: 10px 14px;
    text-align: left;
}

th {
    background: #e9ecef;
    font-weight: bold;
    color: var(--primary-color);
}

tr:nth-child(even) {
    background: #f9f9f9;
}

tr:hover {
    background: #e3f2fd;
    transition: background 0.2s;
}

.section {
    margin-bottom: 30px;
}

.container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: space-between;
}

.box {
    flex: 1;
    min-width: 300px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 15px;
    background-color: white;
}

.toc {
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 30px;
}

.toc ul {
    list-style-type: none;
    padding-left: 15px;
}

.toc-title {
    font-weight: bold;
    margin-bottom: 10px;
}

.circuit-diagram {
    max-width: 500px;
    margin: 20px auto;
    display: block;
}

.scroll-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    text-align: center;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.scroll-top:hover {
    opacity: 1;
}

.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Barre de navigation horizontale */
.topnav {
    background-color: var(--primary-color);
    /* Utilisation de la couleur principale */
    overflow: hidden;
}

.topnav::after {
    clear: both;
    content: "";
    display: block;
}

.topnav a {
    float: left;
    display: block;
    color: var(--background-color);
    /* Texte en couleur de fond pour contraste */
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
    font-size: 17px;
}

.topnav a:hover,
.menu-item:hover .menu-button {
    background-color: var(--secondary-color);
    /* Couleur secondaire pour le survol */
    color: white;
}

.active {
    background-color: var(--secondary-color);
    /* Couleur secondaire pour l'élément actif */
    color: white;
}

.menu-item {
    float: left;
    overflow: hidden;
}

.menu-button {
    font-size: 17px;
    border: none;
    outline: none;
    color: var(--background-color);
    /* Texte en couleur de fond */
    padding: 14px 16px;
    background-color: var(--primary-color);
    /* Couleur principale */
    font-family: inherit;
    margin: 0;
    cursor: pointer;
}

.submenu {
    display: none;
    position: absolute;
    background-color: var(--background-color);
    /* Fond clair pour le sous-menu */
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
    z-index: 1;
    border: 1px solid var(--border-color);
    /* Ajout d'une bordure pour correspondre au design */
}

.submenu a {
    float: none;
    color: var(--text-color);
    /* Texte en couleur principale */
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
    background-color: var(--background-color);
    /* Fond clair pour les liens */
}

.submenu a:hover {
    background-color: var(--secondary-color);
    /* Couleur secondaire pour le survol */
    color: white;
    /* Texte blanc pour le contraste */
}

.menu-item:hover .submenu {
    display: block;
}

/* Style pour le logo */
.logo {
    display: flex;
    align-items: center;
    padding: 0 20px;
}

.logo a {
    color: white;
    text-decoration: none;
    font-weight: bold;
    font-size: 1.2rem;
}

/* Style pour la page d'accueil */
.home-header {
    text-align: center;
    margin: 40px 0;
}

.tutorials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.tutorial-card {
    background-color: white;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.3s;
}

.tutorial-card:hover {
    transform: translateY(-5px);
}

.tutorial-card img {
    width: 20%;
    height: auto;
    object-fit: cover;
    border: none;
    margin: 0;
}

.tutorial-content {
    padding: 15px;
}

.tutorial-content h3 {
    margin-top: 0;
    color: var(--primary-color);
}

.tutorial-btn {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    padding: 8px 15px;
    border-radius: 4px;
    text-decoration: none;
    margin-top: 10px;
}

.tutorial-btn:hover {
    background-color: var(--secondary-color);
}

/* Responsive */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
    }

    .nav-menu {
        flex-direction: column;
        width: 100%;
    }

    .logo {
        padding: 15px 0;
        justify-content: center;
    }
}

/* Style pour le contenu du tutoriel */
.tutorial-container {
    background-color: white;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    padding: 20px;
    margin-bottom: 30px;
}

/* Footer */
footer {
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 15px 0;
    margin-top: 50px;
}


/* Styles pour le bouton de copie de code */
.code-block-container {
    position: relative;
    margin-top: 1em;
    /* Ajustez si nécessaire pour l'espacement */
    margin-bottom: 1em;
    /* Ajustez si nécessaire pour l'espacement */
}

/* Ajustement pour que le conteneur n'ajoute pas de marge si <pre> en a déjà */
.code-block-container pre {
    margin-top: 0;
    margin-bottom: 0;
}

.copy-code-button {
    position: absolute;
    top: 10px;
    /* Ajustez pour la position verticale */
    right: 10px;
    /* Ajustez pour la position horizontale */
    padding: 5px 10px;
    background-color: #f0f0f0;
    /* Couleur de fond du bouton */
    color: #333;
    /* Couleur du texte/logo du bouton */
    border: 1px solid #ccc;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1em;
    /* Taille du logo/texte */
    opacity: 0;
    /* Caché par défaut */
    transition: opacity 0.3s ease-in-out, background-color 0.2s;
    z-index: 1;
    /* Pour s'assurer qu'il est au-dessus du code */
}

.code-block-container:hover .copy-code-button {
    opacity: 1;
    /* Apparaît au survol du conteneur du bloc de code */
}

.copy-code-button:hover {
    background-color: #e0e0e0;
    /* Changement de couleur au survol du bouton */
}

.copy-code-button:active {
    background-color: #d0d0d0;
    /* Changement de couleur au clic */
}

.tutorials-columns {
    display: flex;
    gap: 2em;
    justify-content: center;
    margin-top: 2em;
    margin-bottom: 2em;
}

.tutorial-col {
    flex: 1 1 0;
    min-width: 280px;
    max-width: 350px;
    background: #fff9c4;
    border-radius: 14px;
    box-shadow: 0 2px 12px #0002;
    padding: 1.2em 1em;
    display: flex;
    flex-direction: column;
    /* Hauteur = 2 cards + marges */
    height: 420px;
    overflow-y: auto;
}

.tutorial-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 6px #e0f5d8;
    padding: 0.8em 0.7em;
    display: flex;
    align-items: center;
    gap: 1em;
    margin-bottom: 1.2em;
    min-height: 300px;
}

.tutorial-card img {
    width: 70px;
    height: 70px;
    object-fit: contain;
    border-radius: 8px;
    background: #f8fff4;
}

.tutorial-content {
    flex: 1;
    min-width: 0;
}

.tutorial-content h3 {
    font-size: 1.1em;
    margin: 0 0 0.3em 0;
    color: #1976d2;
    font-weight: bold;
}

.tutorial-btn {
    display: inline-block;
    margin-top: 0.5em;
    background: #388e3c;
    color: #fff;
    padding: 0.4em 1em;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.95em;
    transition: background 0.2s;
}

.tutorial-btn:hover {
    background: #28a745;
}

/* Réduit la largeur de la colonne prototype dans les tableaux API */
.api-td-proto {
    max-width: 480px;
    min-width: 320px;
    width: 36%;
    vertical-align: top;
    background: #f8f8fa;
    border-radius: 10px 0 0 10px;
    padding: 0.5em 1em 0.5em 1em;
    font-size: 0.97em;
    box-sizing: border-box;
}

.api-table .api-th-proto {
    width: 60%;
    min-width: 240px;
    max-width: 900px;
}

.api-td-desc {
    vertical-align: top;
    padding: 0.5em 1em;
}

.api-table .api-th-desc,
.api-td-desc {
    width: 40%;
    min-width: 180px;
    max-width: 700px;
}

@media (max-width: 900px) {

    .api-td-proto,
    .api-table .api-th-proto {
        min-width: 180px;
        max-width: 98vw;
        width: 98vw;
    }

    .api-table .api-th-proto,
    .api-td-proto,
    .api-table .api-th-desc,
    .api-td-desc {
        width: 100%;
        min-width: 120px;
        max-width: 98vw;
    }
}