/* assets/css/app.css
   Stile applicativo LMS (estende Bootstrap 5) */

:root {
    --lms-primary: #3b5bdb;
    --lms-primary-dark: #2f4ac0;
    --lms-primary-soft: #edf1ff;
    --lms-sidebar: #111a33;
    --lms-sidebar-text: #aab4cf;
    --lms-bg: #f4f6fb;
    --lms-border: #e3e8f2;
    --lms-radius: .75rem;
    --bs-primary: #3b5bdb;
    --bs-primary-rgb: 59, 91, 219;
    --bs-link-color: #3b5bdb;
    --bs-link-hover-color: #2f4ac0;
    --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-bg: var(--lms-bg);
}

body { background: var(--lms-bg); font-size: .925rem; }

.btn-primary { --bs-btn-bg: var(--lms-primary); --bs-btn-border-color: var(--lms-primary); --bs-btn-hover-bg: var(--lms-primary-dark); --bs-btn-hover-border-color: var(--lms-primary-dark); --bs-btn-active-bg: var(--lms-primary-dark); --bs-btn-disabled-bg: var(--lms-primary); --bs-btn-disabled-border-color: var(--lms-primary); }
.btn-outline-primary { --bs-btn-color: var(--lms-primary); --bs-btn-border-color: var(--lms-primary); --bs-btn-hover-bg: var(--lms-primary); --bs-btn-hover-border-color: var(--lms-primary); --bs-btn-active-bg: var(--lms-primary); }
.text-primary { color: var(--lms-primary) !important; }
.bg-primary-soft { background: var(--lms-primary-soft) !important; }
.form-control:focus, .form-select:focus { border-color: #9fb0f0; box-shadow: 0 0 0 .2rem rgba(59, 91, 219, .15); }
.form-check-input:checked { background-color: var(--lms-primary); border-color: var(--lms-primary); }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
    width: 250px; flex-shrink: 0; background: var(--lms-sidebar); color: var(--lms-sidebar-text);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 1040;
}
.brand { display: flex; align-items: center; gap: .65rem; padding: 1.1rem 1.25rem; color: #fff; text-decoration: none; font-weight: 700; }
.brand:hover { color: #fff; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--lms-primary); display: grid; place-items: center; font-size: 1.15rem; }
.brand-text { line-height: 1.15; font-size: .98rem; }
.side-nav { padding: .5rem .75rem; flex: 1; }
.side-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; padding: .75rem .75rem .35rem; color: #6c7795; }
.side-link {
    display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: .5rem;
    color: var(--lms-sidebar-text); text-decoration: none; margin-bottom: 2px; transition: background .15s, color .15s;
}
.side-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.side-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-link.active { background: var(--lms-primary); color: #fff; }
.side-footer { padding: 1rem 1.25rem; color: #59627d; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
    display: flex; align-items: center; gap: .5rem; padding: .7rem 1.5rem; background: #fff;
    border-bottom: 1px solid var(--lms-border); position: sticky; top: 0; z-index: 1030;
}
.topbar-title { font-size: 1.15rem; font-weight: 650; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-content { padding: 1.5rem; flex: 1; }

.user-chip { display: flex; align-items: center; gap: .6rem; border: 1px solid var(--lms-border); border-radius: 2rem; padding: .25rem .75rem .25rem .3rem; background: #fff; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--lms-primary-soft); color: var(--lms-primary); display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex-shrink: 0; }

.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
    .app-sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; }
    body.sidebar-open .app-sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 1035; }
    .app-content { padding: 1rem; }
    .app-topbar { padding: .6rem 1rem; }
}

/* ---------- Componenti ---------- */
.card { border: 1px solid var(--lms-border); border-radius: var(--lms-radius); box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.card-header { background: #fff; border-bottom: 1px solid var(--lms-border); font-weight: 600; padding: .85rem 1.1rem; }
.card-header:first-child { border-radius: var(--lms-radius) var(--lms-radius) 0 0; }

.stat-card { padding: 1.1rem 1.2rem; display: flex; flex-direction: row; align-items: center; gap: 1rem; height: 100%; }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; flex-shrink: 0; }
.stat-value { font-size: 1.55rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: #6b7488; font-size: .8rem; }
.tone-blue { background: #edf1ff; color: #3b5bdb; }
.tone-green { background: #e6f6ee; color: #198754; }
.tone-amber { background: #fff4e0; color: #c77700; }
.tone-red { background: #fdecee; color: #d63a4a; }
.tone-purple { background: #f1ebfd; color: #6f42c1; }
.tone-gray { background: #eef0f4; color: #5c667a; }

.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.page-actions .search { max-width: 280px; }

.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: #6b7488; font-weight: 600; background: #f8f9fc; border-bottom-width: 1px; white-space: nowrap; }
.table td { vertical-align: middle; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f7f9ff; }
.table-card { overflow: hidden; }
.table-responsive { border-radius: 0 0 var(--lms-radius) var(--lms-radius); }

.badge-soft { font-weight: 600; padding: .35em .65em; border-radius: .4rem; }
.badge-status-draft { background: #eef0f4; color: #5c667a; }
.badge-status-published { background: #e6f6ee; color: #198754; }
.badge-status-archived { background: #fff4e0; color: #a86400; }
.badge-assigned { background: #eef0f4; color: #5c667a; }
.badge-in_progress { background: #edf1ff; color: #3b5bdb; }
.badge-completed { background: #e6f6ee; color: #198754; }
.badge-overdue { background: #fdecee; color: #d63a4a; }
.badge-valid { background: #e6f6ee; color: #198754; }
.badge-expired { background: #fdecee; color: #d63a4a; }
.badge-revoked { background: #eef0f4; color: #5c667a; text-decoration: line-through; }
.cat-dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .35rem; }

.progress { height: .5rem; background: #e9edf5; border-radius: 1rem; }
.progress-bar { background: var(--lms-primary); border-radius: 1rem; }
.progress-bar.done { background: #198754; }

.empty-state { text-align: center; padding: 3rem 1rem; color: #7a8297; }
.empty-state i { font-size: 2.6rem; display: block; margin-bottom: .6rem; color: #c3cad8; }

.btn-icon { padding: .25rem .45rem; line-height: 1; }
.cursor-grab { cursor: grab; }

/* ---------- Catalogo corsi / percorsi ---------- */
.course-card { overflow: hidden; height: 100%; transition: box-shadow .15s, transform .15s; }
.course-card:hover { box-shadow: 0 8px 24px rgba(16, 24, 40, .08); transform: translateY(-2px); }
.course-cover { aspect-ratio: 16/7; background: linear-gradient(135deg, #3b5bdb, #7048e8); display: grid; place-items: center; color: rgba(255, 255, 255, .85); font-size: 2rem; overflow: hidden; }
.course-cover img { width: 100%; height: 100%; object-fit: cover; }

.path-step { display: flex; gap: 1rem; padding: 1rem 1.1rem; border-bottom: 1px solid var(--lms-border); align-items: center; }
.path-step:last-child { border-bottom: 0; }
.step-num { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; flex-shrink: 0; background: var(--lms-primary-soft); color: var(--lms-primary); }
.path-step.done .step-num { background: #198754; color: #fff; }
.path-step.locked { opacity: .55; }
.path-step.locked .step-num { background: #eef0f4; color: #8a93a6; }

/* ---------- Builder corso ---------- */
.module-box { border: 1px solid var(--lms-border); border-radius: .6rem; background: #fff; margin-bottom: .9rem; }
.module-head { display: flex; align-items: center; gap: .5rem; padding: .65rem .9rem; background: #f8f9fc; border-bottom: 1px solid var(--lms-border); border-radius: .6rem .6rem 0 0; }
.lesson-list { min-height: 12px; padding: .35rem; }
.lesson-row { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; border-radius: .45rem; }
.lesson-row:hover { background: #f7f9ff; }
.lesson-type { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
.sortable-ghost { opacity: .4; background: var(--lms-primary-soft); }

/* ---------- Player ---------- */
.player { display: grid; grid-template-columns: 320px 1fr; gap: 1.25rem; align-items: start; }
.player-nav { position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow-y: auto; }
.player-nav .mod-title { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: #6b7488; padding: .8rem 1rem .3rem; font-weight: 600; }
.player-nav .les { display: flex; align-items: center; gap: .55rem; padding: .5rem 1rem; color: inherit; text-decoration: none; border-left: 3px solid transparent; font-size: .88rem; }
.player-nav .les:hover { background: #f7f9ff; }
.player-nav .les.active { background: var(--lms-primary-soft); border-left-color: var(--lms-primary); font-weight: 600; }
.player-nav .les .st { font-size: 1rem; }
.lesson-body { font-size: 1rem; line-height: 1.65; }
.lesson-body img { max-width: 100%; height: auto; }
.lesson-body iframe { max-width: 100%; }
.ratio-video { position: relative; padding-top: 56.25%; background: #000; border-radius: .6rem; overflow: hidden; }
.ratio-video iframe, .ratio-video video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.doc-frame { width: 100%; height: 75vh; border: 1px solid var(--lms-border); border-radius: .6rem; }
@media (max-width: 991.98px) {
    .player { grid-template-columns: 1fr; }
    .player-nav { position: static; max-height: none; }
}

/* ---------- Quiz ---------- */
.q-card { border: 1px solid var(--lms-border); border-radius: .6rem; padding: 1rem 1.1rem; margin-bottom: 1rem; background: #fff; }
.q-card .form-check { padding: .5rem .75rem .5rem 2.2rem; border-radius: .45rem; border: 1px solid transparent; margin-bottom: .35rem; }
.q-card .form-check:hover { background: #f7f9ff; }
.q-card .form-check.ok { border-color: #a3d9b8; background: #eefaf3; }
.q-card .form-check.ko { border-color: #f1b0b7; background: #fdf1f2; }
.quiz-timer { position: sticky; top: 72px; z-index: 5; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: #fff; }
.login-hero { background: radial-gradient(circle at 20% 20%, #4c6ef5 0, #3b5bdb 35%, #1b2a6b 100%); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.login-hero h2 { font-weight: 750; font-size: 2.1rem; max-width: 26rem; line-height: 1.2; }
.login-hero .feat { display: flex; gap: .75rem; align-items: flex-start; margin-bottom: 1rem; opacity: .92; }
.login-hero .feat i { font-size: 1.25rem; }
.login-form-wrap { display: grid; place-items: center; padding: 2rem; }
.login-form { width: 100%; max-width: 380px; }
@media (max-width: 860px) {
    .login-page { grid-template-columns: 1fr; }
    .login-hero { display: none; }
}

/* ---------- Certificato (stampa) ---------- */
.cert-sheet { width: 297mm; min-height: 210mm; margin: 1.5rem auto; background: #fff; padding: 14mm; box-shadow: 0 10px 30px rgba(0, 0, 0, .1); }
.cert-inner { border: 3px double #3b5bdb; height: 100%; min-height: 182mm; padding: 14mm 18mm; display: flex; flex-direction: column; text-align: center; position: relative; }
.cert-inner h1 { font-family: Georgia, "Times New Roman", serif; font-size: 2.6rem; letter-spacing: .12em; color: #1b2a6b; margin: .4rem 0 0; }
.cert-name { font-family: Georgia, "Times New Roman", serif; font-size: 2.2rem; color: #111; border-bottom: 1px solid #c9d1e6; display: inline-block; padding: 0 2rem .3rem; margin: .5rem 0 1rem; }
.cert-title { font-size: 1.45rem; font-weight: 700; color: #3b5bdb; }
.cert-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: flex-end; font-size: .85rem; text-align: left; }
.cert-sign { border-top: 1px solid #333; padding-top: .3rem; min-width: 60mm; text-align: center; }
@media print {
    @page { size: A4 landscape; margin: 0; }
    body { background: #fff; }
    .no-print { display: none !important; }
    .cert-sheet { margin: 0; box-shadow: none; width: 297mm; height: 210mm; }
}
