/* ============================================================
   mini5.it — Design System Responsive
   Mobile-first approach con card-based layout
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&family=Syne:wght@400;600;800&display=swap');

:root {
    --bg:        #0f0f0f;
    --surface:   #1a1a1a;
    --surface2:  #242424;
    --border:    #2e2e2e;
    --text:      #e8e6e1;
    --muted:     #6b7280;
    --accent:    #e8631a;
    --accent-lt: #f4844a;
    --danger:    #e74c3c;
    --success:   #27ae60;
    --radius:    8px;
    --mono:      'IBM Plex Mono', monospace;
    --sans:      'Syne', sans-serif;
    --nav-height: 64px;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

html { 
    font-size: 16px; 
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    line-height: 1.6;
    min-height: 100vh;
}

/* ============================================================
   LAYOUT RESPONSIVE
   ============================================================ */
.container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

@media (min-width: 640px) {
    .container {
        padding: 2rem 1.5rem 4rem;
    }
}

/* ============================================================
   NAVIGATION - RESPONSIVE CON HAMBURGER
   ============================================================ */
#main-nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    height: var(--nav-height);
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 1rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* Logo */
.nav-logo {
    font-family: var(--mono);
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: -0.5px;
    z-index: 1001;
}

/* Hamburger button (solo mobile) */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.hamburger {
    position: relative;
    width: 24px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: background 0.3s;
}

.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform 0.3s, top 0.3s, bottom 0.3s;
}

.hamburger::before { top: -7px; }
.hamburger::after { bottom: -7px; }

/* Animazione hamburger → X */
.nav-toggle.active .hamburger {
    background: transparent;
}

.nav-toggle.active .hamburger::before {
    top: 0;
    transform: rotate(45deg);
}

.nav-toggle.active .hamburger::after {
    bottom: 0;
    transform: rotate(-45deg);
}

/* Menu principale */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex: 1;
    justify-content: space-between;
    margin-left: 2rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.2s;
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--text);
}

.nav-link-admin {
    color: var(--accent);
}

.nav-link-admin:hover {
    color: var(--accent-lt);
}

/* User profile section */
.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    transition: background 0.2s;
}

.nav-profile:hover {
    background: var(--surface);
}

.nav-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.nav-avatar-icon {
    font-size: 1.2rem;
}

.nav-username {
    font-size: 0.85rem;
    font-family: var(--mono);
    color: var(--muted);
}

.nav-badge {
    font-size: 0.65rem;
    background: var(--accent)22;
    color: var(--accent);
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
    font-weight: 700;
    font-family: var(--mono);
}

/* Guest buttons */
.nav-guest {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ============================================================
   RESPONSIVE NAV - MOBILE
   ============================================================ */
@media (max-width: 768px) {
    .nav-toggle {
        display: flex;
    }

    .nav-menu {
        position: fixed;
        top: var(--nav-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--bg);
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        gap: 0;
        margin: 0;
        padding: 1.5rem;
        overflow-y: auto;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }

    .nav-menu.active {
        transform: translateX(0);
    }

    .nav-links {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        width: 100%;
        margin-bottom: 1.5rem;
        padding-bottom: 1.5rem;
        border-bottom: 1px solid var(--border);
    }

    .nav-link {
        padding: 0.875rem 1rem;
        font-size: 1rem;
        border-radius: var(--radius);
        transition: background 0.2s, color 0.2s;
        color: #ffffff; /* Bianco puro per massima visibilità */
    }

    .nav-link:hover {
        background: var(--surface);
        color: var(--accent);
    }

    .nav-link-admin {
        color: var(--accent); /* Admin restano arancio */
    }

    .nav-link-admin:hover {
        color: var(--accent-lt);
    }

    .nav-user {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        width: 100%;
        padding-bottom: 1rem;
    }

    .nav-profile {
        padding: 1rem;
        background: var(--surface);
        justify-content: flex-start;
    }

    .nav-guest {
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
    }

    .nav-guest .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.2;
    margin-bottom: 1.5rem;
}

@media (min-width: 640px) {
    h1 {
        font-size: 2rem;
    }
}

h2 {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 1rem;
}

.mono { 
    font-family: var(--mono); 
    letter-spacing: -0.5px; 
}

/* ============================================================
   CARDS - BASE SYSTEM
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

@media (min-width: 640px) {
    .card {
        padding: 1.5rem;
        margin-bottom: 1.5rem;
    }
}

/* ============================================================
   BUTTONS - RESPONSIVE
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 1.2rem;
    border-radius: var(--radius);
    font-family: var(--sans);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    white-space: nowrap;
    text-align: center;
}

.btn-sm {
    padding: 0.4rem 0.9rem;
    font-size: 0.8rem;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-primary:hover { 
    background: var(--accent-lt); 
    border-color: var(--accent-lt); 
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

.btn-outline:hover { 
    border-color: var(--accent); 
    color: var(--accent); 
}

.btn-ghost {
    background: transparent;
    color: var(--accent);
    border-color: transparent;
}

.btn-ghost:hover { 
    color: var(--accent-lt);
    background: var(--accent)15;
}

/* Link button - per navigazione e azioni terziarie */
.btn-link {
    background: transparent;
    color: var(--accent);
    border-color: transparent;
    text-decoration: none;
    padding: 0.4rem 0.8rem;
    font-weight: 500;
}

.btn-link:hover {
    color: var(--accent-lt);
    text-decoration: none;
}

@media (max-width: 480px) {
    .btn {
        width: 100%;
        padding: 0.75rem 1rem;
    }

    .btn-sm {
        width: auto;
    }
}

/* ============================================================
   FORMS - RESPONSIVE
   ============================================================ */
.form-group { 
    margin-bottom: 1.25rem; 
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

input[type="text"],
input[type="url"],
input[type="password"],
input[type="email"],
input[type="tel"],
textarea,
select {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.9rem;
    padding: 0.75rem 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent)22;
}

textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.5;
}

/* Input con occhio password */
.input-eye {
    position: relative;
    display: flex;
    align-items: center;
}

.input-eye input {
    width: 100%;
    padding-right: 3rem;
}

.input-eye button {
    position: absolute;
    right: 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    padding: 0.5rem;
    display: flex;
    align-items: center;
    transition: color 0.2s;
    font-size: 1.1rem;
}

.input-eye button:hover { 
    color: var(--accent); 
}

/* Form layout a due colonne */
.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .form-row {
        grid-template-columns: 1fr 1fr;
    }
}

.section-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    border-left: 3px solid;
}

.alert-error   { 
    background: var(--danger)15;  
    border-color: var(--danger);  
    color: #fca5a5; 
}

.alert-success { 
    background: var(--success)15; 
    border-color: var(--success); 
    color: #86efac; 
}

/* ============================================================
   HERO SECTION
   ============================================================ */
.hero {
    padding: 2rem 0 1.5rem;
    text-align: center;
}

@media (min-width: 640px) {
    .hero {
        padding: 3rem 0 2rem;
    }
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 100%;
    margin: 0 auto;
}

@media (min-width: 640px) {
    .search-form {
        flex-direction: row;
        gap: 0.5rem;
        max-width: 520px;
    }

    .search-form input { 
        flex: 1; 
    }
}

/* ============================================================
   STATS HEADER - RESPONSIVE
   ============================================================ */
.stats-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

@media (min-width: 640px) {
    .stats-header {
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
        gap: 1.5rem;
    }
}

.stats-header h1 {
    font-size: 1.75rem;
    color: var(--accent);
    margin-bottom: 0.3rem;
}

@media (min-width: 640px) {
    .stats-header h1 {
        font-size: 2.5rem;
    }
}

.long-url {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.75rem;
    text-decoration: none;
    word-break: break-all;
    display: block;
}

@media (min-width: 640px) {
    .long-url {
        font-size: 0.8rem;
    }
}

.long-url:hover { 
    color: var(--accent); 
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

/* ============================================================
   KPI GRID - RESPONSIVE
   ============================================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 480px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.kpi-card.accent {
    border-color: var(--accent)55;
    background: var(--accent)0d;
}

.kpi-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.kpi-value {
    font-family: var(--mono);
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1;
}

@media (min-width: 640px) {
    .kpi-value {
        font-size: 2rem;
    }
}

.kpi-card.accent .kpi-value { 
    color: var(--accent); 
}

/* ============================================================
   CHARTS GRID - RESPONSIVE
   ============================================================ */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.chart-card.wide { 
    grid-column: 1 / -1; 
}

.chart-card canvas { 
    max-height: 220px;
    width: 100% !important;
    height: auto !important;
}

/* ============================================================
   DATA LISTS - RESPONSIVE
   ============================================================ */
.data-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.data-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}

.data-label {
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.data-count {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--accent);
    flex-shrink: 0;
}

/* ============================================================
   DATA TABLE - RESPONSIVE
   ============================================================ */
.table-wrapper {
    overflow-x: auto;
    margin: 0 -1rem;
    padding: 0 1rem;
}

@media (min-width: 640px) {
    .table-wrapper {
        margin: 0;
        padding: 0;
    }
}

.data-table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tr:last-child td { 
    border-bottom: none; 
}

.data-table tr:hover td { 
    background: var(--surface2); 
}

.table-title {
    display: block;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================
   QR GENERATOR - RESPONSIVE
   ============================================================ */
#qr-panel canvas { 
    image-rendering: pixelated;
    max-width: 100%;
    height: auto;
}

.qr-presets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1rem;
}

@media (min-width: 640px) {
    .qr-presets {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }
}

.qr-preset {
    width: 100%;
    min-width: 80px;
    height: 52px;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    cursor: pointer;
    background: var(--surface2);
    transition: border-color 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
    text-align: center;
    line-height: 1.3;
    padding: 0 0.5rem;
}

@media (min-width: 640px) {
    .qr-preset {
        width: 100px;
    }
}

.qr-preset:hover  { 
    border-color: var(--accent); 
    transform: scale(1.05); 
    color: var(--text); 
}

.qr-preset.active { 
    border-color: var(--accent); 
    box-shadow: 0 0 0 3px var(--accent)33; 
    color: var(--accent); 
}

.qr-preset-swatch {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: calc(var(--radius) - 2px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    font-family: var(--mono);
    line-height: 1.3;
    text-align: center;
    padding: 0 6px;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-logo {
    font-family: var(--mono);
    font-size: 1.3rem;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 1rem;
    text-align: center;
}

@media (min-width: 640px) {
    .login-logo {
        font-size: 1.5rem;
    }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.hint { 
    color: var(--muted); 
    font-size: 0.875rem; 
    margin-top: 1.5rem; 
}

.hint a { 
    color: var(--accent); 
    text-decoration: none; 
}

.hint a:hover { 
    text-decoration: underline; 
}

.empty { 
    color: var(--muted); 
    font-size: 0.875rem; 
    font-style: italic; 
}

.meta {
    color: var(--muted);
    font-size: 0.8rem;
    font-family: var(--mono);
    margin-top: 1rem;
}

/* Text overflow utilities */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-break {
    word-break: break-word;
    overflow-wrap: break-word;
}

.text-break-all {
    word-break: break-all;
}

/* Classi utility responsive */
.hide-mobile {
    display: none;
}

@media (min-width: 768px) {
    .hide-mobile {
        display: block;
    }
}

.show-mobile {
    display: block;
}

@media (min-width: 768px) {
    .show-mobile {
        display: none;
    }
}

/* ============================================================
   ANIMATIONS & TRANSITIONS
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================
   VCARD & BIO PAGE - Responsive
   ============================================================ */
.vcard-field,
.bio-field {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    align-items: flex-start;
}

.vcard-field-label,
.bio-field-label {
    flex-shrink: 0;
    min-width: 80px;
    color: var(--muted);
    font-size: 0.85rem;
}

.vcard-field-value,
.bio-field-value {
    flex: 1;
    min-width: 0; /* Importante per flex overflow */
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Link lunghi (email, URL) */
.vcard-field-value a,
.bio-field-value a {
    word-break: break-all; /* Spezza anche le email lunghe */
    color: var(--accent);
    text-decoration: none;
}

.vcard-field-value a:hover {
    text-decoration: underline;
}

@media (max-width: 480px) {
    .vcard-field,
    .bio-field {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .vcard-field-label,
    .bio-field-label {
        min-width: 0;
        font-weight: 600;
    }
}

/* ============================================================
   NFC CONFIGURATOR - Stepper responsive
   ============================================================ */
.nfc-stepper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    overflow-x: auto;
    padding: 0.5rem 0;
}

.nfc-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 60px;
}

.nfc-step-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-family: var(--sans);
    color: var(--muted);
    flex-shrink: 0;
}

.nfc-step.active .nfc-step-number {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.nfc-step.completed .nfc-step-number {
    background: var(--surface2);
    border-color: var(--accent);
    color: var(--accent);
}

.nfc-step-label {
    font-size: 0.75rem;
    color: var(--muted);
    text-align: center;
    white-space: nowrap;
}

.nfc-step.active .nfc-step-label {
    color: var(--accent);
    font-weight: 600;
}

@media (max-width: 640px) {
    .nfc-stepper {
        justify-content: flex-start;
        gap: 1rem;
    }
    
    .nfc-step {
        min-width: 50px;
        flex: 0 0 auto;
    }
    
    .nfc-step-number {
        width: 32px;
        height: 32px;
        font-size: 0.85rem;
    }
    
    .nfc-step-label {
        font-size: 0.65rem;
        max-width: 60px;
        white-space: normal;
        line-height: 1.2;
    }
}

/* ============================================================
   ADMIN TAB NAV - Fix globale per tutte le sezioni admin
   Si applica a: .admin-nav, .cms-nav, .plans-nav, .api-nav, .bio-tabs
   ============================================================ */
.admin-nav,
.cms-nav,
.plans-nav,
.api-nav,
.bio-tabs {
    display: flex !important;
    gap: 0.25rem !important;
    margin-bottom: 2rem !important;
    border-bottom: 1px solid var(--border) !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 0 !important;
    /* Padding per evitare che il primo/ultimo tab siano tagliati */
    padding-left: 2px !important;
    padding-right: 2px !important;
    scrollbar-width: thin;
    white-space: nowrap;
    /* Indicatore visivo che si può scorrere */
    scroll-snap-type: x proximity;
    /* Ombra ai lati per indicare scroll possibile (mascherata) */
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 8px, #000 calc(100% - 8px), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 8px, #000 calc(100% - 8px), transparent 100%);
}

.admin-nav::-webkit-scrollbar,
.cms-nav::-webkit-scrollbar,
.plans-nav::-webkit-scrollbar,
.api-nav::-webkit-scrollbar,
.bio-tabs::-webkit-scrollbar {
    height: 4px !important;
    width: 0 !important;
}

.admin-nav::-webkit-scrollbar-track,
.cms-nav::-webkit-scrollbar-track,
.plans-nav::-webkit-scrollbar-track,
.api-nav::-webkit-scrollbar-track,
.bio-tabs::-webkit-scrollbar-track {
    background: transparent !important;
}

.admin-nav::-webkit-scrollbar-thumb,
.cms-nav::-webkit-scrollbar-thumb,
.plans-nav::-webkit-scrollbar-thumb,
.api-nav::-webkit-scrollbar-thumb,
.bio-tabs::-webkit-scrollbar-thumb {
    background: var(--border) !important;
    border-radius: 2px !important;
}

.admin-nav a,
.cms-nav a,
.plans-nav a,
.api-nav a,
.bio-tabs a,
.bio-tabs button {
    padding: 0.75rem 1.2rem !important;
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    color: var(--muted) !important;
    text-decoration: none !important;
    border-bottom: 2px solid transparent !important;
    margin-bottom: -1px !important;
    transition: color 0.15s, border-color 0.15s !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    background: transparent !important;
    cursor: pointer;
    line-height: 1.4 !important;
    scroll-snap-align: start;
}

.admin-nav a:hover,
.cms-nav a:hover,
.plans-nav a:hover,
.api-nav a:hover,
.bio-tabs a:hover,
.bio-tabs button:hover {
    color: var(--text) !important;
}

.admin-nav a.active,
.cms-nav a.active,
.plans-nav a.active,
.api-nav a.active,
.bio-tabs a.active,
.bio-tabs button.active {
    color: var(--accent) !important;
    border-bottom-color: var(--accent) !important;
}

/* MOBILE: tab vanno a capo, niente scroll orizzontale */
@media (max-width: 768px) {
    .admin-nav,
    .cms-nav,
    .plans-nav,
    .api-nav,
    .bio-tabs {
        overflow-x: hidden !important;
        flex-wrap: wrap !important;
        gap: 0 !important;
        /* Rimuovo il mask fade che non serve più senza scroll */
        -webkit-mask-image: none !important;
        mask-image: none !important;
    }
}

/* ============================================================
   ADMIN TABLE WRAPPER - Fix globale tabelle admin
   ============================================================ */
.admin-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
}

.admin-table-wrapper table {
    margin: 0;
    min-width: 600px;
}

/* Forza scroll orizzontale anche per .card con padding:0 (legacy admin) */
.card[style*="padding:0"] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ============================================================
   BTN DANGER SOFT - Per delete buttons admin
   ============================================================ */
.btn-danger-soft {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger-soft:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: #fca5a5;
}

/* ============================================================
   PUBLIC CONTENT - Fix overflow blog/CMS
   Si applica a contenuti generati dall'editor TinyMCE
   ============================================================ */

/* Contenitori pubblici principali */
.public-page,
.pub-article,
.pub-article-content,
.post-content,
.page-content,
article {
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Tutti i blocchi di contenuto */
.pub-article-content *,
.post-content *,
.page-content * {
    max-width: 100%;
    box-sizing: border-box;
}

/* PRE/CODE: blocchi di codice che NON devono mai straripare */
.pub-article-content pre,
.post-content pre,
.page-content pre {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    overflow-x: auto;             /* Scroll SOLO nel blocco pre */
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    font-family: var(--mono);
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-wrap;        /* Va a capo se possibile */
    word-wrap: break-word;        /* Spezza parole lunghe */
    word-break: break-all;        /* Spezza anche URL */
}

.pub-article-content code,
.post-content code,
.page-content code {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.15rem 0.4rem;
    font-family: var(--mono);
    font-size: 0.85em;
    color: var(--accent);
    word-break: break-all;        /* Spezza URL lunghi */
    white-space: normal;          /* Va a capo nel testo */
}

/* Code dentro pre: rimuovi doppio styling */
.pub-article-content pre code,
.post-content pre code,
.page-content pre code {
    background: none;
    border: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

/* LINK (a) - URL lunghi vanno a capo */
.pub-article-content a,
.post-content a,
.page-content a {
    word-break: break-word;
    overflow-wrap: break-word;
}

/* IMG - immagini sempre responsive */
.pub-article-content img,
.post-content img,
.page-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1rem auto;
    border-radius: 8px;
}

/* TABLE - tabelle scrollabili */
.pub-article-content table,
.post-content table,
.page-content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    white-space: nowrap;
}

/* IFRAME (video YouTube/Vimeo embed) */
.pub-article-content iframe,
.post-content iframe,
.page-content iframe {
    max-width: 100%;
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    border-radius: 8px;
    border: 0;
}

/* BLOCKQUOTE */
.pub-article-content blockquote,
.post-content blockquote,
.page-content blockquote {
    border-left: 3px solid var(--accent);
    padding: 0.5rem 0 0.5rem 1rem;
    margin: 1rem 0;
    color: var(--muted);
    font-style: italic;
    word-wrap: break-word;
}

/* Heading - parole lunghe vanno a capo */
.pub-article-content h1,
.pub-article-content h2,
.pub-article-content h3,
.pub-article-content h4,
.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.page-content h1,
.page-content h2,
.page-content h3,
.page-content h4 {
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}

/* Mobile: padding ridotto e font più piccoli su pre/code */
@media (max-width: 640px) {
    .pub-article-content pre,
    .post-content pre,
    .page-content pre {
        padding: 0.75rem;
        font-size: 0.75rem;
    }
    
    .pub-article-content,
    .post-content,
    .page-content {
        font-size: 0.95rem;
    }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
    #main-nav,
    .btn,
    .header-actions {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .card {
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
}
