:root {
    --background-color: #f0f0f0;
    --text-color: #333;
    --container-color: #fff;
    --wheel-bg-color: #f0f0f0;
    --sidebar-bg-color: #e0e0e0;
    --sidebar-text-color: #333;
    --history-item-bg-color: #fff;
    --history-item-hover-color: #e0e0e0;
}

body {
    font-family: 'Urbanist', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    min-height: 100vh;
    padding: 0;
}

canvas#wheel {
    background-color: var(--background-color);
    color: var(--text-color);
}

.title-container {
    width: 100%;
    text-align: center;
    padding: 20px 0;
    background-color: var(--container-color);
    color: var(--text-color);
}

.title-section {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

#main-title {
    margin: 0;
    font-size: 2em;
}

.title-input {
    display: none;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1.5em;
    width: 300px;
    max-width: 80%;
}

.edit-title-btn, .save-title-btn {
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 0.8em;
}

.edit-title-btn {
    display: inline-block;
}

.save-title-btn {
    display: none;
}

.main-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    width: 100%;
    max-width: 800px;
    padding: 0 20px 20px 20px;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.setup-section {
    background-color: var(--container-color);
    color: var(--text-color);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 30px;
    width: 100%;
    max-width: 600px;
    margin-top: 0;
}

.setup-section h2 {
    font-size: 1.5em;
    margin-top: 0;
}

.film-input-container {
    display: flex;
    margin-bottom: 10px;
}

.film-input-container input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1em;
}

.film-input-container button {
    margin-left: 10px;
    padding: 10px 15px;
    background-color: #f44336;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#addFilm {
    background-color: #2196F3;;
    margin-top: 20px;
    padding: 12px 25px;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    color: white;
    font-weight: bold;
    width: 100%;
}

#startWheel {
    background-color: #4CAF50;
    margin-top: 20px;
    padding: 12px 25px;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    color: white;
    font-weight: bold;
    width: 100%;
}

.wheel-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    height: 500px;
    margin-bottom: 30px;
    display: none;
    background-color: var(--container-color);
    color: var(--text-color);
    border: none;
}

#wheel {
    width: 100% !important;
    height: 100% !important;
    color: var(--text-color);
    touch-action: manipulation;
}

.close-sidebar-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: var(--text-color);
}

.close-sidebar-btn:hover {
    color: #ff5722; /* Changer la couleur au survol pour indiquer que le bouton est cliquable */
}

#spin {
    padding: 12px 25px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.3s;
    z-index: 10;
    margin-bottom: 30px;
    display: none;
    width: 80%;
    max-width: 300px;
}

#fullscreen-btn {
    display: none;
    margin-bottom: 15px;
    padding: 12px;
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 5px;
    width: 80%;
    max-width: 300px;
    cursor: pointer;
}

.arrow {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-top: 30px solid red;
    z-index: 10;
}

#result {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: bold;
    color: #fff;
    background-color: rgba(0,0,0,0.8);
    padding: 20px;
    border-radius: 10px;
    display: none;
    z-index: 20;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    transition: all 0.5s ease;
    text-align: center;
    min-width: 200px;
}

.wheel-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    max-width: 500px;
}

.legend-item {
    padding: 8px 12px;
    border-radius: 4px;
    background-color: rgb(211, 211, 211);
    font-size: 14px;
    display: flex;
    align-items: center;
    color: black;
}

.legend-color {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    margin-right: 8px;
}

.sidebar {
    width: 250px;
    background-color: var(--sidebar-bg-color);
    padding: 20px;
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
    overflow-y: auto;
    height: 100vh;
    position: fixed;
    right: -300px; /* Masquer le panneau latéral par défaut */
    top: 0;
    transition: right 0.3s ease;
    z-index: 999;
}

.sidebar.visible {
    right: 0; /* Afficher le panneau latéral */
}

.sidebar h2 {
    font-size: 1.5em;
    margin-top: 0;
}

#history {
    list-style-type: none;
    padding: 0;
}

#history li {
    padding: 10px;
    margin-bottom: 5px;
    background-color: var(--history-item-bg-color);
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#history li:hover {
    background-color: #ddd;
}

#history div {
    padding: 10px;
    margin-bottom: 10px;
    background-color: var(--history-item-bg-color);
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#history div:hover {
    background-color: var(--history-item-hover-color);
}

#history div div:first-child {
    font-weight: bold;
    margin-bottom: 5px;
}

#history div div:last-child {
    font-style: italic;
}

.back-arrow {
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 1em;
    display: none; /* Masquer par défaut */
}

.back-arrow:hover {
    background-color: #0b7dda;
}

.toggle-history-btn {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 1em;
    z-index: 1000;
    display: block; /* Assurez-vous que le bouton est visible par défaut */
}

.dark-mode {
    --background-color: #121212;
    --text-color: #f0f0f0;
    --container-color: #1e1e1e;
    --wheel-bg-color: #333;
    --sidebar-bg-color: #333;
    --sidebar-text-color: #f0f0f0;
    --history-item-bg-color: #1e1e1e;
    --history-item-hover-color: #444;
}

.dark-mode-toggle {
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 1em;
    margin-left: 10px;
}

.dark-mode-toggle:hover {
    background-color: #0b7dda;
}

/* Styles pour les mobiles */
@media (max-width: 600px) {
    body {
        padding: 0;
    }

    .title-container {
        padding: 15px 0;
    }

    .title-section {
        flex-direction: column;
        align-items: center;
    }

    #main-title {
        font-size: 1.6em !important;
        margin-bottom: 10px !important;
    }

    .edit-title-btn, .save-title-btn {
        width: 100%;
        max-width: 200px;
        padding: 10px !important;
        font-size: 1em !important;
        margin-bottom: 10px !important;
    }

    .title-input {
        width: 90% !important;
        max-width: 300px !important;
        font-size: 1.3em !important;
        padding: 10px !important;
        margin-bottom: 10px !important;
    }

    .main-container {
        padding: 0 10px 20px 10px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .setup-section {
        width: 95% !important;
        padding: 15px !important;
        margin-top: 10px !important;
        margin-bottom: 15px !important;
    }

    .setup-section h2 {
        font-size: 1.3em !important;
    }

    .film-input-container {
        flex-direction: row !important;  /* Garde les éléments sur une ligne */
        align-items: center;             /* Centre verticalement les éléments */
        margin-bottom: 10px !important;
    }

    .film-input-container input {
       width: calc(100% - 50px) !important; /* Prend la largeur disponible sauf l'espace pour le bouton */
        padding: 12px !important;
        font-size: 1em !important;
        margin-bottom: 0 !important;     /* Supprime la marge inférieure */
    }

    .film-input-container button {
        width: 40px !important;           /* Largeur fixe pour le bouton */
        margin-left: 10px !important;
        padding: 10px !important;
        flex-shrink: 0;                   /* Empêche le bouton de se réduire */
    }

    #addFilm, #startWheel {
        width: 100% !important;
        padding: 12px !important;
        margin-top: 10px !important;
        font-size: 1em !important;
    }

    .wheel-container {
        width: 90vw !important;
        height: 90vw !important;
        max-width: 90vh !important;
        max-height: 90vh !important;
        margin-bottom: 15px !important;
    }

    .arrow {
        border-top-width: 20px !important;
        transform: translateX(-50%) translateY(-15px) !important;
    }

    #spin {
        width: 80% !important;
        max-width: 300px !important;
        padding: 15px !important;
        font-size: 1.1em !important;
        margin-bottom: 15px !important;
    }

    #fullscreen-btn {
        width: 80% !important;
        max-width: 300px !important;
    }

    #result {
        font-size: 1.3em !important;
        padding: 12px !important;
        min-width: 80% !important;
    }

    .wheel-legend {
        flex-direction: column !important;
        width: 90% !important;
        max-width: 300px !important;
    }

    .legend-item {
        width: 100% !important;
        padding: 8px 12px !important;
        font-size: 0.9em !important;
        margin-bottom: 5px !important;
    }
}

/* Améliorations pour les boutons tactiles */
button, .edit-title-btn, .save-title-btn, #addFilm, #startWheel, #spin {
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

/* Adaptation du canvas */
canvas#wheel {
    touch-action: manipulation;
}

/* Meilleure gestion des espacements sur mobile */
.container {
    padding: 0 10px !important;
}
