/* Pcfact — overrides charte Provence Cloud (v1.25 + thème bleu v1.28 + v1.30 thème global). */

:root {
    /* Thème vert (défaut, charte historique Provence Cloud) */
    --pc-primary: #00897B;
    --pc-primary-dark: #00695C;
    --pc-primary-light: #4DB6AC;
    --pc-primary-ring: rgba(0, 137, 123, 0.35);
    --pc-slate: #37474F;
    --pc-slate-dark: #263238;
    --pc-accent-bg: #F5F5F5;
}

/* Thème bleu (azur Provence) — opt-in via data-theme="bleu" sur <body>. */
body[data-theme="bleu"] {
    --pc-primary: #1565C0;
    --pc-primary-dark: #0D47A1;
    --pc-primary-light: #64B5F6;
    --pc-primary-ring: rgba(21, 101, 192, 0.35);
    --pc-slate: #1A2D3F;
    --pc-slate-dark: #102030;
}

body {
    font-family: "Roboto", "Liberation Sans", "DejaVu Sans", Arial, sans-serif;
    color: #263238;
}

/* ============================================================================
 * Overrides Tailwind « teal-x / slate-x » vers variables de thème.
 * On préfixe par `body` pour garantir la spécificité contre les utilitaires
 * Tailwind pré-compilés.
 * ============================================================================ */

/* Header principal */
body header.bg-slate-800 { background: var(--pc-slate-dark); }

/* Navigation principale avec sous-menus */
.pc-icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}
[x-cloak] {
    display: none !important;
}
.pc-icon-sprite symbol,
.pc-nav svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.pc-nav {
    position: relative;
    z-index: 30;
}
.pc-nav-bar {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    min-height: 2.65rem;
}
.pc-nav-home,
.pc-nav-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.15rem;
    padding: 0.45rem 0.7rem;
    border-radius: 0.375rem;
    color: #E2E8F0;
    line-height: 1.15;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.pc-nav-home:hover,
.pc-nav-trigger:hover,
.pc-nav-trigger[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.08);
    color: var(--pc-primary-light);
}
.pc-nav-group {
    position: relative;
}
.pc-nav-icon,
.pc-nav-link svg {
    width: 1.05rem;
    height: 1.05rem;
    flex: 0 0 auto;
}
.pc-nav-chevron {
    width: 0.9rem;
    height: 0.9rem;
    flex: 0 0 auto;
    opacity: 0.75;
    transition: transform 0.15s ease;
}
.pc-nav-trigger[aria-expanded="true"] .pc-nav-chevron {
    transform: rotate(180deg);
}
.pc-nav-menu {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    min-width: 14rem;
    padding: 0.35rem;
    background: #FFFFFF;
    color: #263238;
    border: 1px solid #DDE5EA;
    border-radius: 0.5rem;
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.18);
    /* z-index pour s'assurer que le menu actif reste au-dessus des cartes
       du dashboard ET des autres triggers de menu (pas de chevauchement
       visuel quand on passe d'un menu à l'autre). */
    z-index: 50;
}
.pc-nav-menu-right {
    left: auto;
    right: 0;
}
.pc-nav-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 2.25rem;
    padding: 0.5rem 0.65rem;
    border-radius: 0.375rem;
    color: #334155;
    line-height: 1.2;
}
.pc-nav-link svg {
    color: var(--pc-primary-dark);
}
.pc-nav-link:hover {
    background: #EEF7F6;
    color: var(--pc-primary-dark);
}

/* Branding teal */
body .text-teal-300 { color: var(--pc-primary-light) !important; }
body .text-teal-500 { color: var(--pc-primary) !important; }
body .text-teal-600 { color: var(--pc-primary-dark) !important; }
body .text-teal-700 { color: var(--pc-primary-dark) !important; }
body .text-teal-800 { color: var(--pc-primary-dark) !important; }

body .bg-teal-500 { background-color: var(--pc-primary) !important; }
body .bg-teal-700 { background-color: var(--pc-primary) !important; }
body .bg-teal-800 { background-color: var(--pc-primary-dark) !important; }

body .hover\:bg-teal-700:hover { background-color: var(--pc-primary) !important; }
body .hover\:bg-teal-800:hover { background-color: var(--pc-primary-dark) !important; }
body .hover\:text-teal-300:hover { color: var(--pc-primary-light) !important; }

body .focus\:ring-teal-500:focus { --tw-ring-color: var(--pc-primary-ring) !important; }
body .focus\:border-teal-500:focus { border-color: var(--pc-primary) !important; }

/* Bandeau-titre PCFACT (sous le header) */
.pc-banner {
    background: var(--pc-slate);
    color: #fff;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.pc-banner img.logo {
    display: block;
    width: auto;
    height: auto;
    max-width: 7.5rem;
    max-height: 3rem;
    object-fit: contain;
    flex: 0 0 auto;
}
.pc-banner .titles { line-height: 1.15; }
.pc-banner .brand   { font-weight: 700; font-size: 1.4rem; letter-spacing: 0.04em; }
.pc-banner .subbrand{ font-size: 0.9rem; opacity: 0.9; }
.pc-banner .version { font-size: 0.7rem; opacity: 0.65; }

/* Responsive : compacte le bandeau sur mobile (v1.35) */
@media (max-width: 767px) {
    .pc-nav-bar {
        display: block;
        padding-top: 0.45rem;
        padding-bottom: 0.5rem;
    }
    .pc-nav-home,
    .pc-nav-trigger {
        width: 100%;
        justify-content: flex-start;
        min-height: 2.45rem;
        padding: 0.6rem 0.5rem;
    }
    .pc-nav-chevron {
        margin-left: auto;
    }
    .pc-nav-group {
        margin-top: 0.15rem;
    }
    .pc-nav-menu,
    .pc-nav-menu-right {
        position: static;
        min-width: 0;
        margin: 0 0 0.35rem 1.75rem;
        padding: 0.2rem;
        background: rgba(15, 23, 42, 0.25);
        border: 1px solid rgba(148, 163, 184, 0.25);
        box-shadow: none;
        color: #E2E8F0;
    }
    .pc-nav-link {
        color: #E2E8F0;
    }
    .pc-nav-link svg {
        color: var(--pc-primary-light);
    }
    .pc-nav-link:hover {
        background: rgba(255, 255, 255, 0.08);
        color: #FFFFFF;
    }

    .pc-banner {
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
    }
    .pc-banner img.logo { max-height: 2rem; max-width: 5rem; }
    .pc-banner .brand { font-size: 1.05rem; }
    .pc-banner .subbrand { display: none; }
    .pc-banner .version { font-size: 0.65rem; }
}

/* Cartes dashboard avec bordure gauche teal */
.pc-card {
    background: #fff;
    border-left: 4px solid var(--pc-primary);
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    padding: 1rem;
}

/* ============================================================================
 * Composants Pcfact — source de vérité unique (plain CSS, plus de @apply).
 * .btn-*, .input, table.tbl : tout est défini ici, sans dépendre de la
 * compilation Tailwind d'utilitaires (le bloc <style> @apply de base.html
 * a été supprimé en v1.30).
 * ============================================================================ */
.btn-primary,
.btn-secondary,
.btn-danger {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.95rem;
    line-height: 1.2;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease;
}
.btn-primary  { background: var(--pc-primary); color: #fff; }
.btn-primary:hover { background: var(--pc-primary-dark); }
.btn-secondary { background: #ECEFF1; color: var(--pc-slate-dark); }
.btn-secondary:hover { background: #CFD8DC; }
.btn-danger   { background: #E53935; color: #fff; }
.btn-danger:hover { background: #C62828; }
.btn-primary:disabled,
.btn-secondary:disabled,
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }

.input {
    width: 100%;
    border: 1px solid #CBD5E1;
    border-radius: 0.375rem;
    padding: 0.35rem 0.5rem;
    font-size: 0.95rem;
    background: #fff;
    color: #263238;
}
.input:focus {
    outline: none;
    border-color: var(--pc-primary);
    box-shadow: 0 0 0 2px var(--pc-primary-ring);
}

/* ============================================================================
 * Tableaux .tbl : largeur fluide, responsive, lignes confortables.
 * ============================================================================ */
table.tbl {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}
table.tbl thead th {
    background: var(--pc-primary);
    color: #fff;
    text-align: left;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    padding: 0.5rem 0.75rem;
    white-space: nowrap;
}
table.tbl tbody td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid #E0E0E0;
    vertical-align: top;
}
table.tbl tbody tr:nth-child(even) td { background: #FAFAFA; }
table.tbl tbody tr:hover td { background: #F1F8F7; }

/* Cellules nowrap pour montants, dates, statuts, états */
table.tbl td.nowrap,
table.tbl th.nowrap,
table.tbl td.text-right,
table.tbl th.text-right { white-space: nowrap; }

/* Cellule extensible : permet à la 1re colonne (désignation / nom) de grossir */
table.tbl td.fluid, table.tbl th.fluid { width: 100%; }

/* Colonnes numériques en tableau de saisie multi-lignes (devis support,
 * prestations en lot, etc.) : Tailwind w-24/w-32 ne sont pas dans le
 * build statique du projet — on définit nos propres largeurs ici.
 * - `pc-col-qte`  : 90 px (assez pour 3 chiffres + spinners number)
 * - `pc-col-prix` : 120 px (10 caractères + €)
 * Appliquer sur le <th> ET aussi sur l'<input> à l'intérieur, sinon
 * l'input prend `width: 100%` et casse la largeur de la cellule. */
table.tbl th.pc-col-qte,
table.tbl td.pc-col-qte { width: 90px; min-width: 90px; }
table.tbl th.pc-col-prix,
table.tbl td.pc-col-prix { width: 120px; min-width: 120px; }
table.tbl .pc-col-qte input.input,
table.tbl .pc-col-prix input.input { min-width: 0; width: 100%; }

/* Conteneur scrollable horizontal pour mobile */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl-wrap > table.tbl { min-width: 640px; }

/* Carte de login centrée */
.pc-login-wrap {
    min-height: 100vh;
    background: var(--pc-slate);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.pc-login-card {
    background: #fff;
    border-radius: 1rem;
    padding: 2rem;
    width: 100%;
    max-width: 22rem;
    box-shadow: 0 12px 32px rgba(0,0,0,0.25);
    text-align: center;
}
.pc-login-card img.logo {
    width: auto;
    height: auto;
    max-width: 8.5rem;
    max-height: 4.5rem;
    margin: 0 auto 1rem;
    display: block;
}
.pc-login-card .pc-brand { font-weight: 700; font-size: 1.4rem; color: var(--pc-slate); }
.pc-login-card .pc-subbrand { font-size: 0.85rem; color: #607D8B; margin-bottom: 1.5rem; }
.pc-login-error {
    background: #FFEBEE;
    color: #B71C1C;
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
}
.pc-login-form { text-align: left; }
.pc-login-form label {
    display: block;
    font-size: 0.85rem;
    color: #455A64;
    margin-bottom: 0.85rem;
}
.pc-login-form label .input { margin-top: 0.25rem; }

/* ============================================================================
 * Filter bar standard : barre d'outils en haut des pages liste.
 * ============================================================================ */
.pc-filters {
    background: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    padding: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    margin-bottom: 1rem;
}
.pc-filters label { font-size: 0.8rem; color: #455A64; }
.pc-filters label > select,
.pc-filters label > input { display: block; margin-top: 0.15rem; min-width: 11rem; }
.pc-filters .btn-primary,
.pc-filters .btn-secondary { padding: 0.4rem 0.9rem; font-size: 0.85rem; }

/* Bandeau « société active » dans les pages — visuel discret */
.pc-active-soc-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--pc-primary);
    color: white;
    font-size: 0.7rem;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

/* État vide standardisé pour les tables */
.pc-empty {
    text-align: center;
    color: #90A4AE;
    padding: 2rem 1rem;
    font-size: 0.9rem;
}
.pc-empty .icon { font-size: 1.5rem; display: block; margin-bottom: 0.5rem; opacity: 0.4; }

/* Empêche le warning Tailwind CDN de surcharger la mise en page */
[data-pc-theme-boot] body { visibility: visible; }

/* Éditeur markdown (EasyMDE) — toolbar texte sans FontAwesome */
.editor-toolbar button.pc-mde-btn {
    width: auto;
    min-width: 1.9rem;
    padding: 0 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #334155;
}
.editor-toolbar button.pc-mde-btn:hover {
    background: #F1F5F9;
}
.EasyMDEContainer .CodeMirror {
    border-radius: 0.375rem;
    border-color: #CBD5E1;
    font-size: 0.875rem;
}
.pc-md-rendu img {
    max-width: 100%;
    border: 1px solid #E2E8F0;
    border-radius: 0.375rem;
    margin: 0.25rem 0;
}
.pc-md-rendu pre {
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 0.375rem;
    padding: 0.5rem;
    overflow-x: auto;
    font-size: 0.8rem;
}
.pc-md-rendu ul { list-style: disc; padding-left: 1.25rem; }
.pc-md-rendu ol { list-style: decimal; padding-left: 1.25rem; }
.pc-md-rendu a { color: var(--pc-primary-dark); text-decoration: underline; }
.pc-md-rendu h1, .pc-md-rendu h2, .pc-md-rendu h3, .pc-md-rendu h4 {
    font-weight: 600;
    margin: 0.5rem 0 0.25rem;
}
.pc-md-rendu blockquote {
    border-left: 3px solid #CBD5E1;
    padding-left: 0.6rem;
    color: #64748B;
}
.pc-md-rendu table { border-collapse: collapse; }
.pc-md-rendu th, .pc-md-rendu td {
    border: 1px solid #E2E8F0;
    padding: 0.25rem 0.5rem;
}
