/* ============================================
   CS GALVANI - CLASSI STYLES
   Design system compliant - Editorial/Industrial
   ============================================ */

/* ============================================
   LOADING SKELETONS
   ============================================ */

/* Shimmer animation */
@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Skeleton class card */
.skeleton-class-card {
    border: 1px solid var(--color-border);
    background: var(--color-bg-card);
    overflow: hidden;
}

.skeleton-class-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg);
    border-bottom: 1px solid var(--color-border);
}

.skeleton-class-icon {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    background: linear-gradient(
        90deg,
        var(--color-bg-elevated) 0%,
        var(--color-bg-card) 50%,
        var(--color-bg-elevated) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 0;
}

.skeleton-class-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.skeleton-class-title {
    height: 20px;
    width: 60%;
    background: linear-gradient(
        90deg,
        var(--color-bg-elevated) 0%,
        var(--color-bg-card) 50%,
        var(--color-bg-elevated) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

.skeleton-class-subtitle {
    height: 14px;
    width: 40%;
    background: linear-gradient(
        90deg,
        var(--color-bg-elevated) 0%,
        var(--color-bg-card) 50%,
        var(--color-bg-elevated) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

.skeleton-class-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--color-border);
}

.skeleton-class-stat {
    padding: var(--space-md);
    background: var(--color-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
}

.skeleton-stat-value {
    height: 20px;
    width: 30px;
    background: linear-gradient(
        90deg,
        var(--color-bg-elevated) 0%,
        var(--color-bg-card) 50%,
        var(--color-bg-elevated) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

.skeleton-stat-label {
    height: 10px;
    width: 50px;
    background: linear-gradient(
        90deg,
        var(--color-bg-elevated) 0%,
        var(--color-bg-card) 50%,
        var(--color-bg-elevated) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

.skeleton-hidden {
    display: none;
}

/* Skeleton for modal students loading */
.skeleton-stat-value-large {
    height: 32px;
    width: 48px;
    background: linear-gradient(
        90deg,
        var(--color-bg-elevated) 0%,
        var(--color-bg-card) 50%,
        var(--color-bg-elevated) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

.skeleton-title {
    height: 24px;
    width: 150px;
    background: linear-gradient(
        90deg,
        var(--color-bg-elevated) 0%,
        var(--color-bg-card) 50%,
        var(--color-bg-elevated) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

.skeleton-student-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border-bottom: 1px solid var(--color-border);
}

.skeleton-student-item:last-child {
    border-bottom: none;
}

.skeleton-student-avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background: linear-gradient(
        90deg,
        var(--color-bg-elevated) 0%,
        var(--color-bg-card) 50%,
        var(--color-bg-elevated) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

.skeleton-student-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.skeleton-student-name {
    height: 16px;
    width: 70%;
    background: linear-gradient(
        90deg,
        var(--color-bg-elevated) 0%,
        var(--color-bg-card) 50%,
        var(--color-bg-elevated) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

.skeleton-student-email {
    height: 12px;
    width: 50%;
    background: linear-gradient(
        90deg,
        var(--color-bg-elevated) 0%,
        var(--color-bg-card) 50%,
        var(--color-bg-elevated) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

/* ============================================
   LAYOUT STRUCTURE
   ============================================ */

/* ============================================
   LAYOUT STRUCTURE
   ============================================ */

/* Main container - Overflow fix */
.page-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.classes-grid {
    flex: 1;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
    min-height: 0;
}

/* Grid con sidebar per admin/institute_rep (desktop) */
.role-admin .classes-grid,
.role-institute_rep .classes-grid {
    grid-template-columns: 280px 1fr;
}

/* Layout singola classe (studenti) */
.single-class-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--space-lg);
    align-items: start;
    padding: var(--space-lg);
}

.single-class-layout .class-card {
    width: 100%;
    max-width: none;
}

/* ============================================
   YEARS SIDEBAR
   ============================================ */

.years-sidebar {
    position: sticky;
    top: var(--space-lg);
    height: fit-content;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    display: none; /* Hidden by default - shown only for admin/institute_rep */
}

/* Custom scrollbar per years-sidebar */
.years-sidebar::-webkit-scrollbar {
    width: 6px;
}

.years-sidebar::-webkit-scrollbar-track {
    background: var(--color-bg);
    border-radius: 3px;
}

.years-sidebar::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
    transition: background var(--duration-normal) var(--ease-out);
}

.years-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--color-accent);
}

/* Firefox scrollbar */
.years-sidebar {
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) var(--color-bg);
}

/* Show sidebar only for admin and institute_rep */
.role-admin .years-sidebar,
.role-institute_rep .years-sidebar {
    display: block;
}

/* Adjust grid when sidebar is hidden (for students and class_reps) */
.role-student .classes-grid,
.role-class_rep .classes-grid {
    grid-template-columns: 1fr;
}

.year-list {
    display: flex;
    flex-direction: column;
}

.year-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md);
    color: var(--color-text-muted);
    border-left: 2px solid transparent;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    position: relative;
}

.year-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: rgba(255, 92, 0, 0.05);
    transition: width var(--duration-fast) var(--ease-out);
}

.year-item:hover {
    color: var(--color-text);
}

.year-item:hover::before {
    width: 100%;
}

.year-item.active {
    color: var(--color-accent);
    border-left-color: var(--color-accent);
}

.year-item.active::before {
    width: 100%;
    background: rgba(255, 92, 0, 0.08);
}

.year-number {
    font-family: var(--font-display);
    font-size: 1.5rem;
    line-height: 1;
    margin-right: var(--space-sm);
}

.year-label {
    font-size: 0.875rem;
    font-weight: 500;
}

.year-count {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    transition: all var(--duration-fast) var(--ease-out);
}

.year-item.active .year-count {
    background: var(--color-accent);
    color: var(--color-bg);
    border-color: var(--color-accent);
}

/* ============================================
   SPECIALIZATIONS LIST (below years)
   ============================================ */

.specialization-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.specialization-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    position: relative;
    border-left: 3px solid transparent;
}

.specialization-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: rgba(255, 92, 0, 0.05);
    transition: width var(--duration-fast) var(--ease-out);
    z-index: 0;
}

.specialization-item:hover::before {
    width: 100%;
}

.specialization-item.active {
    color: var(--color-accent);
    border-left-color: var(--color-accent);
}

.specialization-item.active::before {
    width: 100%;
    background: rgba(255, 92, 0, 0.08);
}

.specialization-label {
    font-size: 0.8125rem;
    font-weight: 500;
    position: relative;
    z-index: 1;
}

.specialization-count {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 8px;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    transition: all var(--duration-fast) var(--ease-out);
    position: relative;
    z-index: 1;
}

.specialization-item.active .specialization-count {
    background: var(--color-accent);
    color: var(--color-bg);
    border-color: var(--color-accent);
}

/* ============================================
   CLASSES MAIN AREA
   ============================================ */

.classes-main {
    overflow-y: auto;
    min-height: 0;
    padding-right: var(--space-sm);
}

/* Custom scrollbar per classes-main */
.classes-main::-webkit-scrollbar {
    width: 6px;
}

.classes-main::-webkit-scrollbar-track {
    background: var(--color-bg);
    border-radius: 3px;
}

.classes-main::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
    transition: background var(--duration-normal) var(--ease-out);
}

.classes-main::-webkit-scrollbar-thumb:hover {
    background: var(--color-accent);
}

/* Firefox scrollbar */
.classes-main {
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) var(--color-bg);
}

/* Search section */
.search-section {
    margin-bottom: var(--space-lg);
}

.search-bar {
    position: relative;
}

.search-bar input {
    padding-left: 44px;
    width: 100%;
}

.search-bar svg {
    position: absolute;
    left: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    pointer-events: none;
}

/* Classes grid */
#classes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-lg);
}

/* ============================================
   CLASS CARDS - Improved Design
   ============================================ */
/* ============================================
   CLASS CARDS - Improved Design
   ============================================ */

.class-card {
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    overflow: hidden;
    padding: 0;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    position: relative;
}

.class-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px solid var(--color-accent);
    opacity: 0;
    transition: opacity var(--duration-fast) var(--ease-out);
    pointer-events: none;
}

.class-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.class-card:hover::after {
    opacity: 1;
}

.class-card:active {
    transform: translateY(0);
}

/* Card header */
.class-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
    transition: background var(--duration-fast) var(--ease-out);
}

.class-card:hover .class-header {
    background: var(--color-bg-elevated);
}

.class-icon {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-elevated);
    border: 1px solid rgba(255, 92, 0, 0.2);
    transition: all var(--duration-fast) var(--ease-out);
    position: relative;
    overflow: hidden;
}

.class-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--color-accent);
    opacity: 0.1;
    transition: opacity var(--duration-fast) var(--ease-out);
}

.class-card:hover .class-icon {
    border-color: var(--color-accent);
    transform: scale(1.05);
}

.class-card:hover .class-icon::before {
    opacity: 0.15;
}

.class-icon span {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--color-accent);
    position: relative;
    z-index: 1;
}

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

.class-info h3 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    letter-spacing: 0.02em;
    margin-bottom: 4px;
    color: var(--color-text);
}

.class-info p {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

/* Card stats */
.class-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--color-border);
}

.class-stat {
    padding: var(--space-sm) var(--space-xs);
    background: var(--color-bg);
    text-align: center;
    transition: background var(--duration-fast) var(--ease-out);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 70px;
}

.class-card:hover .class-stat {
    background: var(--color-bg-elevated);
}

.class-stat-value {
    font-family: var(--font-display);
    font-size: 0.9375rem;
    color: var(--color-text);
    line-height: 1.2;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
    word-break: break-word;
    min-height: 2.4em;
}

/* Rappresentanti - anteprima studente */
.card-eyebrow {
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.rep-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: var(--color-bg-elevated);
    font-weight: 700;
    color: var(--color-text);
}

.rep-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.rep-chip {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    border: 1px solid var(--color-border);
    background: var(--color-bg-elevated);
    border-radius: 6px;
    transition: all var(--duration-normal) var(--ease-out);
}

.rep-chip:hover {
    border-color: var(--color-accent);
    transform: translateY(-2px);
}

.rep-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-accent);
    color: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 1.05rem;
    letter-spacing: 0.03em;
}

.rep-meta {
    flex: 1;
    min-width: 0;
}

.rep-name {
    font-weight: 600;
    color: var(--color-text);
}

.rep-role,
.rep-email {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.class-stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    font-weight: 500;
    line-height: 1.2;
}

/* ============================================
   MODAL - Class Detail
   ============================================ */
/* ============================================
   MODAL - Class Detail
   ============================================ */

/* Modal specifics for class detail */
#modal-class-detail .modal {
    max-width: 900px;
}

/* Modal stats grid */
.modal-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.modal-stat-card {
    padding: var(--space-md);
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    text-align: center;
}

.modal-stat-value {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--color-accent);
    line-height: 1;
    margin-bottom: var(--space-xs);
}

.modal-stat-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* Students section in modal */
.modal-students-section {
    margin-bottom: var(--space-xl);
}

.modal-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 2px solid var(--color-border);
}

.modal-section-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    letter-spacing: 0.02em;
}

/* Student list */
.student-list {
    display: flex;
    flex-direction: column;
    max-height: 400px;
    overflow-y: auto;
    padding-right: var(--space-xs);
}

.student-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--color-border);
    transition: background var(--duration-fast) var(--ease-out);
}

.student-item:last-child {
    border-bottom: none;
}

.student-item:hover {
    background: var(--color-bg-elevated);
    margin: 0 calc(-1 * var(--space-sm));
    padding-left: var(--space-sm);
    padding-right: var(--space-sm);
}

.student-avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

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

.student-name {
    font-weight: 600;
    color: var(--color-text);
    font-size: 0.9375rem;
    margin-bottom: 2px;
}

.student-email {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.student-role {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* Student actions */
.student-actions {
    display: flex;
    gap: var(--space-xs);
    align-items: center;
    margin-left: auto;
}

/* Student badge */
.student-badge {
    font-size: 0.625rem;
    padding: 4px 8px;
    background: var(--color-accent);
    color: var(--color-bg);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
    white-space: nowrap;
}

/* ============================================
   SEARCH RESULTS & HIGHLIGHT
   ============================================ */

/* Search highlight */
mark {
    background-color: var(--color-accent);
    color: var(--color-bg);
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
}

/* Search results sections */
.search-results-section {
    margin-bottom: var(--space-xl);
}

.search-results-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 2px solid var(--color-accent);
}

.search-results-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    letter-spacing: 0.02em;
}

.search-results-count {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    padding: 4px 10px;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
}

/* ============================================
   EMPTY STATES
   ============================================ */

.empty-state {
    text-align: center;
    padding: var(--space-3xl) var(--space-lg);
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    color: var(--color-text-subtle);
}

.empty-state-icon svg {
    width: 48px;
    height: 48px;
}

.empty-state-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: var(--space-sm);
    color: var(--color-text);
}

.empty-state-text {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
    max-width: 400px;
    margin: 0 auto var(--space-lg);
}

.empty-state-action {
    margin-top: var(--space-lg);
}

/* ============================================
   FORMS & INPUTS
   ============================================ */
        
@media (max-width: 768px) {
    /* Layout adjustments */
    html, body, .app-container {
        overflow-x: hidden;
        max-width: 100vw;
    }
    
    .page-content {
        overflow-y: auto;
        overflow-x: hidden;
        padding: var(--space-md);
    }

    #classes-grid.single-class-layout {
        display: grid;
    }
    
    .single-class-layout {
        padding: var(--space-md);
        gap: var(--space-md);
    }
    
    .rep-chip {
        align-items: flex-start;
    }
    
    .rep-avatar {
        width: 36px;
        height: 36px;
    }
    
    .main-content {
        overflow-x: hidden;
        max-width: 100vw;
    }
    
    /* Grid to column stack */
    .classes-grid {
        display: flex;
        flex-direction: column;
        gap: var(--space-md);
    }
    
    .years-sidebar {
        position: static;
        max-height: none;
        overflow: visible;
        margin-bottom: var(--space-md);
    }
    
    /* Allow horizontal overflow for years card on mobile */
    .years-sidebar .card {
        overflow: visible;
    }
    
    .years-sidebar .card-body {
        padding: 0;
        overflow: visible;
    }
    
    .classes-main {
        overflow-y: visible;
    }
    
    /* Horizontal year list - COMPATTO TUTTO VISIBILE SU MOBILE */
    .year-list {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: visible;
        overflow-y: hidden;
        gap: 4px;
        padding: var(--space-sm);
        justify-content: space-between;
    }
    
    .year-list::-webkit-scrollbar {
        display: none;
    }
    
    .year-item {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: var(--space-sm);
        border-left: none;
        border-bottom: 3px solid transparent;
        white-space: nowrap;
        flex: 1 1 0;
        min-width: 0;
        max-width: none;
        background: var(--color-bg-elevated);
        border: 1px solid var(--color-border);
        transition: all var(--duration-fast) var(--ease-out);
        cursor: pointer;
    }
    
    .year-item::before {
        display: none;
    }
    
    .year-item:active {
        transform: scale(0.95);
    }
    
    .year-item.active {
        border-left: none;
        border-bottom-color: var(--color-accent);
        background: var(--color-bg-card);
        border-color: var(--color-accent);
    }
    
    .year-number {
        font-size: 1.5rem;
        line-height: 1;
        font-weight: 700;
    }
    
    .year-label {
        font-size: 0.625rem;
        font-weight: 500;
        text-align: center;
    }
    
    .year-count {
        font-size: 0.625rem;
        padding: 2px 6px;
        line-height: 1;
    }
    
    /* Classes grid - single column */
    #classes-grid {
        display: flex;
        flex-direction: column;
        gap: var(--space-md);
    }
    
    /* Card adjustments */
    .card {
        min-width: 0;
        overflow: hidden;
    }
    
    .class-card {
        margin-bottom: 0;
    }
    
    .class-header {
        padding: var(--space-md);
        flex-wrap: wrap;
        gap: var(--space-sm);
    }
    
    .class-icon {
        width: 52px;
        height: 52px;
        flex-shrink: 0;
    }
    
    .class-icon span {
        font-size: 1.375rem;
    }
    
    .class-info {
        min-width: 0;
        flex: 1 1 auto;
        max-width: calc(100% - 52px - var(--space-sm));
    }
    
    .class-info h3 {
        font-size: 1.25rem;
        line-height: 1.3;
    }
    
    .class-info p {
        font-size: 0.875rem;
        line-height: 1.4;
    }
    
    /* Stats - 2 columns on mobile */
    .class-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .class-stat {
        padding: var(--space-md) var(--space-sm);
        min-height: 80px;
    }
    
    .class-stat-value {
        font-size: 1rem;
        line-height: 1.3;
        margin-bottom: 6px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        max-height: 2.6em;
        word-wrap: break-word;
        hyphens: auto;
    }
    
    .class-stat-label {
        font-size: 0.6875rem;
        line-height: 1.3;
    }
    
    /* Rappresentanti - ottimizzazione testo */
    .rep-chip {
        padding: var(--space-xs);
        gap: var(--space-xs);
    }
    
    .rep-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.875rem;
        flex-shrink: 0;
    }
    
    .rep-name {
        font-size: 0.875rem;
        line-height: 1.3;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .rep-role,
    .rep-email {
        font-size: 0.6875rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    /* Badge migliorato per visibilità */
    .student-badge,
    .rep-count-badge {
        font-size: 0.6875rem;
        padding: 5px 10px;
        font-weight: 700;
    }
    
    /* Search bar */
    .search-section {
        width: 100%;
    }
    
    .search-bar {
        width: 100%;
    }
    
    .search-bar input {
        width: 100%;
        font-size: 1rem;
        /* Prevent zoom on focus */
        -webkit-text-size-adjust: 100%;
    }
    
    /* Modal adjustments */
    #modal-class-detail .modal {
        max-width: 100%;
        margin: var(--space-md);
    }
    
    .modal-stats-grid {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }
    
    .modal-stat-card {
        padding: var(--space-sm);
    }
    
    .modal-stat-value {
        font-size: 1.5rem;
    }
    
    .student-list {
        max-height: 300px;
        padding-right: 0;
    }
    
    .student-item {
        padding: var(--space-md) var(--space-sm);
        gap: var(--space-sm);
        flex-wrap: wrap;
        align-items: flex-start;
    }
    
    .student-info {
        flex: 1 1 auto;
        min-width: 0;
        max-width: 100%;
    }
    
    .student-name {
        font-size: 0.875rem;
        line-height: 1.3;
        word-break: break-word;
    }
    
    .student-email,
    .student-role {
        font-size: 0.75rem;
        line-height: 1.3;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    /* Badge su nuova riga */
    .student-badge {
        font-size: 0.6875rem;
        padding: 5px 10px;
        font-weight: 700;
        flex-shrink: 0;
        margin-left: 0;
        margin-top: var(--space-xs);
    }
    
    .student-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    /* Touch targets - minimum 44px */
    .year-item {
        min-height: 44px;
    }
    
    .class-card {
        min-height: 44px;
    }
    
    button, .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Empty state */
    .empty-state {
        padding: var(--space-xl) var(--space-md);
    }
    
    .empty-state-icon {
        width: 64px;
        height: 64px;
    }
    
    .empty-state-icon svg {
        width: 40px;
        height: 40px;
    }
    
    .empty-state-title {
        font-size: 1.25rem;
    }
    
    .empty-state-text {
        font-size: 0.875rem;
    }
    
    /* Utility overrides */
    .grid-cols-2,
    .grid-cols-3 {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   TABLET (769px - 1024px)
   ============================================ */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Grid classi - 2 colonne su tablet */
    #classes-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-md);
    }
    
    .classes-grid {
        grid-template-columns: 200px 1fr;
        gap: var(--space-md);
    }
    
    /* Barra anno compatta */
    .years-sidebar {
        width: 100%;
    }
    
    .year-item {
        padding: var(--space-sm) var(--space-md);
    }
    
    .year-number {
        font-size: 1.375rem;
    }
    
    /* Card classi ottimizzate */
    .class-header {
        padding: var(--space-md);
    }
    
    .class-icon {
        width: 52px;
        height: 52px;
    }
    
    .class-icon span {
        font-size: 1.375rem;
    }
    
    .class-stats {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .class-stat {
        padding: var(--space-sm);
    }
    
    .class-stat-value {
        font-size: 0.9375rem;
    }
    
    /* Modal ottimizzato */
    .modal-stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-md);
    }
}

/* ============================================
   ULTRA SMALL SCREENS (iPhone SE)
   ============================================ */
@media (max-width: 480px) {
    /* Grid ottimizzato per schermi piccoli */
    #classes-grid {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }
    
    /* Card header - più spazio */
    .class-header {
        padding: var(--space-md);
        gap: var(--space-sm);
    }
    
    /* Icon ridotto ma più leggibile */
    .class-icon {
        width: 48px;
        height: 48px;
    }
    
    .class-icon span {
        font-size: 1.25rem;
    }
    
    /* Testo card più grande per leggibilità */
    .class-info h3 {
        font-size: clamp(1.125rem, 4vw, 1.375rem);
        line-height: 1.3;
    }
    
    .class-info p {
        font-size: 0.8125rem;
    }
    
    /* Stats più compatti ma leggibili */
    .class-stats {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .class-stat {
        padding: var(--space-xs) 4px;
        min-height: 68px;
    }
    
    .class-stat-value {
        font-size: clamp(0.875rem, 3vw, 1.125rem);
        margin-bottom: 2px;
        line-height: 1.15;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        max-height: 2.3em;
    }
    
    .class-stat-label {
        font-size: 0.625rem;
        line-height: 1.2;
        letter-spacing: 0.05em;
    }
    
    /* Badge più visibili */
    .stat-badge {
        font-size: 0.625rem;
        padding: 2px 6px;
        font-weight: 600;
    }
    
    /* Layout generale */
    .single-class-layout {
        padding: var(--space-md);
        gap: var(--space-md);
        grid-template-columns: 1fr;
    }
    
    /* Search section */
    .search-section {
        margin-bottom: var(--space-md);
    }
    
    /* Modal ottimizzato */
    .modal-header {
        padding: var(--space-md);
    }
    
    .modal-body {
        padding: var(--space-md);
    }
    
    .modal-class-icon {
        width: 48px;
        height: 48px;
    }
    
    .modal-class-icon span {
        font-size: 1.25rem;
    }
    
    .modal-title {
        font-size: 1.5rem;
    }
    
    .modal-subtitle {
        font-size: 0.8125rem;
    }
    
    /* Student list con badge */
    .student-item {
        gap: var(--space-sm);
        padding: var(--space-md) var(--space-sm);
        flex-wrap: wrap;
        align-items: flex-start;
    }
    
    .student-info {
        flex: 1 1 auto;
        min-width: 0;
        max-width: 100%;
    }
    
    .student-name {
        font-size: 0.8125rem;
        line-height: 1.3;
        word-break: break-word;
    }
    
    .student-email,
    .student-role {
        font-size: 0.6875rem;
        line-height: 1.2;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Badge su stessa riga se possibile, altrimenti va a capo */
    .student-badge {
        font-size: 0.625rem;
        padding: 4px 8px;
        font-weight: 700;
        flex: 0 0 auto;
        margin-left: 0;
        margin-top: 2px;
    }
    
    /* Student actions */
    .student-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: var(--space-xs);
        margin-left: 0;
        order: 3;
    }
}
