/* RESET & BASE */
html, body {
    margin: 0;
    padding: 0;
    /* Supprime ou modifie la ligne ci-dessous */
    /* overflow: hidden; */
    overflow-x: hidden;
    background: #0f0f0f;
    color: #fff;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* CANVAS */
#grid {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    cursor: crosshair;
}

/* UI WRAPPER & BAR */
#ui-wrapper {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    z-index: 100;
    display: flex;
    justify-content: center;
    background: none;
    margin: 0;
    padding: 0;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s;
    transform: translateY(100px);
    opacity: 0;
    pointer-events: none;
}

#ui-wrapper.visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

#ui {
    width: 100vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 0 8px 0;
    pointer-events: auto;
    
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.432);
  color: white;
}

/* TIMER CONTAINER */
#timer-container {
    position: fixed; /* Keep the timer visible even when scrolling */
    z-index: 2001; /* Ensure it's above other elements */
    pointer-events: none; /* The timer should not intercept clicks on the canvas */
    width: fit-content;
    max-width: 90vw;
    background: #fff; 
    color: #000;
    padding: 4px 18px;
    border-radius: 50px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.575);
    font-size: 16px; /* Default font size for the timer */
    text-align: center;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
   }


/* PALETTE COULEURS */
#preset {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    max-width: 90vw;
    width: 100vw;
    padding: 0;
}

.color-btn {
    flex: 0 0 auto;
    min-width: 30px;
    max-width: 50px;
    height: 30px;
    width: clamp(30px, 5vw, 36px);  /* Même logique pour tous */
    height: clamp(30px, 3.5vw, 30px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.2s, border 0.2s, opacity 0.2s, filter 0.2s;
    transform-origin: center;
    box-sizing: border-box;
    margin: 0;
}

.color-btn:hover:not([disabled]),
.color-btn.selected {
    border: 1px solid #000000;
}

.color-btn.selected {
    box-shadow: 0 0 4px #000, 0 0 0 1px #000;
    z-index: 2;
    transform: scale(1.05);
}















/*NEW STYLE FOR DISABLED COLOR BUTTONS */
.color-btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    border: 1px solid #555 !important;
    filter: grayscale(100%);
    box-shadow: none !important;
}

/* Ensure hover and selected states don't apply if disabled */
.color-btn[disabled]:hover,
.color-btn[disabled].selected {
    transform: none;
    border: 1px solid #555;
    box-shadow: none;
}

/* CONFIRM/CANCEL BUTTONS */
#confirmColor,
#cancelSelection {
    min-width: 100px;
    height: 30px;
    padding: 4px 10px;
    font-weight: bold;
    font-size: 13px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s, opacity 0.2s;
}

#confirmColor {
    background: #2ecc71;
    color: #fff;
}

#confirmColor:hover:enabled {
    background: #27ae60;
    transform: scale(1.05);
}

#confirmColor:disabled,
#cancelSelection:disabled {
    background: #777;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

#cancelSelection {
    background: #e74c3c;
    color: #fff;
}

#cancelSelection:hover:enabled {
    background: #c0392b;
    transform: scale(1.05);
}

/* ACTIONS */
#actions {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 10px;
}

/* LABELS & BANNERS */
.beta-banner,
.beta-label {
    background: #ff4081;
    color: #fff;
    padding: 5px 12px;
    border-radius: 5px;
    font-size: 12px;
    z-index: 9999;
}

/* SETTINGS */
#settings-panel,
.settings-panel {
    position: fixed;
    top: 70px;
    right: 20px;
    width: 320px;
    max-width: 90vw;
    background: #222;
    color: #fff;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    z-index: 2002;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}

#settings-panel.visible,
.settings-panel.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#settings-panel label,
.settings-panel label {
    display: block;
    width: 100%;
    cursor: pointer;
    padding: 8px 0;
    user-select: none;
}

.setting-option {
    font-size: 14px;
}

.hidden {
    display: none;
}

#settings-panel label:hover {
    background: #3f3f3f;
    border-radius: 8px;
    transition: background 0.3s;
}

/* SETTINGS ICON */
/* SETTINGS ICON */

#settings-icon {
    cursor: pointer;
    background: white;
    color: black;
    padding: 6px;
    border-radius: 9999px; /* cercle si icône carrée */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s, box-shadow 0.3s, transform 0.2s;
}

#settings-icon:hover {
    background: #f3f3f3;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
    transform: scale(1.05);
}

#settings-icon:active {
    transform: scale(0.95);
}

#settings-icon img {
    width: 28px;
    height: 28px;
    pointer-events: none;
    transition: transform 0.5s ease;
}

/* Rotation animée */
#settings-icon img.rotating-forward {
    transform: rotate(90deg);
}

#settings-icon img.rotating-backward {
    transform: rotate(-90deg);
}

/* LOGO */
#logo-container {
    margin-right: 10px;
}

#logo-container img,
.logo {
    width: 40px;
    height: auto;
    border-radius: 6px;
    transition: transform 0.3s;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.3);
}

#logo-container img:hover,
.logo:hover {
    transform: scale(1.1);
}

/* TOP BAR */
#top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.527);
}

.top-left,
.top-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.site-title {
    font-size: 20px;
    font-weight: bold;
    color: #111;
}

.top-right {
    gap: 15px;
}

#pixel-coords {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

.home {
    text-decoration: none;
    color: inherit;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #f0f0f0;
    transition: background-color 0.3s, transform 0.2s;
}

.home:hover {
    background-color: #e0e0e0;
    transform: scale(1.05);
}

/* RESPONSIVE */
@media (max-width: 1000px) {
    #top-bar {
        flex-direction: row;
        align-items: center;
        height: auto;
        padding: 6px 4px;
        gap: 0;
    }

    .top-left {
        flex-direction: row;
        align-items: center;
        gap: 6px;
        width: auto;
    }

    .site-title {
        font-size: 15px;
        margin-left: 6px;
    }

    .top-right {
        gap: 8px;
        width: auto;
        justify-content: flex-end;
    }

    .logo,
    #logo-container img {
        height: 28px;
        width: 28px;
    }

    #ui {
        padding: 6px 0 4px 0;
        gap: 6px;
    }
/*
    #preset {
        flex-wrap: wrap;
        gap: 4px;
        padding: 0 2px 6px 2px;
        width: 100vw;
        max-width: 100vw;
        justify-content: center;
        box-sizing: border-box;
    }

    .color-btn {
        flex: 1 1 32px;
        min-width: 46px;
        max-width: 46px;
        height: 24px;
        border-radius: 6px;
        margin: 1px 0;
        transition: transform 0.2s, border 0.2s, opacity 0.2s, filter 0.2s;
    }
*/

    #actions {
        gap: 8px;
        margin-top: 2px;
    }

    #confirmColor,
    #cancelSelection {
        min-width: 80px;
        height: 36px;
        font-size: 16px;
        border-radius: 18px;
        padding: 0 10px;
    }

  

    /* #timer.above-ui is likely redundant now that app.js handles positioning. */
    /* If you still need specific adjustments when it's "above-ui", add them here
       for #timer-container. */
    /*
    #timer-container.above-ui {
        left: 50%;
        right: auto;
        bottom: unset;
        transform: translateX(-50%);
    }
    */

    #settings-panel,
    .settings-panel {
        width: 95vw;
        right: 2vw;
        top: 60px;
        padding: 8px 6px;
        font-size: 13px;
    }
}

@media (max-width: 400px) {
    #top-bar {
        padding: 4px;
    }

    .site-title {
        font-size: 14px;
    }

    .logo,
    #logo-container img {
        height: 24px;
        width: 24px;
    }

    #ui {
        padding: 4px 0 2px 0;
        gap: 4px;
    }
/*
    #preset {
        flex-wrap: wrap;
        gap: 2px;
        padding: 0 1px 4px 1px;
        width: calc(100vw - 2px);
        max-width: calc(100vw - 2px);
        justify-content: center;
        box-sizing: border-box;
    }

    .color-btn {
        flex: 1 1 28px;
        min-width: 40px;
        max-width: 40px;
        height: 20px;
        border-radius: 4px;
        margin: 0;
        transition: transform 0.2s, border 0.2s, opacity 0.2s, filter 0.2s;
    }
        */

    #actions {
        gap: 6px;
        margin-top: 0;
    }

    #confirmColor,
    #cancelSelection {
        min-width: 70px;
        height: 32px;
        font-size: 14px;
        border-radius: 16px;
        padding: 0 8px;
    }
}


#pixel-info.hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

@media (max-width: 768px) {
    #timer-display {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    #timer-display {
        font-size: 1rem;
    }

    #timer-container {
        padding: 0.4rem 0.8rem;
    }
}
