/* assets/css/style.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Palette Colori Premium - Hybrid Mode (Sidebar Scura, Content Chiaro) */
    --bg-main: #f1f5f9; /* Slate 100 (Sfondo principale) */
    --bg-sidebar: #0f172a; /* Slate 900 (Sidebar molto scura) */
    --bg-card: #ffffff; /* Bianco per i riquadri */
    
    --text-main: #1e293b; /* Testo scuro per il content */
    --text-secondary: #64748b; /* Testo grigio per il content */
    --text-sidebar: #94a3b8; /* Testo grigio chiaro per sidebar */
    --text-sidebar-hover: #ffffff;
    
    --accent-primary: #3b82f6; /* Blu acceso */
    --accent-hover: #2563eb;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --border-light: #e2e8f0; /* Slate 200 */
    --border-dark: #1e293b;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
    
    --radius-md: 8px;
    --radius-lg: 12px;
    
    --transition: all 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--accent-hover);
}

/* Tipografia */
h1, h2, h3, h4 {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 1rem;
}

p {
    color: var(--text-secondary);
}

/* Moduli Card (Addio Glassmorphism puro, benvenuto design Solid Premium) */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-main);
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.95rem;
    transition: var(--transition);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: #fff;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.4);
}

.btn-outline {
    background-color: transparent;
    border-color: var(--border-light);
    color: var(--text-main);
}
.btn-outline:hover {
    background-color: var(--bg-main);
    border-color: var(--text-secondary);
}

.btn-block {
    width: 100%;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* Badge States */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-success { background-color: #d1fae5; color: #065f46; }
.badge-warning { background-color: #fef3c7; color: #92400e; }
.badge-danger { background-color: #fee2e2; color: #991b1b; }

/* Utility per Layout di Login */
.login-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background-color: var(--bg-sidebar);
    background-image: radial-gradient(circle at top right, rgba(59, 130, 246, 0.15), transparent 50%);
}

.login-box {
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}
.login-header p {
    color: var(--text-secondary);
}

.login-logo {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--accent-primary);
    margin-bottom: 0.5rem;
}

/* --- DASHBOARD LAYOUT --- */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-dark);
}

.sidebar-logo {
    background-color: #ffffff;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    display: inline-block;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0;
}

.nav-item {
    display: block;
    padding: 0.85rem 1.5rem;
    color: var(--text-sidebar);
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-sidebar-hover);
}

.nav-item.active {
    background-color: rgba(59, 130, 246, 0.15);
    color: #ffffff;
    border-left-color: var(--accent-primary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 70px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 5;
}

.content-area {
    padding: 2rem;
    flex: 1;
    overflow-y: auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

/* Dashboard Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 0.2rem;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Tabelle */
.table-container {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    padding: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-light);
    font-size: 0.875rem;
    text-transform: uppercase;
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-main);
    font-size: 0.95rem;
}

tr:hover td {
    background-color: var(--bg-main);
}

/* --- MODALI --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background-color: var(--bg-card);
    border: none;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: var(--danger);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* BADGE CARTELLINO STYLES */
.badge-generator {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}
.badge-preview-container {
    background: #f8fafc;
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px dashed #cbd5e1;
    display: flex;
    justify-content: center;
    align-items: center;
}
.badge-card {
    width: 340px; 
    height: 250px; 
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    border: 1px solid #e2e8f0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.badge-card-header {
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: #ffffff;
    text-align: center;
    padding: 6px 5px;
    border-bottom: 3px solid var(--accent-primary);
}
.badge-card-title {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}
.badge-card-subtitle {
    font-size: 0.55rem;
    font-style: italic;
    color: #cbd5e1;
}
.badge-card-body {
    display: flex;
    flex: 1;
    background: #f1f5f9;
}
.badge-data-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 6px 8px;
    gap: 5px;
}
.badge-field {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 2px 6px;
    height: 26px;
}
.badge-field-label {
    font-size: 0.55rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    width: 40%;
    border-right: 1px solid #e2e8f0;
    margin-right: 6px;
}
.badge-field-value {
    font-size: 0.7rem;
    font-weight: 800;
    color: #0f172a;
    width: 60%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.badge-photo-container {
    width: 105px;
    background-color: #ffffff;
    border-left: 2px solid #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 6px;
}
.badge-photo-container .photo-wrapper {
    width: 100%;
    height: 100%;
    background-color: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.badge-photo-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media print {
    .sidebar, .topbar, .page-header, .glass-card, button {
        display: none !important;
    }
    body, .app-container, .main-content, .content-area, .badge-generator, .badge-preview-container {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        background: transparent !important;
    }
    #listView {
        display: none !important;
    }
    .badge-card {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        border: 1px solid #000 !important;
        width: 86mm !important;
        min-height: 54mm !important; height: auto !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        page-break-inside: avoid;
    }
}



/* ========================================= */
/* RESPONSIVE DESIGN & MOBILE OPTIMIZATION   */
/* ========================================= */

@media screen and (max-width: 768px) {
    /* Layout a colonna singola */
    .app-container {
        flex-direction: column;
    }
    
    /* Sidebar diventa una Topbar fissa */
    .sidebar {
        width: 100%;
        height: auto;
        padding: 1rem;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        position: static; /* non pił sticky se lo era */
    }
    
    .sidebar-logo img {
        max-height: 35px;
    }

    /* Menu orizzontale scorrevole per mobile */
    .sidebar-nav {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        white-space: nowrap;
        gap: 10px;
        margin-top: 10px;
        padding-bottom: 5px;
    }
    
    .sidebar-nav .nav-item {
        margin-bottom: 0;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    /* Aggiustamento margini contenuti principali */
    .main-content {
        width: 100%;
        padding: 0;
    }
    
    .topbar {
        padding: 1rem;
        font-size: 0.9rem;
    }
    
    .content-area {
        padding: 1rem;
    }

    /* Stack dei form su mobile */
    .form-row {
        flex-direction: column;
        gap: 1rem;
    }
    
    .form-group {
        width: 100% !important;
    }

    /* Gestione delle tabelle su mobile */
    .table-container {
        overflow-x: auto;
        display: block;
        width: 100%;
    }
    
    table {
        min-width: 600px; /* forza lo scroll orizzontale se i dati sono molti */
    }

    /* Generatore badge layout a stack */
    .badge-generator {
        flex-direction: column;
    }
    
    .badge-preview-container {
        margin-top: 2rem;
        display: flex;
        justify-content: center;
    }

    /* Modali pił piccole e adattabili */
    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 1.5rem;
    }
}
