:root {
    --bg-color: #252525;
    --panel-bg: #383838;
    --text-color: #f5f5f5;
    --border-color: #444;
    --element-bg: #585858;
    --element-hover-bg: #6b6b6b;
    --tier-s: #ff7f7f;
    --tier-a: #ffbf7f;
    --tier-b: #ffff7f;
    --tier-c: #7fff7f;
    --tier-d: #7fbfff;
    --item-size: 120px;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* HEADER & LAYOUT */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
}

.header {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
    background: var(--panel-bg);
    padding: 15px;
    border-radius: 8px;
}

.header-title {
    display: flex;
    align-items: center;
    width: 100%;
}

.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

#json-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.header input[type="text"] {
    font-size: 24px;
    font-weight: bold;
    background: transparent;
    border: 1px solid transparent;
    color: white;
    padding: 5px;
    min-width: 80px;
    width: 80px;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
}

.header input[type="text"]:focus {
    border-bottom: 1px solid var(--tier-d);
    outline: none;
}

.btn {
    background: var(--element-bg);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn:hover { background: var(--element-hover-bg); }
.btn.active { background: #3498db; }
.btn-danger { background: #cc4444; }
.btn-danger:hover { background: #ee5555; }

/* MATERIAL SYMBOLS */
.material-symbols-outlined {
    font-size: 20px;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0;
    display: flex;
    align-items: center;
}

/* TIER LIST */
.tier-row {
    display: flex;
    min-height: 100px;
    background: var(--panel-bg);
    margin-bottom: 10px;
    border-radius: 4px;
    overflow: hidden;
}

.tier-label {
    width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    color: #333;
    flex-shrink: 0;
}

.tier-items {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    padding: 10px;
    gap: 10px;
    min-height: 100px;
}

/* SIDEBAR */
.sidebar {
    width: 350px;
    background: var(--panel-bg);
    border-left: 2px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.create-form {
    padding: 20px;
    border-bottom: 2px solid var(--border-color);
}

.drop-zone {
    width: 100%;
    height: 150px;
    border: 2px dashed #666;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin-bottom: 10px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    color: #aaa;
    background: #222;
}

.drop-zone.dragover { border-color: var(--tier-d); background: #333; }
.drop-zone img { width: 100%; height: 100%; object-fit: contain; position: absolute; top: 0; left: 0; background: #111; }
.drop-zone span { position: relative; z-index: 1; pointer-events: none; padding: 10px;}

.create-form input[type="text"] {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    background: #111;
    border: 1px solid #444;
    color: white;
    border-radius: 4px;
}

.unassigned-items {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column; /* Colonna verticale come richiesto */
    gap: 10px;
}

/* ITEM COMPONENT */
.tier-item {
    width: max-content;
    height: max-content;
    background: transparent;
    border-radius: 6px;
    cursor: grab;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar .tier-item {
    width: 100%;
    height: 80px;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
}

.sidebar .tier-item img {
    width: 80px;
    min-width: 80px;
    height: 80px;
    max-width: none;
    max-height: none;
    object-fit: contain;
    background-color: transparent;
    border-radius: 4px;
}

.sidebar .tier-item .item-title-overlay {
    display: block;
    position: relative;
    background: transparent;
    padding-left: 15px;
    font-size: 16px;
    text-align: left;
}

.tier-item:active { cursor: grabbing; }

.tier-item img {
    max-width: var(--item-size);
    max-height: var(--item-size);
    width: auto;
    height: auto;
    object-fit: contain; /* Rispetta aspect ratio senza tagliare nel tier */
    display: block;
}

.item-title-overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,0.7);
    color: white;
    font-size: 10px;
    text-align: center;
    padding: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: none; /* Nascosto nel tier, mostrato in sidebar */
}

.tier-items .tier-item:hover .item-title-overlay { display: block; }

/* MODAL */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal {
    background: var(--panel-bg);
    padding: 25px;
    border-radius: 8px;
    width: 400px;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.modal img {
    max-width: 100%;
    max-height: 250px;
    object-fit: contain;
    margin-bottom: 15px;
    background: #111;
    border-radius: 4px;
}

.modal h2 { margin-bottom: 20px; word-wrap: break-word;}
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 15px; }
.modal-actions button { flex: 1 1 calc(33% - 8px); }

/* SCROLLBAR */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track { background: var(--bg-color); }
::-webkit-scrollbar-thumb { background: #555; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #777; }

/* STILE PER VERSIONE STATICA */
.is-static .tier-item {
    cursor: default !important;
}

.is-static .tier-items .tier-item:hover .item-title-overlay {
    display: none !important;
}

.show-labels-always .tier-items .item-title-overlay {
    display: block !important;
}



::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #777;
}

/* Standard */
* {
    scrollbar-color: #555 var(--bg-color);
    scrollbar-width: thin;
}
