/**
 * Stili Area Riservata ANFIT
 * Design moderno e responsive
 */

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

:root {
    /* Colori primari */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6; 

    /* Colori primari */
    --primary-color: #1e40af;   /* Blu più scuro, più vicino al logo */
    --primary-hover: #1e3a8a;   /* Ancora più scuro al hover */
    --secondary-color: #64748b;
    --success-color: #059669;   /* Verde più professionale */
    --danger-color: #dc2626;    /* Rosso più serio */
    --warning-color: #d97706;   /* Arancione più caldo */
    --info-color: #0284c7;      /* Blu informativo */

    /* Colori neutri */
    --bg-color: #f1f5f9;        /* Grigio molto chiaro con hint di blu */
    --bg-secondary: #ffffff;
    --text-primary: #0f172a;    /* Quasi nero con hint di blu */
    --text-secondary: #475569;  /* Grigio medio più scuro */
    --border-color: #cbd5e1;    /* Grigio-blu più definito */

    /* Ombre */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Border radius */
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    
    /* Transizioni */
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 16px;
}

/* ========================================
   TYPOGRAPHY
   ======================================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.1rem; }

p {
    margin-bottom: 1rem;
}

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

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

/* ========================================
   LAYOUT
   ======================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ========================================
   HEADER
   ======================================== */
.main-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo h1 {
    font-size: 1.5rem;
    margin: 0;
    color: var(--primary-color);
    font-weight: 700;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-link {
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
}

.nav-link:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

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

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: 1rem;
    padding-left: 1rem;
    border-left: 1px solid var(--border-color);
}

.user-name {
    font-weight: 500;
    color: var(--text-primary);
}

/* ========================================
   MAIN CONTENT
   ======================================== */
.main-content {
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

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

.page-header h2 {
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--text-secondary);
    margin: 0;
}

/* ========================================
   SECTIONS
   ======================================== */
.section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.section h3 {
    margin-bottom: 1.5rem;
}

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

.section-header h3 {
    margin: 0;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    color: white;
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #059669;
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
    color: white;
}

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

.btn-outline:hover {
    background: var(--bg-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.813rem;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ========================================
   BADGES
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--bg-color);
    color: var(--text-secondary);
}

.badge-admin {
    background: #dbeafe;
    color: #1e40af;
}

.badge-user {
    background: #dcfce7;
    color: #166534;
}

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

.stat-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon-blue {
    background: #dbeafe;
    color: var(--primary-color);
}

.stat-icon-green {
    background: #dcfce7;
    color: var(--success-color);
}

.stat-icon-orange {
    background: #fed7aa;
    color: var(--warning-color);
}

.stat-content h3 {
    font-size: 2rem;
    margin: 0;
    font-weight: 700;
}

.stat-content p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ========================================
   TABLES
   ======================================== */
.table-responsive {
    overflow-x: auto;
}

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

.data-table thead {
    background: var(--bg-color);
}

.data-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    border-bottom: 2px solid var(--border-color);
}

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

.data-table tbody tr:hover {
    background: var(--bg-color);
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-secondary);
}

/* ========================================
   FILE GRID
   ======================================== */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.file-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

.file-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.file-card-admin {
    border-left: 3px solid var(--primary-color);
}

.file-icon {
    flex-shrink: 0;
    color: var(--primary-color);
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-info h4 {
    font-size: 0.875rem;
    margin: 0 0 0.25rem 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-info p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0;
}

.file-actions {
    display: flex;
    gap: 0.5rem;
}

/* ========================================
   ACTIVITY LIST
   ======================================== */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: var(--radius);
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-icon-login,
.activity-icon-logout {
    background: #dbeafe;
    color: var(--primary-color);
}

.activity-icon-upload {
    background: #dcfce7;
    color: var(--success-color);
}

.activity-icon-download {
    background: #fef3c7;
    color: var(--warning-color);
}

.activity-icon-delete {
    background: #fee2e2;
    color: var(--danger-color);
}

.activity-content {
    flex: 1;
}

.activity-content strong {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.activity-content span {
    display: block;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.activity-content small {
    display: block;
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* ========================================
   EMPTY STATE
   ======================================== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    margin-bottom: 1.5rem;
}

/* ========================================
   ALERTS
   ======================================== */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border-left: 4px solid var(--success-color);
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger-color);
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid var(--info-color);
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid var(--warning-color);
}

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

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

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: var(--transition);
    background: var(--bg-secondary);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-actions {
    margin-top: 1.5rem;
}

.form-footer {
    margin-top: 1.5rem;
    text-align: center;
}

.link-secondary {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.link-secondary:hover {
    color: var(--primary-color);
}

/* ========================================
   LOGIN PAGE CON BACKGROUND
   ======================================== */
.login-page {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    background-image: url('https://anfit.sextantferrara.it/wp-content/uploads/hero1.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Overlay con gradient */
.login-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: transparent;
    background-image: linear-gradient(280deg, #002E6D00 0%, #00157B 100%);
    opacity: 0.6;
    transition: background 0.3s, border-radius 0.3s, opacity 0.3s;
    z-index: 1;
}

/* Container sopra l'overlay */
.login-container {
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 2;
}

.login-box {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-secondary);
    margin: 0;
}

.login-form .form-control {
    padding: 0.75rem 1rem;
}

.login-footer {
    text-align: center;
    margin-top: 2rem;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.875rem;
    position: relative;
    z-index: 2;
}

/* ========================================
   FOOTER
   ======================================== */
.main-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: 4rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .main-nav {
        flex-direction: column;
        width: 100%;
    }
    
    .nav-link {
        width: 100%;
        text-align: center;
    }
    
    .user-menu {
        width: 100%;
        justify-content: center;
        border-left: none;
        border-top: 1px solid var(--border-color);
        padding-top: 1rem;
        padding-left: 0;
        margin-left: 0;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .btn {
        width: 100%;
    }
    
    .file-grid {
        grid-template-columns: 1fr;
    }
    
    .data-table {
        font-size: 0.813rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.5rem;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .login-box {
        padding: 1.5rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .section {
        padding: 1rem;
    }
}

.logo-img {
    width: 120px !important;
    height: 100px !important;
    max-width: 120px !important;
    max-height: 100px !important;
    object-fit: contain !important;
}

/* Animazione smooth per l'icona */
.expand-trigger svg {
    transition: transform 0.3s ease;
}

/* Hover effect sul badge cliccabile */
.expand-trigger:hover {
    background: #c7d2fe !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(67, 56, 202, 0.2);
}

/* Animazione per la lista espansa */
.hidden-users-list {
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 500px;
    }
}

/* Tooltip */
.user-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: #1e293b;
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.813rem;
    white-space: pre-line;
    z-index: 1000;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    max-width: 250px;
    line-height: 1.5;
}

.user-tooltip.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* Freccetta del tooltip */
.user-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1e293b;
}

/* Assicura che il parent sia relative per posizionamento tooltip */
.expand-trigger {
    position: relative;
}


/* Bottoni icona */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
    border: 1px solid transparent;
}

/* Download - grigio */
.btn-icon-download {
    background: #f1f5f9;
    color: #475569;
    border-color: #e2e8f0;
}

.btn-icon-download:hover {
    background: #e2e8f0;
    color: #1e293b;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Elimina - rosso */
.btn-icon-delete {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fecaca;
}

.btn-icon-delete:hover {
    background: #dc2626;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

/* Tooltip nativi del browser */
.btn-icon[title] {
    position: relative;
}

/* Bottone Success - Verde Professionale */
.btn-success {
    background: #059669;
    color: white;
    border: 1px solid #059669;
}

.btn-success:hover {
    background: #047857;
    border-color: #047857;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.4);
}

.btn-success:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(5, 150, 105, 0.3);
}


/* ============================================
   MOBILE MENU - HAMBURGER
   ============================================ */

/* Hamburger button - nascosto su desktop */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-primary);
    transition: transform 0.2s ease;
}

.mobile-menu-toggle:hover {
    transform: scale(1.1);
}

.mobile-menu-toggle svg {
    width: 28px;
    height: 28px;
}

/* Bottone chiudi - nascosto su desktop */
.mobile-menu-close {
    display: none;
}

/* Overlay scuro - nascosto di default */
.menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.menu-overlay.active {
    display: block;
    opacity: 1;
}

/* ============================================
   RESPONSIVE - MOBILE (max-width: 768px)
   ============================================ */
@media (max-width: 768px) {
    
    /* Container header - mantieni tutto su una riga */
    .main-header .container {
        padding: 0.75rem 1rem;
    }
    
    /* Header content - flex su UNA riga */
    .header-content {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
        gap: 1rem;
    }
    
    /* Logo container - mantieni tutto inline */
    .logo {
        display: flex !important;
        align-items: center !important;
        gap: 0.5rem !important;
        flex-shrink: 0 !important;
        margin: 0 !important;
    }
    
    /* Logo più piccolo su mobile */
    .logo a {
        display: flex;
        align-items: center;
    }
    
    .logo-img {
        width: 100px !important;
        height: 50px !important;
    }
    
    /* Badge più piccolo su mobile */
    .badge {
        font-size: 0.688rem;
        padding: 0.25rem 0.5rem;
        white-space: nowrap;
    }
    
    /* Mostra hamburger button - stesso allineamento del logo */
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: relative;
        z-index: 1001;
        margin-left: auto;
        flex-shrink: 0;
    }
    
    /* Navigation diventa slide menu laterale */
    .main-nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 300px;
        max-width: 85vw;
        height: 100vh;
        background: white;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
        transition: right 0.3s ease;
        z-index: 999;
        padding: 4rem 1.5rem 2rem;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        gap: 2rem;
    }
    
    /* Menu aperto */
    .main-nav.active {
        right: 0;
    }
    
    /* Bottone chiudi - visibile su mobile */
    .mobile-menu-close {
        display: block;
        position: absolute;
        top: 1rem;
        right: 1rem;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0.5rem;
        color: var(--text-primary);
        transition: transform 0.2s ease;
    }
    
    .mobile-menu-close:hover {
        transform: scale(1.1);
    }
    
    .mobile-menu-close svg {
        width: 24px;
        height: 24px;
    }
    
    /* Nav links - disposizione verticale */
    .nav-links {
        display: flex;
        flex-direction: column;
        gap: 0;
        border-top: 2px solid var(--border-color);
        padding-top: 1rem;
    }
    
    .nav-link {
        display: block;
        padding: 1rem 0.75rem;
        width: 100%;
        border-bottom: 1px solid var(--border-color);
        font-size: 1rem;
        font-weight: 500;
        background: transparent !important;
        transition: color 0.2s ease;
    }
    
    /* Link attivo - solo testo blu e bordo laterale */
    .nav-link.active {
        color: var(--primary-color) !important;
        background: transparent !important;
        border-left: 3px solid var(--primary-color);
        font-weight: 600;
    }
    
    .nav-link:hover {
        color: var(--primary-color);
        background: rgba(37, 99, 235, 0.05) !important;
    }
    
    /* User menu - disposizione verticale */
    .user-menu {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        border-top: 2px solid var(--border-color);
        padding-top: 1.5rem;
        margin-top: auto;
    }
    
    .user-name {
        font-size: 0.875rem;
        font-weight: 600;
        color: var(--text-secondary);
        padding: 0.5rem 0;
    }
    
    .user-menu .btn {
        width: 100%;
        justify-content: center;
    }
}
/* Nascondi hamburger quando menu è aperto */
@media (max-width: 768px) {
    .main-nav.active ~ .mobile-menu-toggle,
    body:has(.main-nav.active) .mobile-menu-toggle {
        opacity: 0;
        pointer-events: none;
        visibility: hidden;
    }
}