/* ===== VARIABILI ===== */
:root {
    --sidebar-bg:      #0c1a3a;   /* navy */
    --sidebar-hover:   #162d5e;
    --sidebar-active:  #1e3f80;
    --sidebar-accent:  #60a5fa;   /* blue 400 - highlight border */
    --sidebar-width:   265px;
    --content-bg:      #f1f5f9;
    --primary:         #1e40af;
    --primary-dark:    #1e3a8a;
    --text-muted:      #64748b;
}

/* ===== RESET ===== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--content-bg);
    margin: 0;
    padding: 0;
}

/* ===== LOGIN PAGE ===== */
.login-body {
    background: #f0f4ff;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 15px;
}

.login-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 32px rgba(30, 64, 175, 0.10);
    border: 1px solid #e8eef8;
}

.login-header {
    background: white;
    text-align: center;
    padding: 40px 30px 28px;
    border-bottom: 1px solid #f0f4ff;
}

.login-logo {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 1.8rem;
    color: white;
    box-shadow: 0 4px 16px rgba(30, 64, 175, 0.25);
}

.login-header h3 {
    margin-bottom: 4px;
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: 0.5px;
    color: #0c1a3a;
}

.login-header .subtitle {
    font-size: 0.85rem;
    color: #6b7280;
    letter-spacing: 0.3px;
}

.login-form {
    padding: 32px 30px 36px;
}

.login-form .form-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: #374151;
}

.login-form .form-control {
    border-radius: 8px;
    border-color: #e2e8f0;
    padding: 0.65rem 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fafbff;
}

.login-form .form-control:focus {
    border-color: #1e40af;
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.10);
    background: white;
}

.login-form .btn-primary {
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    border: none;
    border-radius: 8px;
    font-weight: 600;
    letter-spacing: 0.3px;
    padding: 0.7rem;
    transition: all 0.2s ease;
}

.login-form .btn-primary:hover {
    background: linear-gradient(135deg, #1d3fa8, #2563eb);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(30, 64, 175, 0.30);
}

/* ===== LAYOUT WRAPPER ===== */
#wrapper {
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    transition: transform 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* Custom scrollbar per la sidebar (browser WebKit/Chromium) */
.sidebar::-webkit-scrollbar {
    width: 6px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.25);
}

.sidebar-header {
    padding: 22px 20px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #1e40af, #60a5fa);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.sidebar-brand-name {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.3px;
}

.sidebar-brand-module {
    font-size: 0.72rem;
    color: var(--sidebar-accent);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.sidebar-divider {
    border-color: rgba(255, 255, 255, 0.08);
    margin: 0 16px;
}

/* ===== SWITCH LINK ===== */
.switch-module-link {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    gap: 8px;
}

.switch-module-link:hover {
    color: rgba(255, 255, 255, 0.85);
    background-color: rgba(255, 255, 255, 0.05);
}

/* ===== MENU LABEL ===== */
.sidebar-menu-label {
    padding: 14px 20px 6px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.3);
}

/* ===== SIDEBAR MENU ===== */
.sidebar-menu {
    list-style: none;
    padding: 6px 10px;
    margin: 0;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    border-radius: 8px;
    margin-bottom: 2px;
    gap: 10px;
}

.sidebar-menu li a:hover {
    background-color: rgba(255, 255, 255, 0.07);
    color: white;
}

.sidebar-menu li a.active {
    background-color: rgba(30, 63, 128, 0.45);
    color: white;
    border-left: 3px solid var(--sidebar-accent);
    padding-left: 9px;
}

.sidebar-menu li a i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-wip {
    opacity: 0.4;
    cursor: default !important;
    pointer-events: none;
}

.sidebar-wip-badge {
    margin-left: auto;
    font-size: 0.58rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

/* ===== SUBMENU ===== */
.submenu-toggle {
    position: relative;
}

.submenu-arrow {
    margin-left: auto !important;
    font-size: 0.65rem !important;
    transition: transform 0.3s ease;
    opacity: 0.6;
}

.has-submenu.open > a .submenu-arrow {
    transform: rotate(180deg);
}

.submenu {
    list-style: none;
    padding: 0 0 0 10px;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.has-submenu.open .submenu {
    max-height: 300px;
}

.submenu li a {
    padding: 8px 12px 8px 22px !important;
    font-size: 0.85rem !important;
}

.submenu li a i {
    font-size: 0.82rem !important;
    width: 18px !important;
}

/* ===== SIDEBAR FOOTER ===== */
.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: auto;
}

.user-info-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    margin-bottom: 6px;
}

.user-avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e40af, #60a5fa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.user-info-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}

.user-info-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info-role {
    font-size: 0.7rem;
    color: var(--sidebar-accent);
    font-weight: 500;
    text-transform: capitalize;
}

.logout-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.45);
    text-decoration: none;
    font-size: 0.82rem;
    padding: 6px 10px;
    border-radius: 6px;
    transition: all 0.2s;
}

.logout-link:hover {
    color: #f87171;
    background: rgba(248, 113, 113, 0.08);
}

/* ===== CONTENUTO PRINCIPALE ===== */
.content-wrapper {
    margin-left: var(--sidebar-width);
    padding: 30px;
    flex-grow: 1;
    min-height: 100vh;
    background-color: var(--content-bg);
}

/* ===== TOPBAR ===== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.topbar-left h4 {
    margin: 0;
    font-weight: 700;
    color: #1e1b4b;
    font-size: 1.25rem;
}

/* ===== BREADCRUMB ===== */
.breadcrumb {
    background: white;
    padding: 10px 18px;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    font-size: 0.875rem;
    margin-bottom: 24px;
}

.breadcrumb a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

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

.breadcrumb-item.active {
    color: var(--text-muted);
}

/* ===== STAT CARDS ===== */
.stat-card {
    border-radius: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: none;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1) !important;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.3rem;
}

/* ===== TABELLE ===== */
.table thead th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 2px solid #e2e8f0;
}

.table tbody td {
    vertical-align: middle;
    font-size: 0.9rem;
    color: #334155;
}

/* ===== CARD GENERICHE ===== */
.card {
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.card-header {
    border-bottom: 1px solid #f1f5f9;
    padding: 14px 20px;
    background: white;
    border-radius: 12px 12px 0 0 !important;
}

/* ===== BOTTONI ===== */
.btn-primary {
    background: linear-gradient(135deg, #0c1a3a, #1e40af);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1e40af, #2563eb);
}

/* ===== EMPTY STATE ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    background: #dbeafe;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 20px;
}

.empty-state h5 {
    font-weight: 700;
    color: #374151;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.9rem;
    max-width: 320px;
}

/* ===== SWITCH MODULE PAGE ===== */
.switch-body {
    background: #f0f4ff;
    min-height: 100vh;
}

.switch-topbar {
    background: white;
    border-bottom: 1px solid #e8eef8;
    color: #0c1a3a;
    padding: 14px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    box-shadow: 0 1px 8px rgba(30,64,175,0.06);
}

.switch-topbar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1rem;
    color: #1e40af;
}

.switch-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 60px 20px;
}

.switch-header {
    text-align: center;
    margin-bottom: 50px;
}

.switch-header h2 {
    font-weight: 800;
    color: #0c1a3a;
    font-size: 2rem;
    margin-bottom: 8px;
}

.switch-header p {
    color: #6b7280;
    font-size: 0.95rem;
}

.module-card {
    display: block;
    background: white;
    border-radius: 20px;
    padding: 44px 32px;
    text-align: center;
    text-decoration: none;
    color: #0c1a3a;
    border: 1px solid #e8eef8;
    transition: all 0.3s ease;
    height: 100%;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(30,64,175,0.07);
}

.module-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--card-accent, #1e40af);
    opacity: 0;
    transition: opacity 0.3s;
}

.module-card:hover {
    transform: translateY(-6px);
    border-color: #c7d7f8;
    color: #0c1a3a;
    box-shadow: 0 12px 40px rgba(30,64,175,0.13);
}

.module-card:hover::before {
    opacity: 1;
}

.module-card.disabled-card {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.module-icon {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 22px;
    font-size: 2.1rem;
    color: white;
}

.module-icon.didattica {
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    --card-accent: #1e40af;
}

.module-icon.orientamento {
    background: linear-gradient(135deg, #0e7490, #22d3ee);
    --card-accent: #0e7490;
}

.module-card h3 {
    font-weight: 700;
    margin-bottom: 8px;
    font-size: 1.3rem;
    color: #0c1a3a;
}

.module-card p {
    color: #6b7280;
    font-size: 0.88rem;
    margin-bottom: 22px;
    line-height: 1.6;
}

.module-features {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 22px;
}

.module-features span {
    background: #e8eef8;
    color: #1e40af;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    border: 1px solid #c7d7f8;
}

.module-enter {
    color: #1e40af;
    font-weight: 600;
    font-size: 0.9rem;
}

.coming-soon-badge {
    display: inline-block;
    background: #f0f4ff;
    color: #6b7280;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border: 1px solid #e8eef8;
}

/* ===== MOBILE NAVBAR ===== */
.mobile-navbar {
    background: white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

/* ===== INSEGNANTI ===== */

/* Avatar piccolo (tabella) */
.ins-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e2e8f0;
}

.ins-avatar-initials {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e40af, #60a5fa);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* Avatar grande (form creazione) */
.ins-avatar-lg {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    font-size: 2rem;
    margin: 0 auto;
}

/* Avatar extra large (dettaglio) */
.ins-avatar-xl {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    font-size: 1.8rem;
    border: 3px solid #e2e8f0;
    object-fit: cover;
}

/* Foto preview nel form crea */
.ins-foto-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #e2e8f0;
    margin: 0 auto;
}

/* Bottone modifica foto (overlay) */
.btn-foto-edit {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-foto-edit:hover { background: var(--primary-dark); }

/* Badge stato insegnante */
.badge-status {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}
.badge-status.attivo {
    background: #dcfce7;
    color: #166534;
}
.badge-status.attivo i { color: #22c55e; font-size: 0.45rem; }
.badge-status.disattivo {
    background: #fee2e2;
    color: #991b1b;
}
.badge-status.disattivo i { color: #ef4444; font-size: 0.45rem; }

/* Badge materia */
.badge-materia {
    display: inline-block;
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    margin: 1px;
}

/* Info rows nel dettaglio */
.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.88rem;
}
.info-label {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.82rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 767.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .content-wrapper {
        margin-left: 0;
        padding: 16px;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.55);
        z-index: 999;
        display: none;
    }

    .sidebar-overlay.show {
        display: block;
    }
}
