/* =============================================================================
   Fenêtre d'application sans barre de titre (Window Controls Overlay), ordinateur.

   Tout tient à la classe `attimo-wco`, posée par js/attimo-window.js quand
   l'application installée n'a plus sa barre : ni onglet, ni téléphone, ni galerie.

   --attimo-wco-h     : hauteur des boutons de la fenêtre ;
   --attimo-wco-right : place prise à droite (Windows, Linux) ;
   --attimo-wco-left  : place prise à gauche (Mac).
   ========================================================================== */
html.attimo-wco {
    --attimo-wco-h: env(titlebar-area-height, 0px);
    --attimo-wco-left: env(titlebar-area-x, 0px);
    --attimo-wco-right: calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw));
}

/* La bande qui attrape la fenêtre : couleur de la page, rien dedans. */
.attimo-window-strip { display: none; }
html.attimo-wco .attimo-window-strip {
    display: block;
    position: fixed;
    top: 0;
    left: var(--attimo-window-strip-left, 0px);
    right: 0;
    height: var(--attimo-wco-h);
    z-index: 990;
    background: var(--attimo-window-color, #F8F9FA);
    -webkit-app-region: drag;
    app-region: drag;
}
/* Une fenêtre (modale, plein écran) est posée dessus : elle reçoit les clics. */
html.attimo-wco.attimo-wco-covered .attimo-window-strip { -webkit-app-region: no-drag; app-region: no-drag; }

/* Espace photographe, Studio : la page garde son espace habituel sous la bande. */
html.attimo-wco .main-content { padding-top: max(32px, calc(var(--attimo-wco-h) + 6px)); }
html.attimo-wco .app-container-own-menu .main-content { padding-top: var(--attimo-wco-h); }
@media (max-width: 900px) {
    /* CRM, petite fenêtre : son menu passe en haut de la page. */
    html.attimo-wco .app-container-own-menu { padding-top: var(--attimo-wco-h); }
    html.attimo-wco .app-container-own-menu .main-content { padding-top: 0; }
}
/* Mac : les boutons sont à gauche, sur le menu, qui commence sous eux. Windows : rien. */
html.attimo-wco .sidebar { padding-top: calc(24px + min(var(--attimo-wco-left), var(--attimo-wco-h))); }
html.attimo-wco .crm-side { padding-top: calc(22px + min(var(--attimo-wco-left), var(--attimo-wco-h))); }
html.attimo-wco :is(.sidebar-logo, .crm-brand) { -webkit-app-region: drag; app-region: drag; }

/* Une barre de page au bord haut : son fond attrape la fenêtre, ses commandes se cliquent. */
html.attimo-wco :is(.mobile-header, .mt-top, .ws-topbar, .cov-header) {
    -webkit-app-region: drag;
    app-region: drag;
}
/* Peu chargée : elle s'arrête avant les boutons. */
html.attimo-wco :is(.mobile-header, .cov-header) {
    padding-left: max(16px, calc(var(--attimo-wco-left) + 8px));
    padding-right: calc(var(--attimo-wco-right) + 16px);
}
/* Très chargée (Montage, séance Studio) : les boutons se posent au-dessus, sur sa couleur. */
html.attimo-wco .mt-body { grid-template-rows: calc(56px + var(--attimo-wco-h)) minmax(0, 1fr) 200px; }
html.attimo-wco .ws-container { grid-template-rows: calc(48px + var(--attimo-wco-h)) 1fr auto; }
html.attimo-wco :is(.mt-top, .ws-topbar) { padding-top: var(--attimo-wco-h); }
html.attimo-wco .ws-fs-prompt { top: calc(58px + var(--attimo-wco-h)); }

html.attimo-wco :is(.mobile-header, .mt-top, .ws-topbar, .cov-header, .sidebar-logo, .crm-brand) :is(a, button, input, select, textarea, label, summary, [role="button"], [role="radio"], [onclick], [tabindex], [contenteditable]) {
    -webkit-app-region: no-drag;
    app-region: no-drag;
}

/* Petite fenêtre : le bandeau du menu remplace la bande. */
@media (max-width: 768px) {
    html.attimo-wco body:has(> .mobile-header) .attimo-window-strip { display: none; }
    html.attimo-wco body:has(> .mobile-header) .main-content { padding-top: 72px; }
    html.attimo-wco body:has(> .mobile-header) .sidebar { padding-top: 24px; }
}

/* Page qui n'a ni menu ni barre (connexion, code…). */
html.attimo-wco.attimo-window-plain body { padding-top: var(--attimo-wco-h); box-sizing: border-box; }
