/* admin.css - Stili Pannello Amministratore */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color:  #059669;
    --primary-dark:   #047857;
    --primary-tint:   #d1fae5;
    --radius-card:    12px;
    --radius-btn:     8px;
    --btn-background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    --nav-dark: #1e293b;
    --nav-medium: #334155;
    --success-color: #22c55e;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 4px rgba(30,41,59,0.10);
    --shadow-lg: 0 10px 30px rgba(30,41,59,0.18);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

.hidden {
    display: none !important;
}

/* ===========================
   LOGIN SCREEN
   =========================== */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(150deg, #1e293b 0%, #334155 100%);
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    border-top: 4px solid var(--primary-color);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: var(--btn-background);
    color: white;
    border: none;
    border-radius: var(--radius-btn);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(0,52,98,0.25);
    letter-spacing: 0.02em;
}

.btn-login:hover {
    opacity: 0.92;
    box-shadow: 0 6px 18px rgba(0,52,98,0.38);
}

.error-message {
    margin-top: 15px;
    padding: 12px;
    background: #fee;
    color: var(--danger-color);
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
}

/* ===========================
   ADMIN PANEL
   =========================== */

.admin-header {
    background: white;
    padding: 16px 40px;
    border-bottom: 3px solid var(--primary-color);
    box-shadow: 0 2px 8px rgba(30,41,59,0.07);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left h1 {
    font-size: 22px;
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: 0.01em;
}

.header-subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 2px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.admin-info {
    color: var(--text-secondary);
    font-size: 13px;
}

.btn-logout {
    padding: 7px 18px;
    background: var(--bg-color);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.2s, border-color 0.2s;
}

.btn-logout:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

/* ===========================
   NAVIGATION
   =========================== */

.admin-nav {
    background: white;
    padding: 0 40px;
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--border-color);
    overflow-x: auto;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.nav-tab {
    padding: 14px 18px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
    white-space: nowrap;
    letter-spacing: 0.01em;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.nav-tab:hover {
    color: var(--primary-color);
    background: #f1f5f9;
}

.nav-tab.active {
    color: var(--primary-dark);
    border-bottom-color: var(--primary-color);
    font-weight: 700;
    background: linear-gradient(to bottom, transparent 70%, rgba(0,0,0,0.03) 100%);
}

/* ===========================
   MESSAGES
   =========================== */

.admin-message {
    margin: 20px 40px;
    padding: 15px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
}

.admin-message.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.admin-message.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* ===========================
   CONTENT
   =========================== */

.admin-content {
    padding: 30px 40px;
    max-width: 1400px;
    margin: 0 auto;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.section-header h2 {
    font-size: 28px;
    color: var(--text-primary);
}

/* ===========================
   STATS GRID
   =========================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 22px 24px;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 18px;
    border-left: 4px solid var(--primary-color);
    transition: box-shadow 0.2s, transform 0.2s;
}

.stat-card:hover {
    box-shadow: 0 4px 16px rgba(0,52,98,0.14);
    transform: translateY(-1px);
}

.stat-icon {
    font-size: 36px;
    width: 56px;
    height: 56px;
    background: var(--primary-tint);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: 30px;
    font-weight: 800;
    color: var(--primary-dark);
    line-height: 1;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 5px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* PIN del giorno */
.pin-card {
    background: #fffbeb;
    border: 2px solid #fbbf24;
    border-radius: var(--radius-card);
    padding: 20px 24px;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.pin-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.pin-card-icon { font-size: 1.3rem; }

.pin-card-title {
    font-weight: 700;
    font-size: 1rem;
    color: #92400e;
}

.pin-card-note {
    font-size: 0.8rem;
    color: #b45309;
    margin-left: auto;
}

.pin-card-value {
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: 0.25em;
    color: #1f2937;
    font-variant-numeric: tabular-nums;
}

.pin-card-validity {
    font-size: 0.8rem;
    color: #9ca3af;
}

/* Modalità Reception card */
.reception-mode-card {
    background: #f0fdf4;
    border: 2px solid #86efac;
    border-radius: var(--radius-card);
    padding: 16px 20px;
    margin-bottom: 20px;
}

.reception-mode-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    color: #166534;
}

.reception-mode-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #166534;
    flex: 1;
}

.reception-mode-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
}

.reception-mode-badge-on {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.reception-mode-desc {
    font-size: 0.85rem;
    color: #374151;
    margin-bottom: 12px;
    line-height: 1.5;
}

.reception-mode-btn {
    background: var(--btn-background);
    color: white;
    border: none;
    border-radius: var(--radius-btn);
    padding: 8px 18px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}

.reception-mode-btn:hover { background: var(--primary-dark); }

.reception-mode-btn-off {
    background: #6b7280;
}

.reception-mode-btn-off:hover { background: #4b5563; }

.stat-card-large {
    background: white;
    padding: 30px;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-value-large {
    font-size: 48px;
    font-weight: 700;
    color: var(--primary-color);
    margin: 15px 0;
}

/* ===========================
   QUICK ACTIONS
   =========================== */

.quick-actions {
    background: white;
    padding: 25px;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
    border-top: 3px solid var(--primary-color);
}

.quick-actions h3 {
    margin-bottom: 20px;
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-dark);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.action-btn {
    padding: 14px 20px;
    background: var(--btn-background);
    color: white;
    border: none;
    border-radius: var(--radius-btn);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: opacity 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(0,52,98,0.20);
}

.action-btn:hover {
    opacity: 0.88;
    box-shadow: 0 4px 14px rgba(0,52,98,0.30);
}

.action-btn span {
    font-size: 24px;
}

/* ===========================
   FORMS
   =========================== */

.form-container {
    background: white;
    padding: 25px;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
    margin-bottom: 25px;
}

.form-container h3 {
    margin-bottom: 20px;
    font-size: 18px;
    color: var(--text-primary);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn-primary {
    padding: 10px 20px;
    background: var(--btn-background);
    color: white;
    border: none;
    border-radius: var(--radius-btn);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 6px rgba(0,86,157,0.25);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 10px rgba(0,52,98,0.30);
}

.btn-secondary {
    padding: 10px 20px;
    background: white;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s, border-color 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-color);
    border-color: #cbd5e1;
}

.btn-refresh {
    padding: 8px 16px;
    background: var(--success-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.export-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.btn-print {
    padding: 10px 16px;
    background: #475569;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-print:hover {
    background: #334155;
}

.btn-excel {
    padding: 10px 16px;
    background: #16a34a;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-excel:hover {
    background: #15803d;
}

/* ===========================
   FILTERS
   =========================== */

.filters {
    background: white;
    padding: 20px 25px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 25px;
    display: flex;
    gap: 25px;
}

.filters label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
}

.filters input[type="radio"] {
    cursor: pointer;
}

.date-filters {
    background: white;
    padding: 20px 25px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 25px;
    display: flex;
    gap: 15px;
    align-items: end;
    flex-wrap: wrap;
}

.date-filters .form-group {
    margin: 0;
}

.date-filters input[type="date"] {
    padding: 10px 14px;
}

/* ===========================
   TABLES
   =========================== */

.table-container {
    background: white;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table thead {
    background: linear-gradient(90deg, #1e293b 0%, #2d3f55 100%);
}

.admin-table th {
    padding: 13px 20px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: rgba(255,255,255,0.85);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.admin-table td {
    padding: 13px 20px;
    border-top: 1px solid var(--border-color);
    font-size: 14px;
}

.admin-table tbody tr:hover {
    background: #f0fdf9;
}

.loading, .no-data {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

/* ===========================
   BADGES & STATUS
   =========================== */

.badge-code {
    font-family: 'Courier New', monospace;
    background: var(--bg-color);
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 13px;
}

.badge-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-attivo {
    background: #d1fae5;
    color: #065f46;
}

.badge-disattivo {
    background: #fee2e2;
    color: #991b1b;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-completato {
    background: #e2e8f0;
    color: #475569;
}

.status-presenti {
    background: #d1fae5;
    color: #065f46;
}

.badge-chiuso-user {
    background: #d1fae5;
    color: #065f46;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.badge-chiuso-admin {
    background: #fef3c7;
    color: #92400e;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

/* ===========================
   BUTTONS IN TABLES
   =========================== */

.btn-danger-small {
    padding: 6px 12px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: opacity 0.2s;
}

.btn-danger-small:hover {
    opacity: 0.85;
}

.btn-success-small {
    padding: 6px 12px;
    background: var(--success-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: opacity 0.2s;
}

.btn-success-small:hover {
    opacity: 0.85;
}

.btn-warning {
    padding: 10px 20px;
    background: var(--warning-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: opacity 0.2s;
}

.btn-warning:hover { opacity: 0.85; }

.btn-danger {
    padding: 10px 20px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: opacity 0.2s;
}

.btn-danger:hover { opacity: 0.85; }

/* ===========================
   ALERTS
   =========================== */

.alert-info {
    background: var(--primary-tint);
    color: var(--text-primary);
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 25px;
    font-size: 14px;
    border-left: 4px solid var(--primary-color);
}

.alert-anomalo {
    background: #fef3c7 !important;
}

.alert-anomalo:hover {
    background: #fde68a !important;
}

/* ===========================
   RESPONSIVE
   =========================== */

@media (max-width: 768px) {
    .admin-header {
        padding: 15px 20px;
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .admin-nav {
        padding: 0 20px;
    }
    
    .admin-content {
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .date-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .admin-table {
        font-size: 12px;
    }
    
    .admin-table th,
    .admin-table td {
        padding: 10px 12px;
    }
}

/* Brand footer */
.brand-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 16px;
    font-size: 0.7rem;
    color: #94a3b8;
    border-top: 1px solid #f1f5f9;
    user-select: none;
}

.brand-footer strong {
    font-weight: 600;
    color: #64748b;
}