/* ============================================================
   RESET & BASE
   ============================================================ */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}

select {
    font-family: inherit;
    cursor: pointer;
}

/* ============================================================
   SCHERMO FULLSCREEN
   ============================================================ */

#color-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: background-color 0.6s ease;
    background-color: #cccccc;
}

/* ============================================================
   ETICHETTA HEX
   ============================================================ */

#hex-label {
    font-size: clamp(2rem, 6vw, 5rem);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.85;
    user-select: none;
    transition: color 0.4s ease;
}

/* ============================================================
   AZIONI (bottoni in basso)
   ============================================================ */

#actions {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.75rem;
}

#actions button {
    padding: 0.6rem 1.4rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.35);
    transition: background 0.2s ease, color 0.2s ease;
}

#actions button:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* ============================================================
   OVERLAY
   ============================================================ */

#overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 10;
}

#overlay.visible {
    opacity: 1;
    pointer-events: all;
}

/* ============================================================
   PANNELLO STORICO
   ============================================================ */

#history-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: min(420px, 100vw);
    height: 100%;
    background: #fff;
    color: #111;
    display: flex;
    flex-direction: column;
    z-index: 20;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
}

#history-panel.open {
    transform: translateX(0);
}

/* Header pannello */
#history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #eee;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    flex-shrink: 0;
}

#btn-close-panel {
    font-size: 1.1rem;
    color: #666;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    transition: background 0.2s;
}

#btn-close-panel:hover {
    background: #f0f0f0;
}

/* Selettore N */
#history-limit-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.5rem;
    border-bottom: 1px solid #eee;
    font-size: 0.82rem;
    color: #555;
    flex-shrink: 0;
}

#history-limit {
    padding: 0.3rem 2rem 0.3rem 0.6rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.82rem;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    background-color: #fff;
    cursor: pointer;
}

/* Tab */
#history-tabs {
    display: flex;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.tab {
    flex: 1;
    padding: 0.85rem 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: #888;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    text-align: center;
}

.tab.active {
    color: #111;
    border-bottom-color: #111;
}

.tab:hover:not(.active) {
    color: #444;
}

/* Contenuto tab */
.tab-content {
    display: none;
    overflow-y: auto;
    flex: 1;
}

.tab-content.active {
    display: block;
}

/* Lista colori */
.color-list {
    padding: 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.color-item {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}

.color-item:hover {
    background: #f5f5f5;
}

.color-swatch {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.color-info {
    flex: 1;
    min-width: 0;
}

.color-hex {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.color-meta {
    font-size: 0.72rem;
    color: #999;
    margin-top: 0.1rem;
}

.color-list-empty {
    font-size: 0.85rem;
    color: #bbb;
    text-align: center;
    padding: 2rem 0;
}

/* ============================================================
   INPUT NASCOSTO (copia link)
   ============================================================ */

#share-input {
    position: fixed;
    top: -9999px;
    left: -9999px;
    opacity: 0;
    pointer-events: none;
}

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

@media (max-width: 480px) {
    #actions {
        bottom: 1.5rem;
        gap: 0.5rem;
    }

    #actions button {
        padding: 0.7rem 1rem;
        font-size: 0.95rem;
    }

    .btn-text {
        display: none;
    }
}