/*
    L'habillage de l'application.

    Il reprend le parti du logiciel de bureau : une feuille claire, une encre sombre, une
    seule couleur pour ce qui appelle l'action, et rien qui brille. Le plan occupe toute la
    place qu'on lui laisse ; le reste se range autour.

    Les teintes sont celles de la charte Prophetix (charte/prophetix-charte.css, chargee avant
    cette feuille) : les noms ci-dessous gardent leur role dans les regles, et la charte leur
    donne sa valeur. Le violet porte l'action ; le grege fait les fonds et les traits. Le dessin
    du plan, lui, garde ses propres teintes : elles sont celles du poste et se lisent comme un
    plan, pas comme une marque.
*/

:root {
    --encre: var(--px-texte);
    --encre-douce: var(--px-texte-secondaire);
    --feuille: var(--px-surface);
    --fond: var(--px-fond);
    --trait: var(--px-bordure);
    --primaire: var(--px-primaire);
    --primaire-survol: var(--px-primaire-survol);
    --primaire-texte: var(--px-primaire-texte);
    --choisi: var(--px-violet-clair);

    /* Les etats ne sont pas des couleurs de marque : ils disent bien, attention, faute. Chacun
       est assez sombre pour se lire en texte sur le blanc comme sur le grege clair (4,7:1 au
       moins), ce que ni l'orange ni le vert du poste ne faisaient. */
    --orange: #A4491D;
    --vert: #1B7A43;
    --rouge: #B03A2B;
    --or: #8B5E0A;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--fond);
    color: var(--encre);
    font-family: var(--px-police);
    font-size: 15px;
    line-height: 1.45;
}

/* La racine de Blazor porte la hauteur de la page jusqu'a la mise en page. */
#app { height: 100%; }

.app {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* ----- L'en-tete ----- */

.bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    height: 52px;
    background: var(--feuille);
    border-bottom: 1px solid var(--trait);
    flex: 0 0 auto;
}

.bar-spacer { flex: 1 1 auto; }

/* Le cartouche de la charte tient lieu de nom et de logo ; il ramene a la liste des plans. */
.bar > .px-cartouche:focus-visible { outline: 2px solid var(--primaire); outline-offset: 2px; }

.who { color: var(--encre-douce); }

.lang, select {
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--trait);
    border-radius: 5px;
    background: var(--feuille);
    color: var(--encre);
    font: inherit;
}

.content {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

/* ----- Les feuilles de contenu ----- */

.sheet {
    max-width: 480px;
    margin: 40px auto;
    padding: 28px 32px;
    background: var(--feuille);
    border: 1px solid var(--trait);
    border-radius: 8px;
}

.sheet.wide { max-width: 900px; }
.sheet.pad, .pad { padding: 24px; }

.sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

h1 { font-size: 22px; margin: 0 0 4px; font-weight: 600; }
h2 { font-size: 16px; margin: 28px 0 10px; font-weight: 600; color: var(--encre-douce); }
h3 { font-size: 15px; margin: 22px 0 8px; font-weight: 600; color: var(--encre-douce); }

.lead { color: var(--encre-douce); margin: 6px 0 18px; }
.aside { margin-top: 18px; color: var(--encre-douce); }
.note { color: var(--encre-douce); font-size: 13px; margin: 6px 0 0; }

label {
    display: block;
    margin: 14px 0;
}

label > span {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    color: var(--encre-douce);
}

label.check { display: flex; align-items: center; gap: 8px; }
label.check > span { margin: 0; font-size: 15px; color: var(--encre); }

input[type=text], input[type=email], input[type=password] {
    width: 100%;
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--trait);
    border-radius: 5px;
    font: inherit;
    color: var(--encre);
    background: var(--feuille);
}

input:focus, select:focus, button:focus-visible {
    outline: 2px solid var(--primaire);
    outline-offset: 1px;
}

/* ----- Les boutons ----- */

.btn {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--trait);
    border-radius: 5px;
    background: var(--feuille);
    color: var(--encre);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover { background: var(--fond); }

.btn-main {
    background: var(--primaire);
    border-color: var(--primaire);
    color: var(--primaire-texte);
}

.btn-main:hover { background: var(--primaire-survol); border-color: var(--primaire-survol); }
.btn-main:disabled { opacity: 0.55; cursor: default; }

.btn-quiet { border-color: transparent; color: var(--primaire); }
.btn-quiet:hover { background: var(--fond); }
.btn-quiet.danger { color: var(--rouge); }

.link {
    border: 0;
    background: none;
    padding: 0;
    color: var(--primaire);
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
}

.tag {
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--fond);
    color: var(--encre-douce);
    font-size: 13px;
}

/* ----- Les messages ----- */

.error { color: var(--rouge); margin: 10px 0; }

.banner {
    margin: 0;
    padding: 8px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--trait);
}

/* Les fonds viennent de la charte (turquoise, anis) ; le texte reste a l'encre ou a une couleur
   d'etat sombre : l'anis et le turquoise ne se lisent pas en texte sur fond clair. */
.banner.good { background: var(--px-turquoise-clair); color: var(--vert); }
.banner.bad { background: #FBEEEC; color: var(--rouge); }
.banner.warn { background: var(--px-anis-clair); color: var(--encre); box-shadow: inset 4px 0 0 var(--px-anis); }
.banner .link { margin-left: 10px; }

.page-message { max-width: 480px; margin: 60px auto; text-align: center; }

/* ----- La liste des plans ----- */

.plans { list-style: none; margin: 0; padding: 0; }

.plan {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--trait);
}

.plan-open {
    flex: 1 1 auto;
    min-width: 0;
    text-decoration: none;
    color: var(--encre);
}

.plan-name { display: block; font-weight: 600; }
.plan-meta { display: block; font-size: 13px; color: var(--encre-douce); }
.plan-lock { display: block; font-size: 13px; color: var(--orange); }
.plan-acts { display: flex; gap: 4px; flex: 0 0 auto; }

/* ----- Le partage ----- */

.modal-veil {
    position: fixed;
    inset: 0;
    background: rgba(34, 28, 58, 0.45);   /* l'encre de la charte, voilee */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 20;
}

.modal {
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow: auto;
    padding: 24px 28px;
    background: var(--feuille);
    border-radius: 8px;
}

.modal h2 { margin-top: 0; color: var(--encre); font-size: 18px; }
.modal-acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.share-add { display: flex; gap: 8px; margin: 14px 0; }
.share-add input { flex: 1 1 auto; }

.shares { list-style: none; margin: 0; padding: 0; }

.shares li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--trait);
}

.share-who { flex: 1 1 auto; min-width: 0; }
.share-role { color: var(--encre-douce); font-size: 13px; }
.pending { color: var(--or); font-size: 12px; font-style: normal; margin-left: 6px; }

.fresh-link {
    padding: 10px 12px;
    background: var(--fond);
    border-radius: 6px;
    margin: 10px 0;
}

.fresh-link code { word-break: break-all; font-size: 13px; }

/* ----- L'editeur ----- */

.editor {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.editor-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    height: 46px;
    background: var(--feuille);
    border-bottom: 1px solid var(--trait);
    flex: 0 0 auto;
}

.editor-name { font-weight: 600; }

.lock-state { font-size: 13px; }
.lock-state.mine { color: var(--vert); }
.lock-state.other { color: var(--orange); }
.lock-state.free { color: var(--encre-douce); }

.plan-surface {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    background: var(--feuille);
    cursor: grab;
    touch-action: none;
}

.plan-surface:active { cursor: grabbing; }
.plan-surface canvas { display: block; width: 100%; height: 100%; }

/* ----- Le chargement ----- */

.boot {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    color: var(--encre-douce);
}

.boot-sheet {
    width: 180px;
    height: 128px;
    background: var(--feuille);
    border: 1px solid var(--trait);
    background-image:
        linear-gradient(var(--trait) 1px, transparent 1px),
        linear-gradient(90deg, var(--trait) 1px, transparent 1px);
    background-size: 16px 16px;
}

.boot .px-cartouche { margin-top: 16px; }

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px 16px;
    background: var(--px-anis-clair);
    border-top: 2px solid var(--px-anis);
    z-index: 1000;
}

#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* ----- La barre d'outils du plan ----- */

.tool-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 12px;
    background: var(--fond);
    border-bottom: 1px solid var(--trait);
    flex: 0 0 auto;
}

.tool {
    height: 30px;
    padding: 0 12px;
    border: 1px solid var(--trait);
    border-radius: 4px;
    background: var(--feuille);
    color: var(--encre);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

.tool:hover { background: var(--fond); }

/* L'outil arme se voit : c'est lui qui recoit le prochain clic dans le plan. */
.tool.on {
    background: var(--primaire);
    border-color: var(--primaire);
    color: var(--primaire-texte);
}

/* Un outil qui trace vise un point : le curseur devient une croix. */
.plan-surface.drawing { cursor: crosshair; }
.plan-surface:focus { outline: none; }

/* ----- La ligne d'etat : coordonnees, accrochage, conseil de l'outil ----- */

.status-bar {
    flex: 0 0 auto;
    padding: 4px 12px;
    min-height: 26px;
    background: var(--feuille);
    border-top: 1px solid var(--trait);
    color: var(--encre-douce);
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ----- Le panneau lateral : composition et proprietes ----- */

.editor-body {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

.side {
    flex: 0 0 272px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--feuille);
    border-right: 1px solid var(--trait);
}

.side-tabs { display: flex; border-bottom: 1px solid var(--trait); }

.side-tab {
    flex: 1 1 0;
    height: 34px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--encre-douce);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.side-tab:hover { background: var(--fond); }
.side-tab.on { color: var(--primaire); border-bottom-color: var(--primaire); font-weight: 600; }

.side-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 4px 14px 18px; }
.side-body h3 { margin: 16px 0 6px; font-size: 13px; }
.side-body .lead { margin: 4px 0 10px; font-size: 13px; }

/* Les champs du panneau : une etiquette au-dessus, serree. */
.grid label { margin: 8px 0; }
.grid label > span { margin-bottom: 3px; font-size: 12px; }
.grid input[type=text], .grid select { height: 30px; font-size: 13px; width: 100%; }
.grid label.check { flex-direction: row; align-items: center; }
.grid label.check > span { font-size: 13px; }

.acts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.acts .btn { height: 28px; padding: 0 8px; font-size: 12.5px; }

/* Les listes du panneau : etages, toitures, facades, baies d'un mur. */
.picks { list-style: none; margin: 4px 0; padding: 0; }

.picks li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 4px;
}

.picks li.on { background: var(--choisi); }
.picks li.on .link { font-weight: 600; text-decoration: none; }
.pick-meta { color: var(--encre-douce); font-size: 12px; }

.options { display: flex; flex-direction: column; gap: 2px; }
.options label.check { margin: 2px 0; }
.options label.check > span { font-size: 13px; }

/* ----- Les reglages de l'outil, dans sa barre ----- */

.tool-sep {
    width: 1px;
    align-self: stretch;
    margin: 2px 6px;
    background: var(--trait);
}

.tool-lbl { color: var(--encre-douce); font-size: 12.5px; align-self: center; }

.tool-num {
    width: 62px;
    height: 30px;
    padding: 0 6px;
    border: 1px solid var(--trait);
    border-radius: 4px;
    font: inherit;
    font-size: 13px;
}

.tool-num.wide { width: 96px; }

/* La sortie par account.prophetix.com est un formulaire : il se tient dans la barre comme un bouton. */
form.inline { display: inline; margin: 0; }
a.who { text-decoration: none; }
a.who:hover { text-decoration: underline; }

/* ----- La fenetre du poste dans la page ----- */

.editor.desk { overflow: hidden; }
.editor.desk .editor-bar { height: 40px; }
.desk-host { flex: 1 1 auto; min-height: 0; position: relative; display: flex; }
.desk-host > .wpf-root { flex: 1 1 auto; }

.ask-veil {
    position: fixed; inset: 0; z-index: 2100;
    background: rgba(22, 18, 43, 0.28);   /* la nuit de la charte, voilee */
    display: flex; align-items: center; justify-content: center;
}
.ask {
    background: var(--feuille);
    border-radius: 8px;
    padding: 18px 20px;
    width: min(420px, calc(100vw - 32px));
    box-shadow: 0 16px 48px rgba(22, 18, 43, 0.3);
}
.ask-title { margin: 0 0 10px; font-weight: 600; }
.ask input { width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--trait); border-radius: 5px; font: inherit; }
.ask-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ----- Telephone ----- */

/* Sur ecran tactile, les champs restent a 16px (en dessous, iOS zoome la page au focus) et les
   boutons gagnent une hauteur de doigt. Le plan et le poste (touch-action: none) gardent leurs gestes. */
@media (pointer: coarse) {
    input, select, textarea,
    .lang, .tool-num, .ask input,
    .wpf-root .w-tb, .wpf-root .w-combo-edit { font-size: 16px !important; }
    .btn, .lang, select, input[type=text], input[type=email], input[type=password] { min-height: 44px; }
    .tool, .side-tab { min-height: 44px; }
}

@media (max-width: 640px) {
    .bar { height: auto; min-height: 52px; flex-wrap: wrap; padding: 6px 12px; row-gap: 4px; }
    .who { max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    .sheet { margin: 12px auto; padding: 18px 16px; border-left: 0; border-right: 0; border-radius: 0; }
    .sheet-head { flex-wrap: wrap; }
    .pad { padding: 16px; }

    .plan { flex-wrap: wrap; }
    .plan-acts { flex-wrap: wrap; }

    .modal { padding: 18px 16px; }
    .share-add, .shares li { flex-wrap: wrap; }
    .share-add input { min-width: 0; }

    .editor-bar { height: auto; min-height: 46px; flex-wrap: wrap; padding: 4px 12px; row-gap: 4px; }
    .editor.desk .editor-bar { height: auto; min-height: 40px; }
}

/* Le poste est une fenetre de bureau (900px minimum, comme MainWindow.xaml) : sous cette largeur
   elle se fait defiler au doigt plutot que d'ecraser ses panneaux. */
@media (max-width: 899px) {
    .desk-host { overflow: auto; }
    .desk-host > .wpf-root { flex: 0 0 auto; min-width: 900px; }
}
