/* ============================================
   SOCIAL COLLAB - CSS Mobile First
   ============================================ */

/* -- Reset & Base -- */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

:root {
    /* Primary : bleu nuit (slate-800) */
    --primary: #1E293B;
    --primary-light: #F1F5F9;
    --primary-dark: #0F172A;

    /* Accent : rouge REDCAT (red-600) */
    --accent: #DC2626;
    --accent-light: #FEE2E2;
    --accent-dark: #991B1B;

    --recv-bg: #FEF3C7; --recv-text: #92400E;
    --prog-bg: #FFEDD5; --prog-text: #9A3412;
    --val-bg: #E6F1FB;  --val-text: #0C447C;
    --ok-bg: #E1F5EE;   --ok-text: #085041;
    --pub-bg: #EEEDFE;  --pub-text: #3C3489;

    --ig-bg: #FBEAF0; --ig-text: #993556;
    --fb-bg: #E6F1FB; --fb-text: #0C447C;
    --li-bg: #E6F1FB; --li-text: #185FA5;
    --tk-bg: #F1EFE8; --tk-text: #444441;

    --bg: #FFFFFF;
    --bg2: #F5F4F0;
    --bg3: #EEEDEA;
    --text: #1A1A1A;
    --text2: #6B6B6B;
    --text3: #9B9B9B;
    --border: #E5E4E0;
    --border2: #D1D0CC;

    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 2px 8px rgba(0,0,0,0.08);

    --nav-height: 56px;
    --header-height: 54px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text);
    background: var(--bg2);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: calc(var(--nav-height) + 16px);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
img, video { max-width: 100%; height: auto; display: block; }
button, input, textarea, select { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }

/* -- Utilities -- */
.sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); }
.container { width: 100%; max-width: 800px; margin: 0 auto; padding: 0 12px; }
.container-wide { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 12px; }

/* -- Header fixe -- */
.header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: var(--header-height);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px;
}
.header-title { font-size: 16px; font-weight: 600; color: var(--text); }
.header-title span { color: var(--primary); }
.header-back { width: 36px; height: 36px; border-radius: var(--radius); border: none; background: transparent; display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--text); }
.header-actions { display: flex; gap: 8px; align-items: center; }

body { padding-top: var(--header-height); }

/* Sidebar desktop : cachee par defaut en mobile, reactivee en >= 769px */
.desktop-sidebar { display: none; }

/* -- Navigation bottom -- */
.nav-bottom {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    height: var(--nav-height);
    background: var(--bg);
    border-top: 1px solid var(--border);
    display: flex;
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    text-decoration: none; color: var(--text3); font-size: 10px; font-weight: 500;
    transition: color 0.15s;
    border: none; background: transparent;
    position: relative;
}
.nav-item.active { color: var(--primary); }
.nav-item svg { width: 22px; height: 22px; }
.nav-badge {
    position: absolute; top: 4px; right: calc(50% - 18px);
    width: 8px; height: 8px; border-radius: 50%;
    background: #E24B4A; border: 2px solid var(--bg);
}

/* -- Badges & Pills -- */
.badge {
    display: inline-flex; align-items: center;
    font-size: 11px; font-weight: 600; padding: 3px 10px;
    border-radius: var(--radius-full); white-space: nowrap;
}
.badge-recv { background: var(--recv-bg); color: var(--recv-text); }
.badge-prog { background: var(--prog-bg); color: var(--prog-text); }
.badge-val  { background: var(--val-bg);  color: var(--val-text); }
.badge-ok   { background: var(--ok-bg);   color: var(--ok-text); }
.badge-pub  { background: var(--pub-bg);  color: var(--pub-text); }

.plat {
    display: inline-flex; align-items: center;
    font-size: 10px; font-weight: 600; padding: 2px 7px;
    border-radius: 4px;
}
/* TikTok : pas de SVG fourni, on garde le badge texte */
.plat-tk, .plat-ti { background: var(--tk-bg); color: var(--tk-text); }

/* FB / IG / LI : pastille logo SVG, le texte du label est masque.
   On supporte les 2 conventions de classes :
   - plat-fa/in/li (substr(platform,0,2) cote PHP)
   - plat-fb/ig/li (ancien CSS) */
.plat-fa, .plat-fb,
.plat-in, .plat-ig,
.plat-li {
    width: 20px; height: 20px;
    padding: 0;
    background-color: transparent;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    font-size: 0;          /* masque le label texte */
    color: transparent;
    border-radius: 4px;
    flex-shrink: 0;
    vertical-align: middle;
}
.plat-fa, .plat-fb { background-image: url('../img/facebook.svg'); }
.plat-in, .plat-ig { background-image: url('../img/instagram.svg'); }
.plat-li           { background-image: url('../img/linkedin.svg'); }

/* Pastille thematique : affichee a cote du logo reseau */
.cat-pill {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: #F1F5F9;
    color: #475569;
    white-space: nowrap;
}

/* Pastille reference (campagne / code interne) : cliquable, plus visible
   pour faire ressortir les posts d'une meme campagne. */
.ref-pill {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #FCD34D;
    text-decoration: none;
    white-space: nowrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.2px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ref-pill:before { content: "#"; opacity: 0.6; margin-right: 1px; }
.ref-pill:hover { background: #FDE68A; }

/* Pastille type media : Image / Carrousel / Video / Texte
   Code couleur leger pour scanner visuellement la nature du post. */
.media-pill {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.media-pill-image    { background: #E0F2FE; color: #075985; }
.media-pill-carousel { background: #EDE9FE; color: #5B21B6; }
.media-pill-video    { background: #FEE2E2; color: #991B1B; }
.media-pill-text     { background: #F1F5F9; color: #475569; }
.media-pill-pdf      { background: #FEF3C7; color: #92400E; }
.media-pill:before {
    content: "";
    display: inline-block;
    width: 0; height: 0;
    margin-right: 4px;
}
.media-pill-image:before    { width: 6px; height: 6px; border-radius: 50%; background: #0EA5E9; }
.media-pill-carousel:before { width: 6px; height: 6px; border-radius: 2px; background: #7C3AED; box-shadow: 2px -2px 0 #7C3AED; }
.media-pill-video:before    { width: 0; height: 0; border-left: 6px solid #DC2626; border-top: 4px solid transparent; border-bottom: 4px solid transparent; margin-right:5px; }
.media-pill-text:before     { width: 4px; height: 1.5px; box-shadow: 0 3px 0 currentColor, 0 6px 0 currentColor; background: currentColor; margin-right:5px; opacity:0.7; }

/* Wrapper expand : englobe la card existante + la zone deployable */
.post-card-wrap {
    position: relative;
    border-bottom: 1px solid var(--border);
}
.post-card-wrap:last-child { border-bottom: none; }
.post-card-wrap .post-card { border-bottom: none; }

/* Chevron toggle : discret par defaut, devient interactif au hover */
.post-card-toggle {
    position: absolute;
    right: 10px;
    bottom: 6px;
    width: 26px; height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50%;
    color: #94A3B8;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}
.post-card-toggle:hover {
    background: #F1F5F9;
    border-color: #CBD5E1;
    color: #475569;
}
.post-card-toggle svg { transition: transform 0.2s ease; }
.post-card-wrap.is-expanded .post-card-toggle {
    color: #1E293B;
    background: #E2E8F0;
}
.post-card-wrap.is-expanded .post-card-toggle svg { transform: rotate(180deg); }

/* Zone deployable : contenu complet + tous les visuels */
.post-card-expand {
    padding: 4px 14px 14px 14px;
    background: #F8FAFC;
    border-top: 1px dashed #E2E8F0;
    animation: postCardExpandIn 0.18s ease-out;
}
@keyframes postCardExpandIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.post-card-expand-section {
    margin-top: 12px;
}
.post-card-expand-label {
    font-size: 10px;
    font-weight: 700;
    color: #64748B;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 6px;
}
.post-card-expand-caption {
    font-size: 14px;
    color: #0F172A;
    line-height: 1.55;
    background: #fff;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #E2E8F0;
    white-space: pre-wrap;
    word-break: break-word;
}
.post-card-expand-hashtags {
    font-size: 13px;
    color: #1E40AF;
    background: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #E2E8F0;
    word-break: break-word;
}
.post-card-expand-text {
    font-size: 13px;
    color: #0F172A;
    line-height: 1.5;
    background: #fff;
    padding: 10px 12px;
    border-radius: 8px;
    border-left: 3px solid #94A3B8;
}
.post-card-expand-script .post-card-expand-text { border-left-color: #F59E0B; background: #FFFBEB; }
.post-card-expand-notes  .post-card-expand-text { border-left-color: #94A3B8; }
.post-card-expand-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 6px;
}
.post-card-expand-thumb {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #E2E8F0;
    display: block;
    text-decoration: none;
}
.post-card-expand-thumb img,
.post-card-expand-thumb video {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.post-card-expand-thumb-badge {
    position: absolute;
    bottom: 4px; left: 4px;
    padding: 1px 5px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    border-radius: 4px;
    letter-spacing: 0.3px;
}
.post-card-expand-thumb:hover { border-color: #94A3B8; }

/* En-tete de groupe par titre de sujet : visible uniquement dans la vue
   filtree par ref. Permet de visualiser les sous-groupes FB/IG/LI d'un
   meme sujet. */
.post-group-header {
    background: #F1F5F9;
    border-top: 1px solid #E2E8F0;
    border-bottom: 1px solid #E2E8F0;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.post-group-header-title {
    font-size: 13px;
    font-weight: 700;
    color: #0F172A;
    flex: 1;
    min-width: 0;
}
.post-group-header:before {
    content: "";
    display: inline-block;
    width: 4px;
    height: 16px;
    background: #DC2626;
    border-radius: 2px;
}

/* -- Buttons -- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 20px; border-radius: var(--radius);
    font-size: 14px; font-weight: 600; border: none;
    transition: transform 0.1s, opacity 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: #0F6E56; color: #fff; }
.btn-danger  { background: #FCEBEB; color: #A32D2D; }
.btn-outline { background: transparent; border: 1px solid var(--border2); color: var(--text); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius); }

/* -- Cards -- */
.card {
    background: var(--bg); border-radius: var(--radius-lg);
    border: 1px solid var(--border); overflow: hidden;
}
.card + .card { margin-top: 10px; }

/* -- Form elements -- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.form-input {
    width: 100%; padding: 10px 14px;
    border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--bg); color: var(--text);
    font-size: 14px; transition: border-color 0.15s;
}
.form-input:focus { outline: none; border-color: var(--primary); }
.form-input::placeholder { color: var(--text3); }
textarea.form-input { resize: vertical; min-height: 80px; }

/* -- Chip selector -- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    font-size: 12px; padding: 6px 14px; border-radius: var(--radius);
    border: 1px solid var(--border); background: transparent;
    color: var(--text2); font-weight: 500; transition: all 0.15s;
}
.chip.active { border-color: transparent; }
.chip-ig.active, .chip-in.active { background: var(--ig-bg); color: var(--ig-text); }
.chip-fb.active, .chip-fa.active { background: var(--fb-bg); color: var(--fb-text); }
.chip-li.active                 { background: var(--li-bg); color: var(--li-text); }
.chip-tk.active, .chip-ti.active { background: var(--tk-bg); color: var(--tk-text); }
.chip-obj.active                { background: var(--recv-bg); color: var(--recv-text); }

/* Chip post_form : logo SVG du reseau a la place du texte */
.chip-logo {
    width: 18px !important;
    height: 18px !important;
    max-width: 18px;
    max-height: 18px;
    display: block;
    flex: none;
}
.chip:has(.chip-logo) {
    padding: 4px 8px;
    line-height: 1;
}
/* Force la taille meme si le navigateur ne supporte pas :has() */
.chip > img { width: 18px; height: 18px; }

/* ============================================
   Tuiles plateforme post_form : logo complet de la marque
   - Tuile rectangulaire blanche par defaut
   - Logo plein dedans (instagram-full.svg, facebook-full.svg, linkedin-full.svg)
   - Selection : ring colore (couleur marque) + check overlay + fond teinte
   ============================================ */
.plat-tile {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    width: 140px;
    height: 70px;
    background: #fff;
    border: 2px solid #E2E8F0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    flex: 0 0 auto;
    overflow: hidden;
}
.plat-tile:hover {
    border-color: #94A3B8;
    transform: translateY(-1px);
}
/* Boutons 140x70 : le logo occupe 90% de la tuile, centre.
   object-fit: contain pour ne pas deformer / rogner. */
.plat-tile-logo {
    width: 90%;
    height: 90%;
    display: block;
    object-fit: contain;
    pointer-events: none;
}
.plat-tile-fallback {
    font-size: 14px;
    font-weight: 700;
    color: #0F172A;
}
.plat-tile-check {
    position: absolute;
    top: -6px; right: -6px;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: #10B981;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.plat-tile.active {
    border-width: 3px;
    background: #F8FAFC;
    box-shadow: 0 4px 14px rgba(15,23,42,0.10);
}
.plat-tile.active .plat-tile-check { display: flex; }
/* Couleur de ring specifique a chaque marque */
.plat-tile.chip-in.active { border-color: #E1306C; }
.plat-tile.chip-fa.active { border-color: #1877F2; }
.plat-tile.chip-li.active { border-color: #0A66C2; }
.plat-tile.chip-ti.active { border-color: #000000; }

/* Select thematique modernise : custom arrow, fond clair, focus marque */
.theme-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: #fff;
    background-image: linear-gradient(45deg, transparent 50%, #475569 50%),
                      linear-gradient(135deg, #475569 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%,
                         calc(100% - 13px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 34px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.theme-select:hover { border-color: #94A3B8; }
.theme-select:focus {
    border-color: var(--primary, #1E293B);
    box-shadow: 0 0 0 3px rgba(30, 41, 59, 0.12);
    outline: none;
}
.theme-select option { padding: 8px; font-size: 14px; }

/* ============================================
   Barre de filtres fiche client (org_detail.php)
   ============================================ */
.org-filterbar {
    margin: 0 12px 12px;
    padding: 10px 12px;
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.org-filterbar-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
}
.org-filter {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: #fff;
    border: 1.5px solid #E2E8F0;
    border-radius: 10px;
    padding: 6px 10px 4px;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    min-width: 0;       /* permet au select de retrecir et ne pas deborder */
    overflow: hidden;
}
.org-filter:hover { border-color: #94A3B8; }
.org-filter label {
    font-size: 10px;
    font-weight: 700;
    color: #64748B;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
    pointer-events: none;
}
/* Select natif (avec sa fleche native) pour garantir un rendu
   correct de l'option selectionnee sur tous les navigateurs.
   Pas d'appearance:none ici -> le texte de l'option choisie s'affiche
   toujours, sans masquage. */
.org-filter select {
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    color: #0F172A;
    padding: 2px 4px 4px 0;
    margin: 0;
    width: 100%;
    cursor: pointer;
    outline: none;
}
/* Etat actif : filtre selectionne -> fond + bordure couleur primaire */
.org-filter.is-active {
    background: #EFF6FF;
    border-color: #1E40AF;
    box-shadow: 0 0 0 1px rgba(30, 64, 175, 0.08);
}
.org-filter.is-active label { color: #1E40AF; }
.org-filter.is-active select { color: #1E40AF; }

/* Ligne "X resultats · 2 filtres actifs"  + bouton reset */
.org-filterbar-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: 8px;
    border-top: 1px dashed #CBD5E1;
}
.org-filterbar-count {
    font-size: 12px;
    color: #475569;
}
.org-filterbar-count strong {
    color: #0F172A;
    font-weight: 700;
    font-size: 13px;
}
.org-filterbar-dot { margin: 0 6px; color: #CBD5E1; }
.org-filterbar-active-label {
    color: #1E40AF;
    font-weight: 600;
}
.org-filterbar-reset {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #DC2626;
    background: #FEF2F2;
    border: 1px solid #FECACA;
    padding: 5px 12px;
    border-radius: 999px;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}
.org-filterbar-reset:hover {
    background: #FEE2E2;
    border-color: #FCA5A5;
}
.chip .chip-label-fallback { font-size: 12px; font-weight: 600; }
/* Halo visible quand un reseau est selectionne (au cas ou les couleurs CSS
   var seraient absentes ou trop discretes) */
.chip.active .chip-logo {
    filter: drop-shadow(0 0 1px rgba(0,0,0,0.25));
}
.chip { box-shadow: none; }
.chip.active { box-shadow: inset 0 0 0 2px currentColor; }

/* -- Drop zone upload -- */
.drop-zone {
    border: 2px dashed var(--primary); border-radius: var(--radius-lg);
    padding: 28px 16px; text-align: center; cursor: pointer;
    background: rgba(30,41,59,0.04); transition: background 0.15s;
}
.drop-zone:hover, .drop-zone.dragover { background: rgba(30,41,59,0.08); }
.drop-zone-text { font-size: 14px; color: var(--primary); font-weight: 600; }
.drop-zone-sub { font-size: 12px; color: var(--text3); margin-top: 4px; }

/* -- Upload previews -- */
.upload-previews { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.upload-preview {
    position: relative; width: 72px; height: 72px;
    border-radius: var(--radius); overflow: hidden;
    border: 1px solid var(--border);
}
.upload-preview img, .upload-preview video { width: 100%; height: 100%; object-fit: cover; }
.upload-preview-remove {
    position: absolute; top: 2px; right: 2px;
    width: 20px; height: 20px; border-radius: 50%;
    background: rgba(0,0,0,0.6); color: #fff;
    border: none; font-size: 12px; display: flex; align-items: center; justify-content: center;
}
.upload-preview-video::after {
    content: ''; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    width: 0; height: 0;
    border-style: solid; border-width: 8px 0 8px 14px;
    border-color: transparent transparent transparent #fff;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

/* -- Post card -- */
.post-card {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}
.post-card:last-child { border-bottom: none; }
.post-card:active { background: var(--bg2); }
.post-thumb {
    width: 52px; height: 52px; border-radius: var(--radius);
    flex-shrink: 0; overflow: hidden; background: var(--bg2);
    display: flex; align-items: center; justify-content: center;
}
.post-thumb img, .post-thumb video { width: 100%; height: 100%; object-fit: cover; }
.post-thumb-placeholder { font-size: 10px; color: var(--text3); font-weight: 600; }
.post-body { flex: 1; min-width: 0; }
.post-title { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.post-sub {
    font-size: 12px;
    color: var(--text2);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;     /* evite que les pastilles debordent quand la ref est longue */
    row-gap: 4px;
}
.post-status { flex-shrink: 0; }

/* -- Carousel viewer -- */
.carousel {
    /* UX 2026-05-28 : on retire l'aspect-ratio fixe en 1:1 qui cropait les
       images verticales/rectangles. Le ratio est maintenant lu dynamiquement
       sur la 1ere image par le JS et applique au carousel (cf post_detail.php).
       Default = ratio carre + max-height pour fallback si JS desactive. */
    position: relative; width: 100%;
    aspect-ratio: 1;
    max-height: 720px;
    border-radius: var(--radius-lg); overflow: hidden;
    background: #0F172A; touch-action: pan-y;
}
.carousel-track {
    display: flex; width: 100%; height: 100%;
    transition: transform 0.3s ease;
}
.carousel-slide {
    flex: 0 0 100%; width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
}
.carousel-slide img, .carousel-slide video {
    /* contain = on voit toute l'image, fond sombre pour les ratios qui ne
       matchent pas exactement le cadre. */
    width: 100%; height: 100%;
    object-fit: contain;
}
.carousel-dots {
    position: absolute; bottom: 10px; left: 50%;
    transform: translateX(-50%);
    display: flex; gap: 6px;
}
.carousel-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: rgba(255,255,255,0.5); border: none; padding: 0;
    transition: background 0.2s;
}
.carousel-dot.active { background: #fff; }

/* Barres de progression style Stories Instagram, SOUS le carousel.
   UX 2026-05-28 : les anciens dots gris clair ne se voyaient pas sur fond
   clair. Les barres sont plus contrastees, la barre active s'agrandit et
   passe en rouge accent pour une lecture instantanee. */
.carousel-dots-below {
    display: flex; justify-content: center; gap: 6px;
    padding: 14px 16px 6px;
    align-items: center;
}
.carousel-dots-below .carousel-dot {
    width: 18px; height: 4px; border-radius: 4px;
    background: #CBD5E1; border: none; padding: 0;
    cursor: pointer;
    transition: width 0.25s ease, background 0.2s ease;
}
.carousel-dots-below .carousel-dot.active {
    background: var(--accent, #DC2626);
    width: 28px;
}
.carousel-dots-below .carousel-dot:hover { background: #94A3B8; }
.carousel-dots-below .carousel-dot.active:hover { background: var(--accent, #DC2626); }

/* Curseur "grab" desktop pour signaler que le carousel se drag a la souris */
.carousel { cursor: grab; }
.carousel.is-dragging { cursor: grabbing; }
.carousel.is-dragging .carousel-track { transition: none !important; }

/* Fleches de navigation precedent/suivant (UX 2026-05-28) */
.carousel-arrow {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(0,0,0,0.45); color: #fff; border: none;
    font-size: 24px; line-height: 1; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 5;
    transition: background 0.15s, transform 0.15s;
    padding: 0;
}
.carousel-arrow:hover { background: rgba(0,0,0,0.7); }
.carousel-arrow:active { transform: translateY(-50%) scale(0.95); }
.carousel-arrow-prev { left: 8px; }
.carousel-arrow-next { right: 8px; }
.carousel-arrow:disabled { opacity: 0.35; cursor: not-allowed; }
.carousel-counter {
    position: absolute; top: 10px; right: 10px;
    background: rgba(0,0,0,0.5); color: #fff;
    font-size: 11px; font-weight: 600;
    padding: 3px 8px; border-radius: var(--radius-full);
}
.carousel-video-play {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    width: 56px; height: 56px; border-radius: 50%;
    background: rgba(0,0,0,0.5); border: none;
    display: flex; align-items: center; justify-content: center;
}
.carousel-video-play::after {
    content: ''; width: 0; height: 0;
    border-style: solid; border-width: 10px 0 10px 18px;
    border-color: transparent transparent transparent #fff;
    margin-left: 3px;
}

/* -- Chat / Comments -- */
.chat-list { padding: 12px 14px; }
.chat-msg { margin-bottom: 10px; max-width: 85%; }
.chat-msg-agency { }
.chat-msg-client { margin-left: auto; }
.chat-bubble {
    padding: 8px 12px; border-radius: 12px;
    font-size: 13px; line-height: 1.5;
}
.chat-msg-agency .chat-bubble { background: var(--primary-light); color: var(--primary-dark); border-bottom-left-radius: 3px; }
.chat-msg-client .chat-bubble { background: var(--val-bg); color: var(--val-text); border-bottom-right-radius: 3px; }
.chat-author { font-size: 11px; font-weight: 600; margin-bottom: 2px; }
.chat-time { font-size: 10px; opacity: 0.6; margin-top: 2px; }
.chat-input-bar {
    display: flex; gap: 8px; padding: 10px 14px;
    border-top: 1px solid var(--border); background: var(--bg);
}
.chat-input {
    flex: 1; padding: 8px 12px; border-radius: 20px;
    border: 1px solid var(--border); background: var(--bg2);
    font-size: 13px; color: var(--text); outline: none;
}
.chat-input:focus { border-color: var(--primary); background: var(--bg); }
.chat-send {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--primary); color: #fff; border: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
}

/* -- Stat cards -- */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 12px; }
.stat-card { padding: 10px; border-radius: var(--radius); text-align: center; }
.stat-num { font-size: 22px; font-weight: 700; }
.stat-label { font-size: 10px; font-weight: 600; }
.stat-recv  { background: var(--recv-bg); }
.stat-recv .stat-num { color: var(--recv-text); }
.stat-recv .stat-label { color: var(--recv-text); }
.stat-prog  { background: var(--prog-bg); }
.stat-prog .stat-num { color: var(--prog-text); }
.stat-prog .stat-label { color: var(--prog-text); }
.stat-val   { background: var(--val-bg); }
.stat-val .stat-num { color: var(--val-text); }
.stat-val .stat-label { color: var(--val-text); }
.stat-pub   { background: var(--pub-bg); }
.stat-pub .stat-num { color: var(--pub-text); }
.stat-pub .stat-label { color: var(--pub-text); }

/* -- Alert bar -- */
.alert { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius); margin: 12px; }
.alert-danger { background: #FCEBEB; }
.alert-dot { width: 8px; height: 8px; border-radius: 50%; background: #E24B4A; flex-shrink: 0; }
.alert-text { flex: 1; font-size: 12px; color: #791F1F; }
.alert-btn { font-size: 11px; padding: 4px 12px; border-radius: 6px; background: #E24B4A; color: #fff; border: none; font-weight: 600; }
.alert-success { background: var(--ok-bg); }
.alert-success .alert-text { color: var(--ok-text); }

/* -- Client card (dashboard) -- */
.client-header { display: flex; align-items: center; gap: 10px; padding: 14px; }
.client-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.client-info { flex: 1; min-width: 0; }
.client-name { font-size: 14px; font-weight: 600; color: var(--text); }
.client-count { font-size: 11px; color: var(--text2); }
.client-badges { display: flex; gap: 4px; flex-wrap: wrap; }

/* -- Calendar -- */
.cal-week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; padding: 0 8px; }
.cal-day {
    text-align: center; padding: 8px 0; border-radius: var(--radius);
    cursor: pointer; transition: background 0.15s;
}
.cal-day:active { background: var(--bg3); }
.cal-day.active { background: var(--primary-light); }
.cal-day-label { font-size: 10px; color: var(--text3); margin-bottom: 2px; }
.cal-day-num { font-size: 15px; font-weight: 600; color: var(--text); }
.cal-day.today .cal-day-num {
    background: var(--primary); color: #fff;
    width: 28px; height: 28px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
}
.cal-day-dots { display: flex; justify-content: center; gap: 3px; margin-top: 4px; min-height: 6px; }
.cal-day-dot { width: 5px; height: 5px; border-radius: 50%; }

/* -- Section labels -- */
.section-label { font-size: 12px; font-weight: 600; color: var(--text3); padding: 10px 14px 6px; text-transform: uppercase; letter-spacing: 0.5px; }

/* -- Tab bar -- */
.tabs { display: flex; gap: 4px; padding: 8px 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
    font-size: 12px; padding: 6px 14px; border-radius: var(--radius);
    border: none; background: transparent; color: var(--text2);
    font-weight: 500; white-space: nowrap;
}
.tab.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }

/* -- View toggle (semaine/mois/liste) -- */
.view-toggle { display: flex; gap: 4px; padding: 8px 16px; }
.view-toggle .tab { flex: 1; text-align: center; }

/* -- Flash messages -- */
.flash { padding: 12px 16px; margin: 12px; border-radius: var(--radius); font-size: 13px; font-weight: 500; }
.flash-success { background: var(--ok-bg); color: var(--ok-text); }
.flash-error { background: #FCEBEB; color: #A32D2D; }

/* -- Empty state -- */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-state-icon { font-size: 40px; margin-bottom: 10px; opacity: 0.3; }
.empty-state-text { font-size: 14px; color: var(--text3); }

/* -- Upcoming list -- */
.upcoming-row { display: flex; align-items: center; gap: 10px; padding: 8px 14px; }
.upcoming-dot { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }
.upcoming-text { flex: 1; font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upcoming-date { font-size: 11px; color: var(--text3); flex-shrink: 0; }

/* ============================================
   LOGIN PAGE — Social Collab by REDCAT STUDIO
   ============================================ */
.login-page {
    min-height: 100vh; min-height: 100dvh;
    display: flex; flex-direction: column;
    background:
        radial-gradient(120% 80% at 50% -10%, rgba(220,38,38,0.07) 0%, rgba(220,38,38,0) 60%),
        var(--bg2);
    padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
}
.login-shell {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 24px;
    padding: 24px 0;
}
.login-card {
    width: 100%; max-width: 420px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 32px 24px;
    box-shadow: 0 1px 2px rgba(16,16,16,0.04), 0 12px 40px -12px rgba(16,16,16,0.12);
}
.login-brand {
    display: flex; flex-direction: column; align-items: center;
    text-align: center;
    margin-bottom: 28px;
}
.login-mark {
    width: 52px; height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, #0F172A 100%);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 20px; letter-spacing: -0.5px;
    margin-bottom: 14px;
    box-shadow: 0 6px 18px -6px rgba(30,41,59,0.45);
    position: relative;
}
/* petite pastille rouge discrète en haut-à-droite du monogramme */
.login-mark::after {
    content: '';
    position: absolute;
    top: 4px; right: 4px;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 2px #fff;
}
.login-mark svg { width: 26px; height: 26px; }
.login-product {
    font-size: 22px; font-weight: 700;
    color: var(--text);
    letter-spacing: -0.4px;
    line-height: 1.15;
}
.login-signature {
    font-size: 10.5px; font-weight: 600;
    color: var(--text3);
    letter-spacing: 1.4px;
    text-transform: uppercase;
    margin-top: 6px;
}
.login-signature b { color: var(--accent); font-weight: 700; letter-spacing: 1.4px; }
.login-tagline {
    font-size: 14px; color: var(--text2);
    text-align: center;
    margin-bottom: 24px;
    line-height: 1.5;
}
.login-flash {
    margin-bottom: 16px; padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px; line-height: 1.45;
    display: flex; align-items: flex-start; gap: 10px;
}
.login-flash svg { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }
.login-flash-success { background: var(--ok-bg); color: var(--ok-text); }
.login-flash-error   { background: #FCEBEB; color: #A32D2D; }

.login-field { position: relative; margin-bottom: 14px; }
.login-label {
    display: block;
    font-size: 12.5px; font-weight: 600;
    color: var(--text2);
    margin-bottom: 6px;
}
.login-input-wrap { position: relative; }
.login-input-wrap svg.login-input-icon {
    position: absolute; left: 14px; top: 50%;
    transform: translateY(-50%);
    width: 18px; height: 18px;
    color: var(--text3);
    pointer-events: none;
}
.login-input {
    width: 100%;
    padding: 14px 14px 14px 42px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    -webkit-appearance: none; appearance: none;
}
.login-input::placeholder { color: var(--text3); }
.login-input:hover { border-color: var(--border2); }
.login-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,41,59,0.18);
}
.login-input:focus + .login-input-icon,
.login-input-wrap:focus-within svg.login-input-icon { color: var(--primary); }

.login-btn {
    width: 100%;
    padding: 14px 18px;
    border-radius: 12px;
    border: none;
    background: var(--primary);
    color: #fff;
    font-size: 15px; font-weight: 600;
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    box-shadow: 0 6px 16px -8px rgba(30,41,59,0.55);
    margin-top: 4px;
}
.login-btn:hover { background: var(--primary-dark); }
.login-btn:active { transform: scale(0.985); }
.login-btn:focus-visible { outline: 3px solid rgba(30,41,59,0.35); outline-offset: 2px; }
.login-btn[disabled] { opacity: 0.75; cursor: progress; }
.login-btn svg.login-btn-arrow { width: 16px; height: 16px; transition: transform 0.15s; }
.login-btn:hover svg.login-btn-arrow { transform: translateX(2px); }

.login-spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: login-spin 0.7s linear infinite;
    display: none;
}
.login-btn.is-loading .login-spinner { display: inline-block; }
.login-btn.is-loading svg.login-btn-arrow { display: none; }
@keyframes login-spin { to { transform: rotate(360deg); } }

.login-hint {
    margin-top: 18px;
    padding: 12px 14px;
    background: var(--bg2);
    border-radius: 10px;
    display: flex; gap: 10px; align-items: flex-start;
    font-size: 12.5px; color: var(--text2);
    line-height: 1.5;
}
.login-hint svg { flex-shrink: 0; width: 16px; height: 16px; color: var(--primary); margin-top: 1px; }

.login-footer {
    text-align: center;
    font-size: 11.5px; color: var(--text3);
    padding: 8px 0;
    line-height: 1.6;
}
.login-footer a { color: var(--text2); text-decoration: none; }
.login-footer a:hover { color: var(--primary); }
.login-footer-dot { opacity: 0.5; margin: 0 6px; }

/* Desktop refinements */
@media (min-width: 769px) {
    .login-card {
        padding: 40px 40px 32px;
        border-radius: 22px;
    }
    .login-product { font-size: 26px; }
    .login-mark { width: 58px; height: 58px; border-radius: 16px; }
}

/* Motion + dark mode respectfully */
@media (prefers-reduced-motion: reduce) {
    .login-btn, .login-input, .login-spinner, .login-btn svg.login-btn-arrow {
        transition: none !important; animation: none !important;
    }
}
@media (prefers-color-scheme: dark) {
    .login-page {
        background:
            radial-gradient(120% 80% at 50% -10%, rgba(220,38,38,0.12) 0%, rgba(220,38,38,0) 60%),
            #0B1220;
    }
    .login-card { background: #18181A; border-color: #262628; box-shadow: 0 1px 2px rgba(0,0,0,0.5), 0 16px 50px -16px rgba(0,0,0,0.6); }
    .login-product { color: #F2F2F2; }
    .login-tagline { color: #A8A8AC; }
    .login-label { color: #A8A8AC; }
    .login-input { background: #1E1E21; border-color: #2C2C30; color: #F2F2F2; }
    .login-input::placeholder { color: #6B6B70; }
    .login-hint { background: #1E1E21; color: #A8A8AC; }
    .login-footer, .login-signature { color: #6B6B70; }
}

/* ============================================
   Desktop (> 768px)
   ============================================ */
@media (min-width: 769px) {
    :root {
        --nav-height: 0px;
        --header-height: 60px;
    }

    body { padding-bottom: 0; }
    .nav-bottom { display: none; }

    .desktop-sidebar {
        display: flex; flex-direction: column;
        position: fixed; top: var(--header-height); left: 0; bottom: 0;
        width: 220px; background: var(--bg); border-right: 1px solid var(--border);
        padding: 16px 0;
        z-index: 50;
        overflow-y: auto;
    }
    .desktop-sidebar .nav-item {
        flex-direction: row; justify-content: flex-start; gap: 12px;
        padding: 10px 20px; font-size: 14px; font-weight: 500;
        color: var(--text1);
        transition: background 0.12s ease, color 0.12s ease;
    }
    .desktop-sidebar .nav-item:hover { background: var(--bg2); }
    .desktop-sidebar .nav-item.active {
        background: var(--bg2); color: var(--text1); font-weight: 700;
        border-left: 3px solid var(--accent);
        padding-left: 17px;
    }
    /* "Proposer" en CTA primary sur la sidebar desktop : bouton rouge plein */
    .desktop-sidebar .nav-item-primary {
        background: var(--accent); color: #fff !important;
        margin: 8px 16px;
        border-radius: 10px;
        font-weight: 700;
    }
    .desktop-sidebar .nav-item-primary:hover {
        background: var(--accent); filter: brightness(0.92);
    }
    .desktop-sidebar .nav-item-primary svg { color: #fff; }

    .main-with-sidebar { margin-left: 220px; }

    /* Liens secondaires du bas de home (Profil / Reseaux / Changer compte /
       Deconnexion) sont rendus dans la sidebar en desktop. On les cache
       sur la home elle-meme pour eviter le doublon. */
    .home-bottom-links { display: none !important; }

    .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; }

    .container { max-width: 700px; }
    .container-wide { max-width: 1100px; }

    .post-detail-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
    .post-detail-layout .post-preview { border-right: 1px solid var(--border); }
}
