/* ------------------------------
   RESET & DESIGN TOKENS (stessi di BluSpoty, per coerenza visiva)
------------------------------ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-void: #04060d;
    --bg-base: #080c18;
    --bg-surface: #0e1424;
    --bg-surface-hover: #141b32;
    --bg-elevated: #17203a;
    --border-subtle: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text-primary: #f3f5ff;
    --text-secondary: #96a0c4;
    --text-tertiary: #5b6690;
    --accent: #3d5cff;
    --accent-bright: #6f8bff;
    --accent-dim: rgba(61, 92, 255, 0.16);
    --accent-gradient: linear-gradient(135deg, #3d5cff 0%, #7c5cff 100%);
    --danger: #ff4d6a;
    --danger-dim: rgba(255, 77, 106, 0.15);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow-elevated: 0 24px 60px rgba(0, 0, 0, 0.55);
    --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.3);
}

html, body {
    height: 100%;
}

body {
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
}

svg {
    width: 100%;
    height: 100%;
    display: block;
}

.icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.22);
    background-clip: padding-box;
}

/* ------------------------------
   BOTTONI (identici a BluSpoty)
------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 13.5px;
    font-weight: 600;
    transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}

.btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.btn:hover {
    background: var(--bg-surface-hover);
}

.btn:active {
    transform: scale(0.97);
}

.btn.primary {
    background: var(--accent-gradient);
    box-shadow: 0 6px 18px rgba(61, 92, 255, 0.35);
}

.btn.primary:hover {
    filter: brightness(1.08);
}

.btn.danger {
    background: var(--danger-dim);
    color: var(--danger);
}

.btn.danger:hover {
    background: rgba(255, 77, 106, 0.25);
}

.btn.ghost {
    background: transparent;
    border-color: var(--border-subtle);
    color: var(--text-secondary);
}

.btn.ghost:hover {
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.btn.icon-only {
    padding: 9px;
}

.btn.full-width {
    width: 100%;
    justify-content: center;
    margin-top: 6px;
}

/* ------------------------------
   LOGIN
------------------------------ */
.login-view {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 20%, var(--bg-surface) 0%, var(--bg-void) 70%);
}

.login-card {
    width: 340px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-elevated);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.login-card .brand {
    justify-content: center;
    margin-bottom: 10px;
}

.login-error {
    color: var(--danger);
    font-size: 13px;
    line-height: 1.4;
}

/* ------------------------------
   APP SHELL
------------------------------ */
.app-shell {
    height: 100vh;
    display: grid;
    grid-template-columns: 232px 1fr;
}

.sidebar {
    background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-void) 100%);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    gap: 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.brand-icon {
    width: 26px;
    height: 26px;
    object-fit: contain;
    flex-shrink: 0;
}

.tabs {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tab {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14.5px;
    font-weight: 500;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease;
}

.tab svg {
    width: 19px;
    height: 19px;
    flex-shrink: 0;
}

.tab:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.tab.active {
    background: var(--accent-dim);
    color: var(--accent-bright);
}

.sidebar-bottom-btn {
    margin-top: auto;
    width: 100%;
    justify-content: flex-start;
}

.main {
    min-width: 0;
    overflow-y: auto;
    padding: 28px 32px 40px;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.view-header h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 28px 0 12px;
}

.section-title:first-of-type {
    margin-top: 0;
}

/* ------------------------------
   TABELLE
------------------------------ */
.table-wrap {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    text-align: left;
    padding: 12px 16px;
    font-size: 13.5px;
}

.table th {
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-size: 11.5px;
    font-weight: 700;
    border-bottom: 1px solid var(--border-subtle);
}

.table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.15s ease;
}

.table tbody tr:last-child {
    border-bottom: none;
}

.table tbody tr:hover {
    background: var(--bg-surface-hover);
}

.table td {
    color: var(--text-primary);
}

.table td.muted {
    color: var(--text-secondary);
}

.table .row-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.empty-row td {
    color: var(--text-tertiary);
    text-align: center;
    padding: 28px 16px;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge.admin {
    background: var(--accent-dim);
    color: var(--accent-bright);
}

.badge.user {
    background: var(--bg-elevated);
    color: var(--text-tertiary);
}

.badge.online {
    background: rgba(52, 211, 153, 0.15);
    color: #34d399;
}

/* ------------------------------
   MODALI (identici a BluSpoty)
------------------------------ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(4, 6, 13, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    width: 360px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-elevated);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.modal-head h3 {
    font-size: 18px;
    font-weight: 700;
}

.field-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.field-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.4;
    margin-top: -4px;
}

.modal-content input,
select {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease;
}

.modal-content input:focus,
select:focus {
    border-color: var(--accent);
}

select {
    width: 100%;
    max-width: 360px;
    cursor: pointer;
}

.playlist-create-content {
    width: 460px;
    max-height: 80vh;
}

.playlist-select-row {
    display: flex;
    gap: 8px;
    margin: -4px 0 2px;
}

.playlist-select-row .btn {
    font-size: 12.5px;
    padding: 6px 12px;
}

.playlist-track-list {
    overflow-y: auto;
    max-height: 40vh;
    padding-right: 4px;
    margin: -2px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.items .item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.items .item:hover {
    background: var(--bg-surface-hover);
}

.items .item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.items .item-title {
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.items .item-sub {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item.selectable .item-check {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1.5px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.item.selectable .item-check svg {
    width: 12px;
    height: 12px;
}

.item.selectable.selected {
    background: var(--accent-dim);
    border-color: rgba(111, 139, 255, 0.3);
}

.item.selectable.selected .item-check {
    background: var(--accent-gradient);
    border-color: transparent;
    color: #fff;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
    cursor: pointer;
}

.checkbox-row input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.confirm-message {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.confirm-actions .btn {
    flex: 1;
    justify-content: center;
}

/* ------------------------------
   TOAST
------------------------------ */
.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    color: var(--text-primary);
    padding: 13px 20px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    font-weight: 500;
    box-shadow: var(--shadow-elevated);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    z-index: 1200;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Abbonamento MAX (paywall + badge) --- */
.paywall-bar {
    margin: 4px 0 18px;
    padding: 14px 16px;
    border: 1px solid var(--line, #2a2a33);
    border-radius: 14px;
    background: var(--surface, #17171d);
}
.paywall-bar .field-hint { margin: 6px 0 0; }
.badge.max {
    background: linear-gradient(90deg, #f5c451, #e0a020);
    color: #1a1205;
    font-weight: 700;
}
.btn.max-toggle { padding: 4px 12px; font-size: 13px; min-width: 74px; }

.btn.server-toggle { padding: 4px 10px; font-size: 12px; min-width: 84px; }
