:root {
    --navy: #13294b;
    --navy-2: #1d3a66;
    --accent: #f59f00;
    --teal: #12a594;
    --bg: #f3f6fb;
    --card: #ffffff;
    --muted: #6b7a90;
    --radius: 14px;
}

* { font-family: 'Cairo', system-ui, -apple-system, 'Segoe UI', sans-serif; }
body { background: var(--bg); color: #1f2d3d; }

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 250px; flex-shrink: 0; background: var(--navy); color: #cfd8e6;
    display: flex; flex-direction: column; padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; padding: 4px 8px 18px; }
.brand img { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,.3); }
.brand span { font-weight: 700; line-height: 1.1; font-size: 15px; }
.brand small { display: block; font-weight: 400; color: var(--accent); font-size: 12px; letter-spacing: 2px; }
.sidebar nav { flex: 1; }
.nav-sep { text-transform: uppercase; font-size: 11px; letter-spacing: 1.5px; color: #7f93b2; margin: 16px 10px 6px; }
.nav-item-link {
    display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px;
    color: #cfd8e6; text-decoration: none; font-size: 14.5px; margin-bottom: 2px;
}
.nav-item-link i { font-size: 18px; width: 20px; text-align: center; }
.nav-item-link:hover { background: var(--navy-2); color: #fff; }
.nav-item-link.active { background: var(--accent); color: #13294b; font-weight: 700; }
.nav-item-link.logout { margin-top: 12px; border-top: 1px solid rgba(255,255,255,.1); border-radius: 0; padding-top: 14px; }

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 14px; padding: 14px 28px; background: #fff;
    border-bottom: 1px solid #e5eaf2; position: sticky; top: 0; z-index: 10;
}
.page-title { font-size: 20px; font-weight: 700; margin: 0; color: var(--navy); }
.user-chip { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.user-chip i { font-size: 22px; color: var(--navy); }
.role-tag { background: #eef3fb; color: var(--navy); border-radius: 20px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.content { padding: 24px 28px 40px; }

/* Cards */
.card-x { background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04); border: 1px solid #e8edf5; padding: 20px; margin-bottom: 20px; }
.card-x h2 { font-size: 16px; font-weight: 700; color: var(--navy); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.stat { display: flex; align-items: center; gap: 14px; }
.stat .ico { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; color: #fff; }
.stat .val { font-size: 26px; font-weight: 700; line-height: 1; color: var(--navy); }
.stat .lbl { color: var(--muted); font-size: 13px; }
.bg-navy { background: var(--navy) !important; }
.bg-accent { background: var(--accent) !important; }
.bg-teal { background: var(--teal) !important; }
.bg-rose { background: #e5484d !important; }
.bg-violet { background: #6e56cf !important; }

.btn-primary { background: var(--navy); border-color: var(--navy); }
.btn-primary:hover, .btn-primary:focus { background: var(--navy-2); border-color: var(--navy-2); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #13294b; font-weight: 700; }
.btn-accent:hover { background: #e08e00; color: #13294b; }

.table { vertical-align: middle; }
.table thead th { background: #f5f8fc; color: var(--navy); font-weight: 700; font-size: 13.5px; border-bottom: 1px solid #e3e9f2; }
.form-label { font-weight: 600; font-size: 13.5px; color: var(--navy); }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.empty i { font-size: 34px; display: block; margin-bottom: 6px; color: #b9c4d6; }

/* Appel (absences) */
.roll-row { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-bottom: 1px solid #eef2f7; }
.roll-row:last-child { border-bottom: 0; }
.roll-row .name { flex: 1; font-weight: 600; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #e7eefa; color: var(--navy); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex-shrink: 0; object-fit: cover; }
.btn-check + .btn { min-width: 86px; }

.profile-avatar { width: 112px !important; height: 112px !important; font-size: 34px !important; border: 4px solid #eef3fb; }
.class-card { transition: transform .15s, box-shadow .15s; }
.class-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(19,41,75,.12); }

/* Bibliothèque */
.book-card { display: block; text-decoration: none; color: inherit; background: #fff; border: 1px solid #e8edf5; border-radius: 14px; overflow: hidden; height: 100%; transition: transform .15s, box-shadow .15s; }
.book-card:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(19,41,75,.14); }
.book-cover { --c: #13294b; position: relative; height: 170px; padding: 14px; display: flex; flex-direction: column; justify-content: space-between;
    background: linear-gradient(150deg, var(--c), color-mix(in srgb, var(--c) 60%, #000)); color: #fff; }
.book-cover::before { content: ""; position: absolute; left: 10px; top: 0; bottom: 0; width: 3px; background: rgba(255,255,255,.25); }
.book-subject { font-size: 12px; background: rgba(255,255,255,.18); border-radius: 20px; padding: 1px 10px; align-self: flex-start; }
.book-title { font-weight: 700; font-size: 16px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.book-cover i { position: absolute; right: 12px; bottom: 8px; font-size: 26px; opacity: .35; }
.book-meta { padding: 10px 12px; }
.empty-book .book-cover { filter: grayscale(.7) opacity(.75); }
.reader { display: grid; grid-template-columns: 300px 1fr; gap: 16px; height: calc(100vh - 170px); min-height: 520px; }
.reader-toc { overflow-y: auto; padding: 12px; }
.reader-view { display: flex; flex-direction: column; padding: 12px; }
.reader-view iframe { flex: 1; width: 100%; border: 1px solid #e3e9f2; border-radius: 10px; background: #f5f7fb; }
.toc-module { font-weight: 700; color: var(--navy); margin: 8px 4px 4px; font-size: 14px; }
.toc-chap summary { cursor: pointer; padding: 6px 6px; border-radius: 8px; font-size: 14px; }
.toc-chap summary:hover { background: #f3f6fb; }
.toc-page { display: block; padding: 5px 10px 5px 22px; border-radius: 8px; font-size: 13.5px; color: #1f2d3d; text-decoration: none; }
.toc-page:hover { background: #eef3fb; }
.toc-page.active { background: var(--accent); color: var(--navy); font-weight: 700; }
.toc-page.disabled { color: #a0aabb; }
@media (max-width: 991px) { .reader { grid-template-columns: 1fr; height: auto; } .reader-toc { max-height: 260px; } .reader-view iframe { height: 75vh; } }

/* Garde */
.garde-now { background: linear-gradient(135deg, var(--teal), #0d7d70); color: #fff; border: 0; }
.garde-now h2 { color: #fff; }
.garde-person { display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,.14); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; }
.garde-person .avatar { background: #fff; color: var(--teal); }

/* Réclamations */
.thread-item { display: flex; gap: 12px; padding: 14px 6px; border-bottom: 1px solid #eef2f7; text-decoration: none; color: inherit; }
.thread-item:hover { background: #f8fafd; }
.thread-item.unread .subj { font-weight: 700; }
.thread-item .subj { color: var(--navy); }
.msg { border-radius: 14px; padding: 12px 16px; margin-bottom: 12px; max-width: 80%; }
.msg.me { background: #e9f1ff; margin-left: auto; }
.msg.other { background: #fff; border: 1px solid #e8edf5; }
.msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid #d9e2ef; border-radius: 8px; padding: 4px 10px; margin-top: 8px; font-size: 13px; text-decoration: none; }
.status-ouverte { background: #fff4e0; color: #a05e00; }
.status-en_cours { background: #e6f0ff; color: #1d4ed8; }
.status-traitee { background: #e3f7ee; color: #0f7a4a; }

/* Notes */
.note-input { width: 80px; text-align: center; }
.note-low { color: #c92a2a; font-weight: 700; }
.note-ok { color: #0f7a4a; font-weight: 700; }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--navy) 0%, #24508f 100%); padding: 20px; }
.login-card { background: #fff; border-radius: 20px; width: 100%; max-width: 400px; padding: 36px 32px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-card .logo { width: 86px; height: 86px; border-radius: 50%; object-fit: cover; display: block; margin: 0 auto 10px; border: 4px solid #eef3fb; }
.login-card h1 { text-align: center; font-size: 22px; font-weight: 700; color: var(--navy); margin-bottom: 2px; }
.login-card p.sub { text-align: center; color: var(--muted); margin-bottom: 24px; }

/* Mobile */
@media (max-width: 991px) {
    .sidebar { position: fixed; left: -260px; z-index: 50; transition: left .2s; }
    .sidebar.open { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.3); }
    .content { padding: 16px; }
    .topbar { padding: 12px 16px; }
    .user-chip span:not(.role-tag) { display: none; }
    .msg { max-width: 100%; }
}
@media print {
    .sidebar, .topbar, .no-print, .dt-length, .dt-search, .dt-paging { display: none !important; }
    .content { padding: 0; }
    .card-x { box-shadow: none; border: 0; }
}
