@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,600;12..96,700&family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

/* ── TOKENS ─────────────────────────────────────────────── */
:root {
    --ink:           #0C231C;
    --emerald:       #137A52;
    --emerald-deep:  #0E5C3E;
    --emerald-soft:  #E4F0EA;
    --gold:          #C0902E;
    --paper:         #E9EFEB;
    --card:          #FFFFFF;
    --field:         #F4F8F5;
    --muted:         #5C6F67;
    --text-muted:    #5C6F67;
    --line:          #D6E2DB;
    --danger:        #B23B3B;
    --danger-soft:   #FBECEC;
    --success:       #137A52;
    --success-dark:  #0E5C3E;
    --success-soft:  #E4F0EA;
    --info:          #2D6E8C;
    --info-soft:     #E7F0F4;
    --radius:        14px;
    --radius-md:     10px;
    --radius-lg:     18px;
    --shadow:        0 1px 2px rgba(12,35,28,.04), 0 18px 40px -22px rgba(12,35,28,.28);
    --ring:          0 0 0 4px rgba(19,122,82,.16);
    --ff-display:    'Bricolage Grotesque', 'Segoe UI', sans-serif;
    --ff-body:       'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
    --ff-mono:       'IBM Plex Mono', ui-monospace, 'Courier New', monospace;
}

/* ── BASE ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--ff-body);
    color: var(--ink);
    background-color: var(--paper);
    background-image: radial-gradient(circle at 1px 1px, rgba(19,122,82,.07) 1px, transparent 0);
    background-size: 26px 26px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

:focus-visible {
    outline: 2px solid var(--emerald);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ── NAVBAR ──────────────────────────────────────────────── */
.navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.9rem clamp(1.1rem, 5vw, 3rem);
    background: rgba(255,255,255,0.86);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--ff-display);
    font-weight: 700;
    font-size: 1.18rem;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.navbar-brand::before {
    content: "";
    width: 14px;
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(135deg, var(--emerald), var(--gold));
    box-shadow: var(--ring);
}

.navbar-nav {
    list-style: none;
    display: flex;
    align-items: center;
    gap: clamp(0.5rem, 2vw, 1.6rem);
    margin: 0;
    padding: 0;
}

.nav-link {
    position: relative;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--muted);
    padding: 0.35rem 0.1rem;
    transition: color 0.18s ease;
}

.nav-link::after {
    content: "";
    position: absolute;
    left: 0; bottom: -2px;
    width: 100%; height: 2px;
    background: var(--emerald);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.22s ease;
}

.nav-link:hover { color: var(--ink); }
.nav-link:hover::after, .nav-link.active::after { transform: scaleX(1); }
.nav-link.active { color: var(--ink); font-weight: 600; }

.nav-btn {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    background: var(--emerald);
    padding: 0.5rem 1.05rem;
    border-radius: 10px;
    transition: background 0.18s ease, transform 0.18s ease;
}
.nav-btn:hover { background: var(--emerald-deep); transform: translateY(-1px); }

.nav-btn-logout {
    background: var(--danger);
}
.nav-btn-logout:hover { background: #8C2B2B; }

/* ── LAYOUT ──────────────────────────────────────────────── */
.container {
    width: 100%;
    max-width: 1140px;
    margin-inline: auto;
    padding-inline: clamp(1.1rem, 5vw, 2rem);
    padding-block: clamp(1.5rem, 4vw, 3rem);
}

.centered-container {
    flex: 1;
    display: grid;
    place-items: center;
    padding-block: clamp(2rem, 6vw, 4rem);
}

/* ── CARD ────────────────────────────────────────────────── */
.card {
    position: relative;
    width: 100%;
    max-width: 560px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: clamp(1.6rem, 5vw, 2.75rem);
    overflow: hidden;
    animation: cardIn 0.5s cubic-bezier(0.22,1,0.36,1) both;
}

.card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, var(--emerald), var(--gold));
}

.card--wide { max-width: 920px; }

@keyframes cardIn {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.page-title {
    font-family: var(--ff-display);
    font-weight: 700;
    font-size: clamp(1.55rem, 4.5vw, 2.05rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin: 0.2rem 0 0;
}

.page-title::before {
    content: "● Gestion des étudiants";
    display: block;
    font-family: var(--ff-mono);
    font-weight: 500;
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--emerald);
    margin-bottom: 0.55rem;
}

.page-subtitle {
    color: var(--muted);
    font-size: 0.96rem;
    margin: 0.5rem 0 1.6rem;
    padding-bottom: 1.4rem;
    border-bottom: 1px solid var(--line);
}

/* ── FORMULAIRE ──────────────────────────────────────────── */
.form-group { margin-bottom: 1.15rem; }

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 0.42rem;
    letter-spacing: 0.005em;
}

.form-control {
    width: 100%;
    font-family: var(--ff-body);
    font-size: 0.95rem;
    color: var(--ink);
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.78rem 0.95rem;
    transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.form-control::placeholder { color: #9DACA4; }
.form-control:focus {
    outline: none;
    background: #fff;
    border-color: var(--emerald);
    box-shadow: var(--ring);
}
.form-control.is-invalid {
    border-color: var(--danger);
    background: var(--danger-soft);
}
.form-control.is-invalid:focus { box-shadow: 0 0 0 4px rgba(178,59,59,.15); }
.form-control.is-valid { border-color: var(--emerald); }

select.form-control {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235C6F67' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.95rem center;
    padding-right: 2.4rem;
    cursor: pointer;
}

.error-feedback {
    display: block;
    font-family: var(--ff-mono);
    font-size: 0.76rem;
    color: var(--danger);
    margin-top: 0.4rem;
    min-height: 0.2rem;
}

/* ── FILE UPLOAD ─────────────────────────────────────────── */
.file-upload-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 96px;
    padding: 1.1rem;
    background: var(--field);
    border: 1.5px dashed var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.18s, background 0.18s;
}
.file-upload-wrapper:hover, .file-upload-wrapper.dragover {
    border-color: var(--emerald);
    background: var(--emerald-soft);
}
.file-upload-info {
    font-size: 0.86rem;
    color: var(--muted);
    pointer-events: none;
}
.file-upload-info strong { color: var(--emerald); }
.file-upload-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* ── BOUTONS ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--ff-body);
    font-weight: 600;
    font-size: 0.98rem;
    letter-spacing: 0.01em;
    border: none;
    border-radius: var(--radius);
    padding: 0.92rem 1.4rem;
    cursor: pointer;
    transition: background 0.18s, transform 0.15s, box-shadow 0.18s;
    text-decoration: none;
}

.btn-primary {
    width: 100%;
    margin-top: 0.4rem;
    color: #fff;
    background: var(--emerald);
    box-shadow: 0 10px 24px -12px rgba(19,122,82,.7);
}
.btn-primary:hover { background: var(--emerald-deep); transform: translateY(-2px); box-shadow: 0 16px 30px -14px rgba(19,122,82,.75); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.65; cursor: progress; transform: none; }

.btn-secondary {
    color: var(--ink);
    background: var(--field);
    border: 1px solid var(--line);
}
.btn-secondary:hover { background: var(--line); }

/* ── ALERTES ─────────────────────────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    font-size: 0.9rem;
    line-height: 1.45;
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    border-left: 4px solid;
    margin-bottom: 1.2rem;
    animation: cardIn 0.35s ease both;
}
.alert > span { flex-shrink: 0; }
.alert a { color: var(--success-dark); }
.alert-success { background: var(--success-soft); border-color: var(--success); color: var(--emerald-deep); }
.alert-error,
.alert-danger  { background: var(--danger-soft);  border-color: var(--danger);  color: #8C2B2B; }
.alert-info    { background: var(--info-soft);     border-color: var(--info);    color: #235870; }

/* ── TOOLBAR ─────────────────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.4rem;
}

.search-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.search-form .form-control {
    flex: 1;
    min-width: 0;
    margin: 0;
}

.search-form .btn {
    width: auto;
    margin: 0;
}

/* ── TABLEAU ─────────────────────────────────────────────── */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--card);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.table-student {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.table-student thead th {
    font-family: var(--ff-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    text-align: left;
    padding: 0.85rem 1rem;
    border-bottom: 1.5px solid var(--line);
    background: var(--field);
    white-space: nowrap;
}

.table-student tbody td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.table-student tbody tr:last-child td { border-bottom: none; }
.table-student tbody tr { transition: background 0.15s; }
.table-student tbody tr:hover { background: var(--emerald-soft); }

/* ── AVATAR ──────────────────────────────────────────────── */
.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--line);
    display: block;
}

.avatar-placeholder {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--emerald-soft);
    color: var(--emerald-deep);
    font-family: var(--ff-mono);
    font-weight: 600;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    flex-shrink: 0;
}

/* ── BADGE FILIÈRE ───────────────────────────────────────── */
.badge {
    display: inline-block;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--emerald-deep);
    background: var(--emerald-soft);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    white-space: nowrap;
}

/* ── BOUTONS D'ACTION ────────────────────────────────────── */
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    font-size: 1rem;
    text-decoration: none;
    transition: background 0.15s, transform 0.15s;
    cursor: pointer;
}
.btn-edit  { background: var(--emerald-soft); }
.btn-edit:hover  { background: var(--emerald); transform: scale(1.08); }
.btn-delete { background: var(--danger-soft); }
.btn-delete:hover { background: var(--danger); transform: scale(1.08); }

/* ── PAGINATION ──────────────────────────────────────────── */
.pagination {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0;
    margin: 1.5rem 0 0;
    flex-wrap: wrap;
}

.page-item.disabled .page-link {
    opacity: 0.4;
    pointer-events: none;
    cursor: default;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--ink);
    background: var(--card);
    transition: background 0.15s, border-color 0.15s;
    text-decoration: none;
}

.page-link:hover { background: var(--emerald-soft); border-color: var(--emerald); }
.page-item.active .page-link {
    background: var(--emerald);
    border-color: var(--emerald);
    color: #fff;
}

/* ── PIED DE PAGE ────────────────────────────────────────── */
footer {
    text-align: center;
    padding: 1.8rem 1.2rem;
    font-family: var(--ff-mono);
    font-size: 0.78rem;
    color: var(--muted);
    border-top: 1px solid var(--line);
    background: rgba(255,255,255,0.5);
    margin-top: auto;
}
footer strong { color: var(--ink); font-weight: 500; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 640px) {
    .navbar { justify-content: center; }
    .navbar-nav { width: 100%; justify-content: center; flex-wrap: wrap; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .search-form { flex-wrap: wrap; }
    .page-title::before { font-size: 0.66rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}
