body {
    font-family: 'Arial', sans-serif;
    /* display: flex; */
    flex-direction: column;
    align-items: center;
    background-color: #f0f0f0;
    margin: 0;
    padding: 5px;
    height: 90%;
    overflow-x: hidden;
}

.header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.header h1 {
    color: #333;
    font-size: 1.5em;
    margin: 0 auto;
}

body h2 {
    display: block;
    font-size: 1em;
    margin-block-start: 0.25em;
    margin-block-end: 0.25em;
}

.header img {
    width: 30px;
    height: 30px;
}

.tools {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto; /* Ajoute un défilement horizontal */
    overflow-y: hidden;
    margin-bottom: 5px;
    gap: 5px;
    -webkit-overflow-scrolling: touch; /* Améliore le défilement tactile sur iOS */
    scrollbar-width: thin; /* Réduit la largeur de la barre de défilement sur Firefox */
    scrollbar-color: #888 #f0f0f0; /* Couleur de la barre de défilement */
}

/*
.tools::-webkit-scrollbar {
    height: 8px; /* Hauteur de la barre de défilement 
}

.tools::-webkit-scrollbar-thumb {
    background-color: #888; /* Couleur de la barre de défilement
    border-radius: 4px; /* Rayon de la barre de défilement
}
.tools::-webkit-scrollbar-track {
    background-color: #f0f0f0; /* Couleur de la piste de défilement 
}
*/

.tool {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px; /* Largeur fixe pour chaque outil */
    height: 30px; /* Hauteur fixe pour chaque outil */
    border: 2px solid transparent;
    cursor: pointer;
    flex-shrink: 0;
}

.tool.selected {
    border-color: #007BFF;
}

.tool img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Conserve les proportions des icônes */
}

.container {
    display: flex;
    align-items: flex-start;
    width: 100%;
    height: calc(100vh - 150px);
}


.leftside {
    width: 130px;
}


.palette {
    display: grid;
    grid-template-columns: repeat(5, 20px);
    grid-template-rows: repeat(7, 20px);
    gap: 5px;
    margin-right: 20px;
    height: 100%;
    overflow-y: visible;
}

.color {
    width: 20px;
    height: 20px;
    border: 1px solid #333;
    cursor: pointer;
}

.color.selected {
    border: 2px solid #000;
    box-sizing: border-box;
}

.color-usage {
    border: 1px solid #ccc;
    padding: 10px;
    border-radius: 5px;
    background-color: #f9f9f9;
    margin-left: 0px;
}

.color-usage h3 {
    margin-top: 0;
    font-size: 16px;
}

.color-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 220px;
    overflow-y: auto;
}

.color-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-sample {
    width: 20px;
    height: 20px;
    border: 1px solid #333;
}

.color-count {
    font-size: 14px;
}

.main {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    height: 100%;
}

.grid-container {
    border: 2px solid #333;
    /* margin-bottom: 20px; */
    overflow: hidden;
    width: 100%;
    height: 100%;
    position: relative;
}

.grid {
    display: grid;
    grid-template-columns: repeat(16, 20px);
    grid-template-rows: repeat(16, 20px);
    gap: 0;
    background-color: #333;
    transform-origin: 0 0;
    position: absolute;
    top: 0;
    left: 0;
}

.pixel {
    width: 20px;
    height: 20px;
    background-color: #FFFFFF00;
    cursor: pointer;
    user-select: none;
    -webkit-user-drag: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.pixel.selected {
    position: relative;
}

.pixel.selected::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 255, 0.3);
    pointer-events: none;
}

.grid-info {
    display: flex;
    flex-direction: column;
    font-size: 15px;
    gap: 3px;
    margin-left: 10px;
}

button {
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    background-color: #007BFF;
    color: white;
    border: none;
    border-radius: 5px;
}

button:hover {
    background-color: #0056b3;
}

.modal {
    display: none;
    position: fixed;
    align-items: center;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 7% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 400px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    max-height: 80vh;
    overflow-y: auto; /* Ajoute un défilement vertical si nécessaire */
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: black;
}

.shortcuts-grid {
    display: grid;
    /* grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-top: 10px; */
}

.shortcuts-header {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr;
    font-weight: bold;
    border-bottom: 1px solid #ddd;
    padding-bottom: 5px;
}

.shortcuts-grid div {
    padding: 1px;
    text-align: center;
}

.shortcuts-list {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr;
    gap: 10px;
}

.shortcuts-list div {
    text-align: center;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shortcuts-list img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.modal-content label {
    display: block;
    margin-top: 10px;
    font-size: 16px;
}

.modal-content input {
    width: 100%;
    padding: 8px;
    margin-top: 5px;
    font-size: 16px;
    box-sizing: border-box;
}

.modal-content button {
    margin-top: 20px;
    width: 100%;
}

.contrast-bar {
  display: flex;
  margin-top: 10px;
  width: 120px;
}

#contrast-slider {
  flex-grow: 1;
  width:100%
}

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

:root {
  --grid-color-1: #ffffff;
  --grid-color-2: #f0f0e7;
}

/* CSS pour les appareils mobiles */
@media (max-width: 768px) {
    .header {
        margin-bottom: 0px;
    }
    
    .header h1 {
        font-size: 1em;
    }
    .palette {
        overflow-y: visible;
        margin-right: 5px;
    }

    .color {
        width: 15px;
        height: 15px;
    }

    .tool {
        width: 20px;
        height: 20px;
    }

    .tools {
        gap: 5px;
    }

    body h2 {
        font-size: 15px;
    }

    .grid-info {
        font-size: 12px;
    }

    .color-usage {
        padding: 5px;
    }

    .color-sample {
        width: 15px;
        height: 15px;
    }

    .color-usage h3 {
        font-size: 12px;
        margin-bottom: 0.25em;
    }
}

/* Mode portrait*/
@media (max-width: 768px) and (orientation: portrait) {

    .leftside {
        width: 60px;
    }
    .palette {
        grid-template-columns: repeat(3, 15px);
        grid-template-rows: repeat(12, 15px);
    }
    .contrast-bar {
        width: 55px;
        height: 100px;
    }
    #contrast-slider {
            writing-mode: vertical-lr
    }
}

/* Mode landscape*/
@media (max-width: 768px) and (orientation: landscape) {
    .palette {
        grid-template-columns: repeat(5, 15px);
        grid-template-rows: repeat(7, 15px);
    }
    .contrast-bar {
        width: 100px;
    }
    .color-list {
        max-height: 120px;
    }
}
