/* ============================================================================
   Gestion des Stages — UFR Sciences Médicales d'Abidjan
   Palette ancrée sur le vert institutionnel des deux blasons (UFHB / UFR-SM) :
   un vert profond en assise, un vert de gorge (sauge) en accent, un fond
   ivoire chaud plutôt qu'un blanc clinique.
   ============================================================================ */

:root {
    --vert-fonce:   #163A2B;   /* assise, sidebar, texte fort */
    --vert-moyen:   #21603F;   /* accent primaire, boutons */
    --vert-sauge:   #7A9A85;   /* accent secondaire, hover */
    --ivoire:       #F6F4EE;   /* fond général */
    --blanc-carte:  #FFFFFF;
    --encre:        #232A24;  /* texte principal */
    --encre-douce:  #5B655D;  /* texte secondaire */
    --bordure:      #E1DED2;
    --alerte-ambre: #B4791A;
    --alerte-rouge: #A3342A;
    --alerte-verte: #2F6B3F;

    --rayon: 10px;
    --ombre: 0 1px 2px rgba(22, 58, 43, 0.06), 0 4px 14px rgba(22, 58, 43, 0.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Source Sans 3', 'Segoe UI', Tahoma, sans-serif;
    background: var(--ivoire);
    color: var(--encre);
    font-size: 15px;
    line-height: 1.5;
}

h1, h2, h3, h4 {
    font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    color: var(--vert-fonce);
    font-weight: 600;
    margin: 0 0 .5rem;
}
h1 { font-size: 1.7rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

a { color: var(--vert-moyen); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Structure générale : sidebar + contenu ------------------------------ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: var(--vert-fonce);
    color: #DCE7DF;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0;
}
.sidebar .brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 0 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.12);
    margin-bottom: 1rem;
}
.sidebar .brand img { height: 38px; width: auto; border-radius: 4px; background: #fff; padding: 2px; }
.sidebar .brand strong { font-size: .95rem; color: #fff; display: block; line-height: 1.2; }
.sidebar .brand span { font-size: .72rem; color: #B9C9BE; }

.sidebar nav { flex: 1; }
.sidebar .nav-section-label {
    font-size: .7rem;
    color: #8FA394;
    padding: 1rem 1.25rem .35rem;
    letter-spacing: .02em;
}
.sidebar a.nav-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .6rem 1.25rem;
    color: #D6E2DA;
    border-left: 3px solid transparent;
}
.sidebar a.nav-link:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar a.nav-link.active {
    background: rgba(255,255,255,.09);
    border-left-color: var(--vert-sauge);
    color: #fff;
    font-weight: 600;
}
.sidebar .user-box {
    margin: 1rem 1.25rem 0;
    padding: .75rem;
    border-radius: var(--rayon);
    background: rgba(255,255,255,.06);
    font-size: .82rem;
}
.sidebar .user-box .role { color: var(--vert-sauge); font-size: .72rem; }
.sidebar .logout { display: inline-block; margin-top: .5rem; color: #E8B4AC; font-size: .8rem; }

.main {
    flex: 1;
    min-width: 0;
    padding: 1.75rem 2.25rem 3rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: .5rem;
}
.topbar .breadcrumb { font-size: .82rem; color: var(--encre-douce); }

/* --- Cartes / conteneurs -------------------------------------------------- */
.card {
    background: var(--blanc-carte);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    box-shadow: var(--ombre);
    padding: 1.4rem;
    margin-bottom: 1.25rem;
}
.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-tile {
    background: var(--blanc-carte);
    border: 1px solid var(--bordure);
    border-left: 4px solid var(--vert-moyen);
    border-radius: var(--rayon);
    padding: 1rem 1.15rem;
}
.stat-tile.warn { border-left-color: var(--alerte-ambre); }
.stat-tile.danger { border-left-color: var(--alerte-rouge); }
.stat-tile .value { font-family: 'Source Serif 4', serif; font-size: 1.9rem; color: var(--vert-fonce); font-weight: 600; }
.stat-tile .label { font-size: .82rem; color: var(--encre-douce); }

/* --- Formulaires ----------------------------------------------------------*/
label { display: block; font-size: .85rem; font-weight: 600; color: var(--encre); margin-bottom: .3rem; }
.form-group { margin-bottom: 1rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], select, textarea {
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid var(--bordure);
    border-radius: 7px;
    background: #fff;
    font-size: .92rem;
    font-family: inherit;
    color: var(--encre);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--vert-moyen);
    box-shadow: 0 0 0 3px rgba(33, 96, 63, .13);
}
.hint { font-size: .78rem; color: var(--encre-douce); margin-top: .25rem; }

/* --- Boutons ---------------------------------------------------------------*/
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.1rem;
    border-radius: 7px;
    border: 1px solid transparent;
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.btn-primary { background: var(--vert-moyen); color: #fff; }
.btn-primary:hover { background: var(--vert-fonce); text-decoration: none; }
.btn-outline { background: transparent; border-color: var(--vert-moyen); color: var(--vert-moyen); }
.btn-outline:hover { background: rgba(33,96,63,.07); text-decoration: none; }
.btn-danger { background: var(--alerte-rouge); color: #fff; }
.btn-danger:hover { background: #7f2820; text-decoration: none; }
.btn-sm { padding: .32rem .65rem; font-size: .78rem; }

/* --- Tables ------------------------------------------------------------- */
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data th {
    text-align: left;
    padding: .6rem .7rem;
    background: #EFEDE3;
    color: var(--vert-fonce);
    border-bottom: 2px solid var(--bordure);
    font-weight: 600;
}
table.data td { padding: .55rem .7rem; border-bottom: 1px solid var(--bordure); vertical-align: middle; }
table.data tr:hover td { background: #FAF9F4; }

.badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 20px;
    font-size: .74rem;
    font-weight: 600;
}
.badge-vert   { background: #E1EEE3; color: var(--vert-fonce); }
.badge-ambre  { background: #F5E6CC; color: var(--alerte-ambre); }
.badge-rouge  { background: #F3DBD8; color: var(--alerte-rouge); }
.badge-gris   { background: #E8E6DD; color: var(--encre-douce); }

/* --- Alertes / flash ------------------------------------------------------*/
.alert { padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1.1rem; font-size: .9rem; }
.alert-success { background: #E4F1E6; color: #235330; border: 1px solid #BFDFC5; }
.alert-error   { background: #F6DEDA; color: #7C2A20; border: 1px solid #E8B9B0; }
.alert-warning { background: #FBEED9; color: #7A4E0C; border: 1px solid #EFD3A0; }
.alert-info    { background: #E4EEF6; color: #204A6B; border: 1px solid #BFDCEF; }

/* --- Page de connexion ---------------------------------------------------*/
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--vert-fonce) 0%, #234A38 55%, var(--vert-moyen) 100%);
    padding: 1.5rem;
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--blanc-carte);
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
    padding: 2.2rem 2rem;
}
.login-logos { display: flex; justify-content: center; gap: 1.4rem; margin-bottom: 1.1rem; }
.login-logos img { height: 56px; width: auto; }
.login-card h1 { text-align: center; font-size: 1.15rem; margin-bottom: .15rem; }
.login-card .subtitle { text-align: center; color: var(--encre-douce); font-size: .82rem; margin-bottom: 1.6rem; }
.login-card .btn-primary { width: 100%; justify-content: center; margin-top: .5rem; }

/* --- Divers ---------------------------------------------------------------*/
.text-muted { color: var(--encre-douce); }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.d-flex { display: flex; } .gap-1 { gap: .5rem; } .align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-100 { width: 100%; }

@media (max-width: 900px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; }
    .main { padding: 1.25rem; }
}
/* --- Modales (ajout / modification, style natif sans Bootstrap) -----------*/
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(22, 58, 43, .45);
    z-index: 1000;
    padding: 2rem 1rem;
    overflow-y: auto;
}
.modal-overlay.is-open { display: flex; align-items: flex-start; justify-content: center; }
.modal-box {
    background: var(--blanc-carte);
    border-radius: 12px;
    width: 100%;
    max-width: 640px;
    box-shadow: 0 25px 60px rgba(0,0,0,.3);
    margin: auto;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--bordure);
}
.modal-header h3 { margin: 0; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    color: var(--encre-douce);
    padding: .2rem .4rem;
}
.modal-close:hover { color: var(--encre); }
.modal-body { padding: 1.4rem; max-height: 70vh; overflow-y: auto; }
.modal-footer {
    padding: 1rem 1.4rem;
    border-top: 1px solid var(--bordure);
    display: flex;
    justify-content: flex-end;
    gap: .6rem;
}

/* --- Accordéon (regroupement des occurrences de stage par ECUE) ----------*/
.accordion-item {
    border: 1px solid var(--bordure);
    border-radius: 10px;
    margin-bottom: .8rem;
    overflow: hidden;
    background: var(--blanc-carte);
}
.accordion-trigger {
    width: 100%;
    text-align: left;
    background: #F2F0E6;
    border: none;
    padding: .85rem 1.1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    font-family: inherit;
}
.accordion-trigger:hover { background: #ECEADC; }
.accordion-trigger .chevron { transition: transform .15s; color: var(--vert-moyen); }
.accordion-trigger[aria-expanded="true"] .chevron { transform: rotate(90deg); }
.accordion-panel { display: none; padding: 1rem 1.1rem; }
.accordion-panel.is-open { display: block; }
