/* ===========================================================================
   app.css — couche au-dessus de 98.css : layout plein écran, grille,
   habillage des tables et utilitaires. Style Windows 95.
   ========================================================================= */

html, body {
    height: 100%;
    margin: 0;
}

body {
    /* Fond "bureau" Win95 turquoise classique */
    background: #008080;
    padding: 0;
    font-size: 12px;
}

/* Police de base agrandie +1px (11px → 12px) sur tout le site, en surchargeant
   la taille fixée par 98.css. Le tableau de données garde sa propre taille (14px). */
.title-bar, .window, button, input, label, legend,
li[role=tab], option, select, textarea, ul.tree-view {
    font-size: 12px;
}


/* --- Fenêtre principale plein écran ------------------------------------- */
.app-shell {
    display: flex;
    flex-direction: column;
    align-items: center;      /* centre la fenêtre horizontalement */
    height: 100vh;            /* fenêtre bornée à l'écran : le contenu scrolle, pas la page */
    overflow: hidden;         /* jamais de scrollbar de page (les zones internes scrollent) */
    box-sizing: border-box;
    padding: 24px;            /* laisse respirer le fond turquoise autour */
}

.app-window {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: 1400px;        /* fenêtre plus compacte sur grand écran */
}

/* Bouton « Restaurer » : masqué par défaut (mode fenêtré).
   Sélecteurs à 2+ classes pour battre la spécificité de 98.css (.title-bar-controls button). */
.title-bar-controls .ctl-restore { display: none; }

/* Fenêtre agrandie (clic sur « Agrandir » → classe .maximized) : plein écran + « Restaurer ». */
.app-shell.maximized { padding: 0; }
.app-shell.maximized .app-window { max-width: none; }
.app-shell.maximized .ctl-maximize { display: none; }
.app-shell.maximized .ctl-restore { display: block; }

/* --- Mobile : toujours plein écran, plus de fond turquoise, bouton « Restaurer » --- */
@media (max-width: 768px) {
    body { background: silver; }
    .app-shell { padding: 0; }
    .app-window { max-width: none; }
    .title-bar-controls .ctl-maximize { display: none; }
    .title-bar-controls .ctl-restore { display: block; }
}

.app-window .window-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: auto;
}
/* Mode "fenêtre fixe" : pas de scroll de page, c'est le contenu (grille) qui scrolle. */
.app-window .window-body.fill { overflow: hidden; }
.page-fill {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}
.page-fill .data-table-wrap {
    flex: 1 1 auto;
    min-height: 0;
}

/* --- Barre de menus (navigation) ---------------------------------------- */
.menu-bar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border-bottom: 1px solid #808080;
    background: silver;
    flex-wrap: wrap;
}

.menu-bar a,
.menu-bar .brand {
    text-decoration: none;
    color: #000;
    padding: 3px 10px;
    display: inline-block;
}

.menu-bar a:hover {
    background: #000080;
    color: #fff;
}

.menu-bar .brand {
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 6px;
}

.menu-bar .spacer { flex: 1 1 auto; }

/* --- Barre d'état -------------------------------------------------------- */
.status-bar-field { padding: 2px 8px; }

/* --- Grille de mise en page (form rows) --------------------------------- */
.row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 8px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.field.grow { flex: 1 1 0; }
.col-1 { flex: 1 1 0; }
.col-2 { flex: 2 1 0; }
.col-3 { flex: 3 1 0; }

.field > label { font-weight: bold; }
.field input[type="text"],
.field input[type="time"],
.field input[type="password"],
.field select,
.field textarea {
    width: 100%;
    box-sizing: border-box;
}

/* --- Tables de données --------------------------------------------------- */
.data-table-wrap {
    flex: 1 1 auto;
    overflow: auto;
    border: 2px groove #fff;
    background: #fff;
}

table.data-table {
    border-collapse: collapse;
    width: 100%;
    background: #fff;
    font-size: 14px;          /* agrandi pour la lisibilité (demande client) */
    /* Police lisse et lisible (version scalable de la police Win95), uniquement
       dans le tableau ; le reste du site garde la police bitmap de 98.css. */
    font-family: "Microsoft Sans Serif", Tahoma, "Segoe UI", Arial, sans-serif;
}

table.data-table th,
table.data-table td {
    border: 1px solid #c0c0c0;
    padding: 4px 7px;          /* cellules un peu plus aérées */
    text-align: left;
    white-space: nowrap;
}

table.data-table thead th {
    position: sticky;
    top: 0;
    background: silver;
    border-bottom: 2px solid #808080;
    z-index: 1;
}

table.data-table tbody tr:nth-child(even) { background: #f3f3f3; }
table.data-table td.cell-call { font-weight: bold; } /* colonne Indicatif mise en avant */
table.data-table tbody tr:hover { background: #000080; color: #fff; }

/* --- Pagination ---------------------------------------------------------- */
.pager {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 2px;
    flex-wrap: wrap;
}
.pager .grow { flex: 1 1 auto; }

/* --- Utilitaires --------------------------------------------------------- */
.toolbar {
    display: flex;
    gap: 6px;
    padding: 6px 2px;
    flex-wrap: wrap;
    align-items: center;
}
.search-clear {
    min-width: 0;
    min-height: 0;
    width: 18px;
    height: 18px;
    padding: 0;
    font-size: 11px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.mt-1 { margin-top: 8px; }
.mb-1 { margin-bottom: 8px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.hidden { display: none !important; }
[x-cloak] { display: none !important; }
.flash {
    margin: 8px 0;
    padding: 6px 10px;
    border: 2px groove #fff;
    background: #ffffe1;
}
.text-danger { color: #aa0000; font-weight: bold; }
.muted { color: #555; }

/* --- Login --------------------------------------------------------------- */
.login-center {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-center .window { width: 320px; }

/* === Scrollbar Windows 95 réutilisable (pilotée par winscroll.js) =========
   Remplace les scrollbars natives par une barre Win95 toujours visible,
   identique dans tous les navigateurs. S'applique à tout .js-winscroll. */
.wsc-host {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    scrollbar-width: none;            /* Firefox : masque la native */
    -ms-overflow-style: none;          /* anciens Edge/IE */
}
.wsc-host::-webkit-scrollbar { width: 0; height: 0; display: none; } /* webkit */
.wsc-wrap { position: relative; box-sizing: border-box; }
.wsc-wrap.has-v { padding-right: 16px; }
.wsc-wrap.has-h { padding-bottom: 16px; }
.wsc-bar { position: absolute; background: silver; display: flex; user-select: none; }
.wsc-vbar { top: 0; right: 0; bottom: 0; width: 16px; flex-direction: column; }
.wsc-hbar { left: 0; right: 0; bottom: 0; height: 16px; flex-direction: row; }
.wsc-wrap.has-v.has-h .wsc-hbar { right: 16px; }
.wsc-corner { position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; background: silver; }
.wsc-arrow {
    flex: 0 0 16px;
    width: 16px; height: 16px;
    min-width: 0; min-height: 0; padding: 0;
    display: flex; align-items: center; justify-content: center;
}
.wsc-track {
    flex: 1 1 auto;
    position: relative;
    background-color: #dfdfdf;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='2' height='2' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 0H0v1h1v1h1V1H1V0z' fill='silver'/%3E%3Cpath d='M2 0H1v1H0v1h1V1h1V0z' fill='%23fff'/%3E%3C/svg%3E");
}
.wsc-thumb {
    position: absolute;
    background: silver;
    box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #fff, inset -2px -2px grey, inset 2px 2px #dfdfdf;
    cursor: default;
}
.wsc-vbar .wsc-thumb { left: 0; width: 16px; min-height: 16px; }
.wsc-hbar .wsc-thumb { top: 0; height: 16px; min-width: 16px; }
.tri-up, .tri-down { width: 0; height: 0; border-left: 3px solid transparent; border-right: 3px solid transparent; }
.tri-up { border-bottom: 4px solid #000; }
.tri-down { border-top: 4px solid #000; }
.tri-left, .tri-right { width: 0; height: 0; border-top: 3px solid transparent; border-bottom: 3px solid transparent; }
.tri-left { border-right: 4px solid #000; }
.tri-right { border-left: 4px solid #000; }

/* --- Export carnets ------------------------------------------------------ */
.carnet-layout {
    display: flex;
    gap: 10px;
    align-items: stretch;
    min-height: 0;
}
.carnet-list {
    flex: 0 0 148px;
    max-height: 420px;
    overflow-y: auto;
    border: 2px groove #fff;
    background: #fff;
    padding: 3px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.carnet-list button { text-align: left; }
.carnet-list button.sel {
    background: #000080 !important;
    color: #fff !important;
    font-weight: bold;
}
.carnet-pages {
    flex: 1 1 auto;
    max-height: 420px;
    overflow-y: auto;
    padding: 4px 8px;
}
.carnet-page-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.carnet-page-row button { flex: 0 0 80px; }
.carnet-page-row .progress-indicator { flex: 1 1 auto; height: 20px; padding: 3px; }
.carnet-page-row .pct { flex: 0 0 42px; text-align: right; }
.carnet-page-row .progress-indicator-bar.partial { background-color: #808000; }

/* --- Icônes réelles (aucun emoji) --------------------------------------- */
.title-bar-text img { width: 14px; height: 14px; vertical-align: -2px; margin-right: 5px; }
/* Titre rétractable : il tronque (…) au lieu de pousser les boutons hors écran. */
.title-bar-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.btn-icon { min-width: 0; padding: 3px 7px; line-height: 0; }
.btn-icon img { width: 16px; height: 16px; display: block; }
.tri-up, .tri-down, .tri-left, .tri-right { display: inline-block; vertical-align: middle; }
.pager .tri-left { margin-right: 6px; }
.pager .tri-right { margin-left: 6px; }
.sort-ind { display: inline-block; margin-left: 4px; }

/* --- Boîte de dialogue Windows 95 (remplace confirm() natif) ------------ */
.win-modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.25);
    z-index: 1000;
}
.win-modal { min-width: 320px; max-width: 460px; }
.win-modal .window-body { margin: 10px; }
.win-modal-body {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 16px;
}
.win-modal-icon {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #000;
    background: #fff;
    color: #000080;
    font-weight: bold;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.win-modal-msg { flex: 1 1 auto; padding-top: 5px; line-height: 1.4; }
.win-modal-actions { display: flex; gap: 8px; justify-content: center; }
.win-modal-actions button { min-width: 84px; }

/* --- Tuiles d'accueil (lanceur façon Program Manager) ------------------- */
.tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 14px;
}
.tile {
    width: 124px;
    height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    text-align: center;
}
.tile img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

/* --- Autocomplétion maison (dropdown style Windows 95) ------------------ */
.ac-wrap { position: relative; }
.ac-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    margin: 0;
    padding: 2px;
    list-style: none;
    max-height: 168px;
    overflow-y: auto;
    background: #fff;
    box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #808080, inset -2px -2px #dfdfdf, inset 2px 2px #fff;
    border: 1px solid #000;
    scrollbar-width: auto;
    scrollbar-color: #808080 #dfdfdf;
}
.ac-list li {
    display: flex;
    align-items: stretch;
    cursor: default;
}
.ac-list li.sel,
.ac-list li:hover {
    background: #000080;
    color: #fff;
}
.ac-val {
    flex: 1 1 auto;
    padding: 1px 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ac-del {
    flex: 0 0 auto;
    min-width: 0;
    min-height: 0;
    padding: 0 6px;
    border: none;
    background: transparent;
    box-shadow: none;
    color: inherit;
    cursor: pointer;
    font-weight: bold;
    line-height: 1;
}
.ac-del:active { box-shadow: none; }
.ac-del:hover { color: #ff6961; }   /* rouge clair au survol de la croix */

/* --- Datepicker maison (calendrier déroulant style Windows 95) ---------- */
.dp-cal {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 60;
    width: 196px;
    background: silver;
    padding: 3px;
    box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #fff, inset -2px -2px grey, inset 2px 2px #dfdfdf;
    border: 1px solid #000;
}
.dp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #000080;
    color: #fff;
    padding: 2px 4px;
    margin-bottom: 3px;
}
.dp-title { font-weight: bold; }
.dp-nav {
    min-width: 0;
    min-height: 0;
    padding: 1px 6px;
}
.dp-head .tri-left { border-right-color: #fff; }
.dp-head .tri-right { border-left-color: #fff; }
.dp-dows {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: bold;
    margin-bottom: 2px;
}
.dp-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}
.dp-day {
    min-width: 0;
    min-height: 0;
    padding: 2px 0;
    border: none;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
    text-align: center;
}
.dp-day:active { box-shadow: none; }
.dp-day.empty { visibility: hidden; }
.dp-day:not(.empty):hover,
.dp-day.sel { background: #000080; color: #fff; }

/* --- Spinner de traitement ---------------------------------------------- */
.processing {
    padding: 6px;
    font-style: italic;
    color: #000080;
}
