/* ===== SalonUp Design System ===== */
/* Variabili tema: light = bianco/blu stile Facebook, dark = nero/grigio */

:root {
    --bg: #f0f2f5;
    --surface: #ffffff;
    --surface-alt: #e9ebee;
    --border: #dcdfe4;
    --text: #1c1e21;
    --text-muted: #65676b;
    --primary: #1877f2;
    --primary-hover: #166fe5;
    --primary-text: #ffffff;
    --sidebar-bg: #ffffff;
    --danger-bg: #fde2e1;
    --danger-text: #c0392b;
    --danger-border: #f5b7b1;
    --success-bg: #e3f3e3;
    --success-text: #2e7d32;
    --success-border: #b7e0b8;
    --warning-bg: #fff4e0;
    --warning-text: #a15c00;
    --warning-border: #f0d8a8;
    --radius: 10px;
}

[data-theme="dark"] {
    --bg: #121212;
    --surface: #1e1e1e;
    --surface-alt: #2a2a2a;
    --border: #333333;
    --text: #e8e8e8;
    --text-muted: #a0a0a0;
    --primary: #4a9eff;
    --primary-hover: #6bb0ff;
    --primary-text: #0d0d0d;
    --sidebar-bg: #1a1a1a;
    --danger-bg: #3a1f1f;
    --danger-text: #f0b8b8;
    --danger-border: #5c2a2a;
    --success-bg: #1f3a24;
    --success-text: #b8f0c8;
    --success-border: #2a5c3a;
    --warning-bg: #3a2f1a;
    --warning-text: #eab84a;
    --warning-border: #5c4a2a;
}

* { box-sizing: border-box; }

html {
    overflow-x: hidden;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background 0.15s ease, color 0.15s ease;
    overflow-x: hidden;
}

a { color: var(--primary); }

/* ===== Auth (login/register/setup) ===== */

.auth-box {
    max-width: 380px;
    margin: 60px auto;
    background: var(--surface);
    padding: 32px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.language-switcher {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 16px;
}

.language-switcher a {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.language-switcher a.active {
    background: var(--primary);
    color: var(--primary-text);
    border-color: var(--primary);
}

.translation-table td {
    vertical-align: top;
}

.translation-input {
    width: 100%;
    min-height: 38px;
    resize: vertical;
    font-family: inherit;
    font-size: 13px;
}

.auth-box h1 {
    margin: 0 0 4px;
    color: var(--primary);
}

.subtitle {
    color: var(--text-muted);
    margin: 0 0 20px;
}

/* ===== Forms ===== */

label {
    display: block;
    margin: 14px 0 6px;
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}

input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    -webkit-appearance: none;
    appearance: none;
}

input[type="checkbox"],
input[type="radio"] {
    width: 16px;
    height: 16px;
    min-width: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
}

textarea { resize: vertical; }

button {
    width: 100%;
    margin-top: 20px;
    padding: 12px;
    background: var(--primary);
    color: var(--primary-text);
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
}

button:hover { background: var(--primary-hover); }

.link {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
}

.link a { text-decoration: none; }

/* ===== Alerts ===== */

.alert {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger-text);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 8px;
}

.alert-success {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success-text);
}

/* ===== App shell (sidebar + content) ===== */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.sidebar-brand {
    font-weight: 700;
    font-size: 18px;
    color: var(--primary);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.sidebar nav a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar nav a:hover {
    background: var(--surface-alt);
}

.sidebar nav a.active {
    background: var(--primary);
    color: var(--primary-text);
}

.sidebar nav a.disabled {
    color: var(--border);
    cursor: default;
}

.sidebar nav a.disabled:hover { background: none; }

.sidebar-user {
    border-top: 1px solid var(--border);
    padding-top: 14px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user-link {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: var(--text);
}

.sidebar-user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.sidebar-user .logout {
    color: var(--danger-text);
    text-decoration: none;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.quicklinks {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
}

.quicklink-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    border-radius: 8px;
    background: var(--surface-alt);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 10px;
    text-align: center;
    border: 1px solid transparent;
}

.quicklink-btn:hover {
    border-color: var(--border);
    color: var(--text);
}

.quicklink-btn.disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.icon-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.content {
    flex: 1;
    padding: 32px 40px;
    min-width: 0;
    margin-left: 220px;
}

/* ===== Topbar (mobile hamburger + theme toggle) ===== */

.topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border);
}

.topbar-brand {
    font-weight: 700;
    color: var(--primary);
}

.nav-toggle-checkbox {
    display: none;
}

.nav-toggle-label {
    display: none;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    color: var(--text);
    background: none;
    padding: 4px 8px;
    width: auto;
    margin: 0;
}

/* ===== Theme toggle ===== */

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
    text-decoration: none;
    width: auto;
    margin: 0;
    cursor: pointer;
}

.theme-toggle:hover { background: var(--border); }

/* ===== Cards ===== */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

/* ===== Badges ===== */

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-pilot { background: var(--success-bg); color: var(--success-text); }
.badge-trial { background: var(--warning-bg); color: var(--warning-text); }
.badge-active { background: var(--success-bg); color: var(--success-text); }
.badge-suspended { background: var(--danger-bg); color: var(--danger-text); }

/* ===== Buttons / links ===== */

.btn-link {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    border-radius: 8px;
}

.btn-link:hover { background: var(--surface-alt); }

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid var(--danger-border);
}

/* ===== Inline forms ===== */

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.inline-form input[type="text"] {
    width: auto;
    flex: 1;
    min-width: 150px;
}

.inline-form button {
    margin: 0;
    padding: 10px 16px;
    width: auto;
}

/* ===== Tables ===== */

.su-table {
    width: 100%;
    border-collapse: collapse;
}

.su-table th, .su-table td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.su-table th {
    color: var(--text-muted);
    font-weight: 500;
}

.su-table .actions a {
    color: var(--primary);
    text-decoration: none;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.su-table td.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    align-items: center;
}

.content button, .content .btn-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: auto;
    padding: 10px 18px;
    margin-top: 16px;
    margin-right: 8px;
}

.table-scroll {
    overflow-x: auto;
}

code {
    background: var(--surface-alt);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

/* ===== Misc ===== */

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
}

.admin-tag {
    background: var(--warning-text);
    color: #1a1408;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    vertical-align: middle;
    margin-left: 6px;
}

.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 32px 20px;
    text-align: center;
    background: var(--surface-alt);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.dropzone-text {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 4px;
}

.dropzone-dragging {
    border-color: var(--primary);
    background: var(--surface);
}

.dropzone-has-file {
    border-color: var(--success-border);
}

.dropzone-has-file .dropzone-text {
    color: var(--success-text);
    font-weight: 600;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-num {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ===== Menu a categorie (fisarmonica) ===== */

.nav-category {
    margin-bottom: 2px;
}

.nav-cat-toggle {
    display: none;
}

.nav-cat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
}

.nav-cat-header:hover {
    background: var(--surface-alt);
}

.nav-cat-chevron {
    transition: transform 0.15s ease;
    display: flex;
}

.nav-cat-toggle:checked ~ .nav-cat-header .nav-cat-chevron {
    transform: rotate(90deg);
}

.nav-cat-items {
    display: none;
    flex-direction: column;
    gap: 2px;
    padding-left: 4px;
}

.nav-cat-toggle:checked ~ .nav-cat-items {
    display: flex;
}

.nav-flat-item {
    margin-bottom: 2px;
}

.nav-toplevel {
    margin-bottom: 4px;
}

.nav-toplevel-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}

.nav-toplevel-link:hover {
    background: var(--surface-alt);
}

.nav-toplevel-link.active {
    background: var(--primary);
    color: var(--primary-text);
}

.nav-sublist {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: 30px;
    margin: 2px 0 6px;
}

.nav-sublist a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 6px;
}

.nav-sublist a:hover {
    background: var(--surface-alt);
}

.nav-sublist a.active {
    background: var(--primary);
    color: var(--primary-text);
}

/* ===== Toolbar lista (ricerca + filtri + vista) ===== */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.page-header h1 {
    margin: 0;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--primary-text);
    text-decoration: none;
    flex-shrink: 0;
    border: none;
    cursor: pointer;
}

.btn-icon:hover {
    background: var(--primary-hover);
}

.list-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-input-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.search-input-wrap input {
    padding-left: 36px;
    height: 42px;
}

.search-input-wrap .search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
}

.filter-toggle-btn {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.filter-toggle-btn:hover, .filter-toggle-btn.filter-active {
    background: var(--surface-alt);
    color: var(--text);
}

.filter-panel {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.filter-checkbox-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin: 8px 0 4px;
}

.filter-checkbox-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
}

.filter-checkbox-row input[type="checkbox"] {
    width: auto;
}

.results-loading {
    opacity: 0.5;
    pointer-events: none;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
}

.view-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.view-toggle-btn {
    height: 42px;
    padding: 0 12px;
    color: var(--text-muted);
    background: var(--surface);
    text-decoration: none;
    display: flex;
    align-items: center;
}

.view-toggle-btn:hover {
    background: var(--surface-alt);
}

.view-toggle-active {
    background: var(--primary);
    color: var(--primary-text);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.entity-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: center;
    align-items: center;
}

.entity-card-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.entity-card-title {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.entity-card-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.entity-card-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 10px;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    width: 100%;
}

.entity-card-actions a {
    color: var(--primary);
    text-decoration: none;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ===== Responsive: mobile ===== */

@media (max-width: 860px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    .topbar {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 60;
    }
    .nav-toggle-label { display: inline-block; }

    /* L'header e' fisso: aggiungiamo lo spazio equivalente in cima
       cosi' il contenuto non ci finisce sotto. */
    .app-shell {
        flex-direction: column;
        padding-top: 52px;
    }

    .content {
        margin-left: 0;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        width: 240px;
        box-shadow: 2px 0 10px rgba(0,0,0,0.15);
        padding-top: 60px;
    }

    .nav-toggle-checkbox:checked ~ .app-shell .sidebar {
        transform: translateX(0);
    }

    /* Overlay scuro dietro il menu: cliccandoci sopra si chiude
       (stessa checkbox, e' un secondo <label> che la spegne). */
    .nav-overlay {
        display: none;
    }

    .nav-toggle-checkbox:checked ~ .app-shell .nav-overlay {
        display: block;
        position: fixed;
        inset: 0;
        top: 52px;
        background: rgba(0, 0, 0, 0.4);
        z-index: 45;
    }

    .content {
        padding: 20px 16px;
    }

    .su-table { font-size: 13px; }

    .auth-box {
        margin: 24px 16px;
        padding: 24px;
    }
}

/* ===== Footer ===== */

.site-footer {
    text-align: center;
    padding: 20px 16px;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: 24px;
}

.site-footer a {
    color: var(--text-muted);
    text-decoration: underline;
}
