/* ===================================
   CLEO Utils - Custom Theme
   Sidebar scura + contenuto chiaro
   =================================== */

:root {
    --sidebar-width: 260px;
    --sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active: #3b82f6;
    --sidebar-hover-bg: #334155;
    --content-bg: #f8fafc;
    --card-bg: #ffffff;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-amber: #f59e0b;
    --accent-red: #ef4444;
    --topbar-height: 56px;
}

/* ===== Base ===== */
body {
    background-color: var(--content-bg);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow-x: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand {
    color: #ffffff;
    font-size: 1.2rem;
    font-weight: 700;
    text-decoration: none;
    display: flex;
    align-items: center;
}

.sidebar-brand:hover {
    color: #ffffff;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.sidebar-nav .nav-link {
    color: var(--sidebar-text);
    padding: 0.6rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
}

.sidebar-nav .nav-link:hover {
    color: #e2e8f0;
    background: var(--sidebar-hover-bg);
}

.sidebar-nav .nav-link.active {
    color: #ffffff;
    background: rgba(59, 130, 246, 0.12);
    border-left-color: var(--sidebar-active);
}

.sidebar-nav .nav-link i {
    font-size: 1.1rem;
    width: 1.25rem;
    text-align: center;
}

.nav-section {
    padding: 1rem 1.5rem 0.3rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    list-style: none;
}

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

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

.sidebar-user > i {
    font-size: 1.75rem;
    color: #64748b;
}

.sidebar-user-name {
    font-size: 0.85rem;
    color: #e2e8f0;
    font-weight: 500;
}

.sidebar-user-role {
    font-size: 0.75rem;
    color: #64748b;
}

/* ===== Topbar (mobile) ===== */
.topbar {
    background: var(--sidebar-bg);
    height: var(--topbar-height);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
}

/* ===== Main Content ===== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 1.5rem 2rem;
}

.content-header {
    margin-bottom: 1.5rem;
}

.content-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.breadcrumb {
    font-size: 0.8rem;
}

.breadcrumb-item a {
    color: var(--accent-blue);
    text-decoration: none;
}

/* ===== KPI Cards ===== */
.kpi-card {
    background: var(--card-bg);
    border-radius: 0.75rem;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border-left: 4px solid transparent;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: box-shadow 0.15s ease;
}

.kpi-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.kpi-card.blue { border-left-color: var(--accent-blue); }
.kpi-card.green { border-left-color: var(--accent-green); }
.kpi-card.amber { border-left-color: var(--accent-amber); }
.kpi-card.red { border-left-color: var(--accent-red); }

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.kpi-icon.blue { background: rgba(59,130,246,0.1); color: var(--accent-blue); }
.kpi-icon.green { background: rgba(16,185,129,0.1); color: var(--accent-green); }
.kpi-icon.amber { background: rgba(245,158,11,0.1); color: var(--accent-amber); }
.kpi-icon.red { background: rgba(239,68,68,0.1); color: var(--accent-red); }

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1;
}

.kpi-label {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 0.15rem;
}

.kpi-change {
    font-size: 0.75rem;
    margin-top: 0.15rem;
}

.kpi-change.up { color: var(--accent-green); }
.kpi-change.down { color: var(--accent-red); }
.kpi-change.neutral { color: #64748b; }

/* ===== Cards ===== */
.card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: #1e293b;
}

/* ===== Chart Panel ===== */
.chart-panel {
    background: var(--card-bg);
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.chart-panel-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
}

.chart-toggle {
    display: inline-flex;
    background: #e2e8f0;
    border-radius: 0.5rem;
    padding: 2px;
    gap: 2px;
}

.chart-toggle-btn {
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.6rem;
    border-radius: 0.4rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
}

.chart-toggle-btn:hover {
    color: #1e293b;
}

.chart-toggle-btn.active {
    background: #fff;
    color: var(--accent-blue);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ===== Status Badge ===== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.active {
    background: rgba(16,185,129,0.1);
    color: #059669;
}

.status-badge.inactive {
    background: rgba(239,68,68,0.1);
    color: #dc2626;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ===== DataTable wrapper ===== */
.data-table-wrapper {
    background: var(--card-bg);
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    padding: 1.25rem;
}

.data-table-wrapper .dataTables_wrapper {
    padding: 0;
}

.data-table-wrapper .dataTables_filter input {
    border-radius: 0.5rem;
    border: 1px solid #cbd5e1;
    padding: 0.35rem 0.75rem;
}

.data-table-wrapper .dataTables_length select {
    border-radius: 0.5rem;
    border: 1px solid #cbd5e1;
}

/* ===== Filter Bar ===== */
.filter-bar {
    background: var(--card-bg);
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.filter-bar label {
    font-size: 0.8rem;
    font-weight: 500;
    color: #475569;
}

/* ===== SSO Error row colors ===== */
.row-exception {
    background-color: rgba(239,68,68,0.08) !important;
}

.row-auto-enrollment {
    background-color: rgba(245,158,11,0.08) !important;
}

.row-check-failed {
    background-color: rgba(234,179,8,0.08) !important;
}

/* ===== Toggle switch ===== */
.toggle-switch {
    cursor: pointer;
}

/* ===== Login Page ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #0f172a 0%, #1e293b 35%, #334155 65%, #1e293b 100%);
    padding: 1rem;
    position: relative;
    overflow: hidden;
}

/* Abstract background decoration */
.login-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.bg-s { position: absolute; }

/* === Strips - bande diagonali allungate === */
.bg-strip-1 {
    width: 700px;
    height: 3px;
    background: linear-gradient(90deg, transparent 0%, rgba(71,85,105,0.4) 30%, rgba(51,65,85,0.5) 60%, transparent 100%);
    top: 18%;
    left: -5%;
    transform: rotate(-18deg);
}

.bg-strip-2 {
    width: 550px;
    height: 50px;
    background: linear-gradient(135deg, rgba(51,65,85,0.35), rgba(71,85,105,0.08));
    top: -10px;
    right: -80px;
    transform: rotate(-22deg);
    border-radius: 2rem;
}

.bg-strip-3 {
    width: 400px;
    height: 25px;
    background: linear-gradient(90deg, transparent, rgba(51,65,85,0.25), rgba(71,85,105,0.15), transparent);
    bottom: 22%;
    left: -40px;
    transform: rotate(8deg);
    border-radius: 1rem;
}

/* === Arcs - mezzelune/archi curvi === */
.bg-arc-1 {
    width: 280px;
    height: 280px;
    border: 2px solid rgba(71,85,105,0.2);
    border-radius: 50%;
    top: 5%;
    right: 12%;
    clip-path: polygon(0 0, 100% 0, 100% 60%, 0 40%);
}

.bg-arc-2 {
    width: 400px;
    height: 400px;
    border: 1px solid rgba(51,65,85,0.15);
    border-radius: 50%;
    bottom: -15%;
    left: -8%;
    clip-path: polygon(30% 0, 100% 0, 100% 100%, 50% 100%);
}

/* === Rings - anelli vuoti === */
.bg-ring-1 {
    width: 120px;
    height: 120px;
    border: 2px solid rgba(71,85,105,0.18);
    border-radius: 50%;
    top: 30%;
    left: 6%;
}

.bg-ring-2 {
    width: 60px;
    height: 60px;
    border: 1.5px solid rgba(59,130,246,0.1);
    border-radius: 50%;
    bottom: 18%;
    right: 15%;
}

/* === Glows - bagliori sfumati === */
.bg-glow-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(51,65,85,0.2) 0%, transparent 65%);
    top: -12%;
    right: -10%;
    border-radius: 50%;
}

.bg-glow-2 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(71,85,105,0.15) 0%, transparent 60%);
    bottom: -8%;
    left: -5%;
    border-radius: 50%;
}

/* === Lines - linee sottilissime parallele === */
.bg-line-1 {
    width: 300px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(71,85,105,0.3), transparent);
    top: 40%;
    right: 0;
    transform: rotate(-5deg);
}

.bg-line-2 {
    width: 250px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(71,85,105,0.25), transparent);
    top: 42%;
    right: 2%;
    transform: rotate(-5deg);
}

.bg-line-3 {
    width: 180px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(71,85,105,0.2), transparent);
    top: 44%;
    right: 5%;
    transform: rotate(-5deg);
}

/* === Dots - piccoli punti sparsi === */
.bg-dot-1 {
    width: 6px;
    height: 6px;
    background: rgba(71,85,105,0.35);
    border-radius: 50%;
    top: 25%;
    left: 18%;
    box-shadow:
        22px 14px 0 rgba(71,85,105,0.2),
        48px -6px 0 rgba(71,85,105,0.15),
        -8px 30px 0 rgba(71,85,105,0.25),
        36px 32px 0 rgba(71,85,105,0.12);
}

.bg-dot-2 {
    width: 4px;
    height: 4px;
    background: rgba(71,85,105,0.3);
    border-radius: 50%;
    bottom: 30%;
    right: 8%;
    box-shadow:
        -15px 10px 0 rgba(71,85,105,0.2),
        12px 22px 0 rgba(71,85,105,0.15),
        -28px -8px 0 rgba(71,85,105,0.18);
}

.bg-dot-3 {
    width: 5px;
    height: 5px;
    background: rgba(59,130,246,0.12);
    border-radius: 50%;
    top: 65%;
    left: 12%;
    box-shadow:
        18px 8px 0 rgba(59,130,246,0.08),
        -10px 20px 0 rgba(59,130,246,0.06);
}

/* === Chevron - forma a V aperta === */
.bg-chevron {
    width: 80px;
    height: 80px;
    border-right: 2px solid rgba(71,85,105,0.18);
    border-bottom: 2px solid rgba(71,85,105,0.18);
    top: 70%;
    right: 25%;
    transform: rotate(-45deg);
    border-radius: 0 0 0.5rem 0;
}

.login-card {
    background: var(--card-bg);
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
}

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

.login-logo h2 {
    color: #1e293b;
    font-weight: 700;
    margin-top: 0.5rem;
}

.login-grid-icon {
    display: inline-grid;
    grid-template-columns: repeat(3, 16px);
    gap: 5px;
    margin-bottom: 0.25rem;
}

.login-grid-icon span {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    background: var(--accent-blue);
}

.login-grid-icon .sq-red { background: #ef4444; }
.login-grid-icon .sq-amber { background: #f59e0b; }
.login-grid-icon .sq-indigo { background: #6366f1; }

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

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

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1035;
    }

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

    .main-content {
        margin-left: 0;
        padding-top: calc(var(--topbar-height) + 1rem);
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

@media (min-width: 992px) {
    .topbar {
        display: none !important;
    }
}

/* ===== Scrollbar sidebar ===== */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

/* ===== Utilities ===== */
.text-blue { color: var(--accent-blue) !important; }
.text-green { color: var(--accent-green) !important; }
.text-amber { color: var(--accent-amber) !important; }
.text-red { color: var(--accent-red) !important; }

.cursor-pointer { cursor: pointer; }
