﻿/* =====================================================================
   REGISTRO ELETTRONICO - CUSTOM DESIGN SYSTEM & UI ENHANCEMENTS
   Framework: Bootstrap 5.3+ CDN Compatible
   ===================================================================== */

:root {
    --re-primary: #1e3a8a;
    --re-primary-light: #3b82f6;
    --re-primary-dark: #172554;
    --re-accent: #0284c7;
    --re-success: #059669;
    --re-warning: #d97706;
    --re-danger: #dc2626;
    --re-info: #0891b2;
    --re-bg: #f8fafc;
    --re-card-bg: #ffffff;
    --re-border: #e2e8f0;
    --re-text-main: #0f172a;
    --re-text-muted: #64748b;
    --re-sidebar-width: 260px;
    --re-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --re-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
    --re-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);
    --re-radius: 0.75rem;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--re-bg);
    color: var(--re-text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- Layout Structure --- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--re-sidebar-width);
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: #e2e8f0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.05);
    z-index: 1040;
    transition: transform 0.3s ease;
    /* â”€â”€ Scrollable sidebar â”€â”€ */
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.18);
    border-radius: 4px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.32);
}

.main-content {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--re-bg);
}

.top-navbar {
    background: #ffffff;
    border-bottom: 1px solid var(--re-border);
    padding: 0.85rem 1.75rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.page-body {
    padding: 1.75rem;
    flex-grow: 1;
}

/* --- Sidebar Styling --- */
.sidebar-brand {
    padding: 1.5rem 1.25rem;
    font-weight: 700;
    font-size: 1.15rem;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    letter-spacing: -0.02em;
}

.sidebar-nav {
    padding: 1rem 0.75rem;
    list-style: none;
    margin: 0;
    flex-grow: 1;
}

.sidebar-nav .nav-link {
    color: #cbd5e1;
    padding: 0.75rem 1rem;
    font-size: 0.92rem;
    font-weight: 500;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
    transition: all 0.2s ease;
}

.sidebar-nav .nav-link:hover {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.12);
}

.sidebar-nav .nav-link.active {
    color: #ffffff !important;
    background-color: #2563eb !important;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.45);
}

/* Header Sezioni Multi-Ruolo ad altissima leggibilitÃ  */
.sidebar-section-header {
    border-top: 1px solid rgba(255, 255, 255, 0.14) !important;
    margin-top: 0.85rem !important;
    padding-top: 0.85rem !important;
    padding-bottom: 0.35rem !important;
    list-style: none;
}

.sidebar-section-header span {
    font-weight: 700;
}

.sidebar-section-header .text-muted {
    color: #e2e8f0 !important;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.85rem;
}

/* --- Modern Card System --- */
.card-modern {
    background: var(--re-card-bg);
    border: 1px solid var(--re-border);
    border-radius: var(--re-radius);
    box-shadow: var(--re-shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-modern:hover {
    box-shadow: var(--re-shadow-md);
}

.card-header-clean {
    background: transparent;
    border-bottom: 1px solid var(--re-border);
    padding: 1.15rem 1.4rem;
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* --- Stat Metric Cards --- */
.stat-card {
    padding: 1.25rem 1.4rem;
    border-radius: var(--re-radius);
    background: #ffffff;
    border: 1px solid var(--re-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--re-shadow-sm);
}

.stat-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

/* --- Grade Badges --- */
.grade-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 1.05rem;
}

.grade-pill.sufficient {
    background-color: #dcfce7;
    color: #166534;
    border: 2px solid #86efac;
}

.grade-pill.insufficient {
    background-color: #fee2e2;
    color: #991b1b;
    border: 2px solid #fca5a5;
}

/* --- Presa Visione Pulsing Badges --- */
.badge-unread-pulse {
    animation: pulseNotice 2s infinite ease-in-out;
    background-color: #ef4444;
    color: #ffffff;
    font-weight: 600;
    letter-spacing: 0.02em;
}

@keyframes pulseNotice {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.85; }
    100% { transform: scale(1); opacity: 1; }
}

/* --- Custom Tables --- */
.table-modern {
    margin-bottom: 0;
}

.table-modern th {
    background-color: #f8fafc;
    color: var(--re-text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    padding: 0.9rem 1rem;
    border-top: none;
    border-bottom: 1px solid var(--re-border);
}

.table-modern td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--re-border);
}

/* --- Responsive Adjustments --- */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        height: 100vh;
        overflow-y: auto;
        transform: translateX(-100%);
    }

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

    .page-body {
        padding: 1rem;
    }

    /* Sidebar nav link touch target su tablet/mobile grande */
    .sidebar-nav .nav-link {
        padding: 0.875rem 1rem;
        font-size: 0.95rem;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* =====================================================
   MOBILE RESPONSIVE ENHANCEMENTS (< 768px)
   ===================================================== */

@media (max-width: 767.98px) {

    /* 1. Touch targets â€” tutti i bottoni almeno 44px */
    .btn {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.35rem;
    }
    .btn-sm {
        min-height: 38px;
        padding: 0.4rem 0.75rem;
    }
    .btn-xs {
        min-height: 34px;
    }

    /* 2. Navbar top padding ridotto */
    .top-navbar {
        padding: 0.6rem 1rem;
    }

    /* 3. Page body padding compatto */
    .page-body {
        padding: 0.75rem;
    }

    /* 4. Card body padding ridotto per massimizzare spazio */
    .card-body {
        padding: 0.875rem !important;
    }
    .card-header-clean {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .stat-card {
        padding: 0.65rem 0.75rem !important;
        border-radius: 10px;
        gap: 0.45rem;
        min-height: 100%;
    }
    .stat-card .fw-medium {
        font-size: 0.72rem !important;
        line-height: 1.15;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    .stat-card h3 {
        font-size: 1.25rem !important;
        margin: 0.1rem 0 !important;
        line-height: 1.2;
    }
    .stat-card small {
        font-size: 0.67rem !important;
        line-height: 1.15;
        display: block;
    }
    .stat-card .stat-icon-wrapper {
        width: 34px !important;
        height: 34px !important;
        min-width: 34px;
        border-radius: 8px !important;
        font-size: 0.95rem !important;
    }

    /* 5. Tipografia â€” leggibilitÃ  su schermi piccoli */
    body {
        font-size: 0.95rem;
    }
    .form-label {
        font-size: 0.9rem;
        font-weight: 600;
        margin-bottom: 0.3rem;
    }
    small, .small {
        font-size: 0.82rem;
    }
    h5, .h5 { font-size: 1.05rem; }
    h6, .h6 { font-size: 0.95rem; }

    /* 6. Form inputs â€” min-height 44px + full width */
    .form-control,
    .form-select {
        min-height: 44px;
        font-size: 1rem;
        padding: 0.5rem 0.75rem;
    }
    .form-control-sm,
    .form-select-sm {
        min-height: 38px;
        font-size: 0.9rem;
    }
    /* Input voto compatto su mobile */
    .input-voto-classe {
        width: 70px !important;
        min-height: 38px;
        font-size: 0.95rem;
        padding: 0.3rem 0.4rem;
        text-align: center;
    }

    /* 7. Tabelle â€” riduzione padding su mobile */
    .table-modern th {
        font-size: 0.72rem;
        padding: 0.6rem 0.5rem;
        letter-spacing: 0.03em;
    }
    .table-modern td {
        padding: 0.6rem 0.5rem;
        font-size: 0.85rem;
    }
    .table-sm th,
    .table-sm td {
        padding: 0.4rem 0.4rem;
        font-size: 0.82rem;
    }

    /* 8. Sidebar offcanvas â€” larghezza max 85% per contesto visivo */
    .sidebar.offcanvas-lg {
        max-width: 85vw !important;
    }
    .sidebar-nav .nav-link {
        padding: 0.875rem 1rem;
        min-height: 44px;
        font-size: 0.95rem;
        margin-bottom: 0.15rem;
    }
    .sidebar-brand {
        padding: 1.1rem 1rem;
        font-size: 1rem;
    }
    .sidebar-footer {
        padding: 0.75rem 1rem;
    }

    /* 9. Stat cards â€” griglia responsive auto */
    .stat-card .stat-icon-wrapper {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }

    /* 10. Grade pill ridotto su mobile */
    .grade-pill {
        width: 36px;
        height: 36px;
        font-size: 0.95rem;
    }

    /* 11. Utility classi mobile-stack */
    .mobile-stack {
        flex-direction: column !important;
    }
    .mobile-full {
        width: 100% !important;
    }
    .mobile-wrap {
        flex-wrap: wrap !important;
        gap: 0.5rem;
    }

    /* 12. Pulsanti azione in gruppo â€” impilati su mobile */
    .btn-group-mobile-stack {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
        width: 100%;
    }
    .btn-group-mobile-stack .btn {
        width: 100%;
        justify-content: center;
    }

    /* 13. Modali â€” padding ridotto */
    .modal-body {
        padding: 1rem;
    }
    .modal-header {
        padding: 0.875rem 1rem;
    }
    .modal-footer {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .modal-footer .btn {
        flex: 1 1 auto;
    }

    /* 14. Badge e pill â€” tap-friendly */
    .badge {
        font-size: 0.75rem;
        padding: 0.35em 0.6em;
    }

    /* 15. Alert su mobile */
    .alert {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    /* 16. Tab nav su mobile */
    .nav-tabs .nav-link {
        padding: 0.6rem 0.75rem;
        font-size: 0.85rem;
    }

    /* 17. Row cols responsive per stat cards */
    .row-cols-mobile-1 > * {
        flex: 0 0 100%;
        max-width: 100%;
    }
    .row-cols-mobile-2 > * {
        flex: 0 0 50%;
        max-width: 50%;
    }
}
