/* ============================================================
   suivibiz_common.css — feuille commune aux 3 pages suivibiz
   Sert : suivibiz_login.html, suivibiz_dashboard.html, suivibiz_prospect.html
   Charge via <link rel="stylesheet" href="suivibiz_common.css">
   ============================================================
   Sommaire :
     @layer reset      — box-sizing + reset margin/padding
     @layer tokens     — :root design tokens (palette, radius, shadow, typo)
     @layer base       — html/body + button + input/select/textarea
     @layer components — shell, nav, card, tag, stag, btn, btn-icon,
                         btn-add, btn-add-primary, avatar, user-chip, pill, tabs/tab,
                         alog/aitem/anew, chan, rappel-badge, empty
   ----------------------------------------------------------------
   Aucune valeur de style en dur dans les pages : toute taille,
   couleur, espacement, radius passe par var(--*). Les overrides
   strictement page-only restent inline dans le <style> du HTML.
   ============================================================ */

@layer reset, tokens, base, components;

/* ---------- @layer reset ---------- */
@layer reset {
  *, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }
}

/* ---------- @layer tokens ---------- */
@layer tokens {
  :root {
    /* Surfaces */
    --bg:        #f4f5f7;
    --white:     #ffffff;
    --nav:       #1a1d2e;
    --nav-icon:  #8b8fa8;
    --nav-act:   #7f77dd;

    /* Bordures */
    --border:    #e2e4e9;
    --border2:   #eceef2;

    /* Texte */
    --text:      #111827;
    --text2:     #6b7280;
    --text3:     #9ca3af;

    /* Accent */
    --accent:    #7f77dd;
    --accent-h:  #6860c8;
    --accent-bg: #f0effc;

    /* Statuts */
    --green:     #16a34a;
    --green-bg:  #dcfce7;
    --blue:      #2563eb;
    --blue-bg:   #dbeafe;
    --amber:     #d97706;
    --amber-bg:  #fef3c7;
    --red:       #dc2626;
    --red-bg:    #fee2e2;
    --whatsapp:    #25D366;
    --whatsapp-bg: #d4f7e0;
    --violet:      #7c3aed;
    --violet-bg:   #ede9fe;
    
    /* Radius */
    --radius-sm: 6px;
    --radius:    10px;

    /* Shadow */
    --shadow:    0 1px 3px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
    --shadow-md: 0 2px 8px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.06);

    /* Typo — profil C (body 16px, labels upper 13px, KPI 36px) */
    --fs-xs:      12px;  /* badge label compact, kpi-l sidebar */
    --fs-sm:      13px;  /* tag, stag, card-hd--upper, f label, empty */
    --fs-base:    14px;  /* meta, sous-titres */
    --fs-md:      15px;  /* button, btn, pill, search */
    --fs-lg:      16px;  /* body, t-name, gi-name, card-hd-title */
    --fs-xl:      18px;  /* topbar-title, sb-title */
    --fs-2xl:     22px;  /* dh-l h2 (titre detail) */
    --fs-display: 36px;  /* kpi-value */
  }
}

/* ---------- @layer base ---------- */
@layer base {
  html, body {
    height: 100%;
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    color: var(--text);
    font-size: var(--fs-lg);
  }

  /* Bouton primaire generique (override possible par page) */
  button {
    font-family: inherit;
    cursor: pointer;
  }

  /* Champs de formulaire (rapatries depuis prospect inline 2026-05-29) */
  input[type=text], input[type=email], input[type=date], select, textarea {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    color: var(--text);
    font-size: var(--fs-md);
    font-family: inherit;
    outline: none;
    width: 100%;
    transition: border-color .15s, box-shadow .15s;
  }
  input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(127,119,221,.1);
    background: var(--white);
  }
  select { cursor: pointer; }
}

/* ---------- @layer components ---------- */
@layer components {

  /* ===== Shell ===== */
  .shell {
    display: flex;
    height: 100vh;
  }

  /* ===== Nav laterale icones (dashboard + prospect) ===== */
  .nav {
    width: 52px;
    background: var(--nav);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 0;
    gap: 4px;
    flex-shrink: 0;
  }
  .nav-logo {
    font-size: var(--fs-xs);
    font-weight: 700;
    color: #fff;
    letter-spacing: -.02em;
    line-height: 1.1;
    text-align: center;
    margin-bottom: 16px;
    padding: 0 4px;
  }
  .nav-logo em {
    color: var(--nav-act);
    font-style: normal;
  }
  .nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--nav-icon);
    transition: background .15s, color .15s;
    border: none;
    background: transparent;
  }
  .nav-btn:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
  }
  .nav-btn.on {
    background: var(--nav-act);
    color: #fff;
  }
  .nav-btn svg {
    flex-shrink: 0;
  }
  .nav-foot {
    margin-top: auto;
  }

  /* ===== Card generique ===== */
  .card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    flex-shrink: 0;
    overflow: hidden;
  }
  /* .card-hd : base flex titre + lien. Variante uppercase via .card-hd--upper. */
  .card-hd {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border2);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .card-hd-title {
    font-size: var(--fs-lg);
    font-weight: 600;
  }
  .card-hd-link {
    font-size: var(--fs-base);
    color: var(--accent);
    cursor: pointer;
    text-decoration: none;
  }
  .card-hd-link:hover {
    text-decoration: underline;
  }
  .card-hd--upper {
    padding: 10px 14px;
    font-size: var(--fs-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text3);
    display: block;
  }

  /* ===== Tags marque ===== */
  .tag {
    font-size: var(--fs-sm);
    padding: 2px 7px;
    border-radius: 20px;
    white-space: nowrap;
    font-weight: 500;
  }
  .tag-P { background: #dbeafe; color: #1d4ed8; }
  .tag-C { background: #fef3c7; color: #92400e; }
  .tag-O { background: #dcfce7; color: #15803d; }
  .tag-D { background: #ede9fe; color: #6d28d9; }
  .tag-M { background: #f3f4f6; color: #6b7280; }

  /* ===== Tags statut ===== */
  .stag {
    font-size: var(--fs-sm);
    padding: 2px 7px;
    border-radius: 20px;
    font-weight: 500;
  }
  .stag-a { background: #f3f4f6;       color: #6b7280; }
  .stag-c { background: var(--amber-bg); color: var(--amber); }
  .stag-r { background: var(--blue-bg);  color: var(--blue); }
  .stag-s { background: var(--green-bg); color: var(--green); }

  /* ===== Avatar + user-chip (dashboard topbar) ===== */
  .user-chip {
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 12px 4px 6px;
    font-size: var(--fs-base);
    color: var(--text2);
  }
  .avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-bg);
    color: var(--accent);
    font-size: var(--fs-xs);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* ===== Boutons utilitaires (prospect detail) ===== */
  .btn {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--text2);
    font-size: var(--fs-md);
    font-family: inherit;
    cursor: pointer;
    transition: all .12s;
  }
  .btn:hover {
    border-color: var(--accent);
    color: var(--accent);
  }
  .btn-icon {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--text3);
    font-size: var(--fs-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .12s;
  }
  .btn-icon:hover {
    border-color: var(--red);
    color: var(--red);
  }
  .btn-add {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--text2);
    font-size: var(--fs-md);
    font-family: inherit;
    cursor: pointer;
    transition: all .12s;
    white-space: nowrap;
  }
  .btn-add:hover {
    border-color: var(--accent);
    color: var(--accent);
  }

  /* ===== Bouton primaire ajout (action explicite, formulaires) ===== */
  .btn-add-primary {
    background: var(--accent);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-size: var(--fs-md);
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background .12s;
    white-space: nowrap;
  }
  .btn-add-primary:hover { background: var(--accent-h); }

  /* ===== Pills (filtres sidebar prospect, rapatrie 2026-05-29) ===== */
  .pill {
    font-size: var(--fs-sm);
    padding: 3px 9px;
    border-radius: 20px;
    border: 1px solid var(--border);
    color: var(--text2);
    cursor: pointer;
    background: transparent;
    font-family: inherit;
    transition: all .12s;
  }
  .pill:hover { border-color: var(--accent); color: var(--accent); }
  .pill.on {
    background: var(--accent-bg);
    color: var(--accent);
    border-color: var(--accent);
    font-weight: 500;
  }

  /* ===== Onglets connectes (Phase 2.5.D) =====
     .tabs       conteneur (ligne d'onglets soudee au sommet de la zone contenu)
     .tab        onglet inactif (accent-bg mauve pale)
     .tab--on    onglet actif (blanc, fusionne avec contenu en dessous) */
  .tabs {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
    position: relative;
  }
  .tab {
    padding: 7px 14px;
    font-size: var(--fs-md);
    background: var(--accent-bg);
    color: var(--accent);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    cursor: pointer;
    font-family: inherit;
    transition: background .12s, color .12s;
    position: relative;
    top: 1px;
  }
  .tab:hover {
    background: var(--white);
  }
  .tab--on {
    background: var(--white);
    color: var(--text);
    font-weight: 500;
    border-bottom: 1px solid var(--white);
    z-index: 1;
  }

  /* ===== Journal d'echanges (refonte 2026-05-29 soir : carte verticale empilee) ===== */
  .alog { display: flex; flex-direction: column; gap: 8px; }
  .aitem {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
  }
  .aitem-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }
  .adate { font-size: var(--fs-sm); color: var(--text2); }
  .aqui  { font-size: var(--fs-sm); color: var(--accent); font-weight: 600; }
  .meta-sep { color: var(--text3); }
  .anote { font-size: var(--fs-md); color: var(--text); line-height: 1.5; }
  .arappel-line { font-size: var(--fs-sm); color: var(--amber); padding-top: 2px; }
  .adel {
    margin-left: auto;
    cursor: pointer;
    color: var(--text3);
    font-size: var(--fs-md);
    padding: 0 4px;
  }
  .adel:hover { color: var(--red); }
  .anew {
    margin-top: 12px;
    display: grid;
    grid-template-columns: 130px 110px 1fr 130px auto;
    gap: 8px;
    align-items: center;
    padding: 10px;
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
  }
  .anew input[type=date], .anew select, .anew input[type=text] {
    background: var(--white);
  }

  /* ===== Chip canal CRM (HubSpot/Pipedrive pattern) ===== */
  .chan {
    display: inline-block;
    padding: 2px 8px;
    margin-right: 6px;
    border-radius: 12px;
    font-size: var(--fs-sm);
    font-weight: 500;
    vertical-align: baseline;
  }
  .chan-appel    { background: var(--blue-bg);     color: var(--blue); }
  .chan-email    { background: var(--bg);          color: var(--text2); }
  .chan-sms      { background: var(--green-bg);    color: var(--green); }
  .chan-whatsapp { background: var(--whatsapp-bg); color: var(--whatsapp); }
  .chan-visite   { background: var(--violet-bg);   color: var(--violet); }
  .chan-note     { background: var(--border2);     color: var(--text2); }
  .chan-rdv      { background: var(--accent-bg);   color: var(--accent); }

  /* ===== Rappel badge (rapatrie depuis prospect 2026-05-29) ===== */
  .rappel-badge {
    font-size: var(--fs-sm);
    color: var(--amber);
    background: var(--amber-bg);
    border-radius: var(--radius-sm);
    padding: 3px 9px;
    font-weight: 500;
  }
  .rappel-badge.late { color: var(--red); background: var(--red-bg); }


  /* ===== Etat vide generique (rapatrie depuis prospect 2026-05-29) ===== */
  .empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text3);
    font-size: var(--fs-sm);
  }
}

/* ============================================================
   RESPONSIVE — Breakpoints
     - Mobile  : < 600px  → nav en bottom bar, master/detail mobile
     - Tablette: 600-1023 → nav 48px, sidebar 220px (overrides page)
     - Desktop : >= 1024px → etat actuel
   ============================================================ */

/* ── Mobile (< 600px) ── */
@media (max-width: 599px) {
  /* Nav verticale -> bottom bar fixe */
  .nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 56px;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    padding: 0 8px;
    gap: 0;
    border-top: 1px solid rgba(255,255,255,.06);
    z-index: 100;
  }
  .nav-logo { display: none; }
  .nav-btn {
    width: 44px;
    height: 44px;
  }
  .nav-foot {
    margin-top: 0;
    margin-left: auto;
  }
  /* Journal d'echanges mobile : formulaire reflowed (liste reste flex-column intrinseque) */
  .anew { grid-template-columns: 1fr 1fr; }
  .anew input[type=text] { grid-column: span 2; }
  /* Bouton "+ Ajouter" reste a droite, jamais pleine largeur */
  /* Body : laisser de la place pour la bottom bar */
  .shell {
    padding-bottom: 56px;
  }
  /* Cards : padding reduit */
  .card-hd { padding: 10px 12px; }
  .card-hd--upper { padding: 8px 12px; }
}

/* ── Tablette (600-1023px) ── */
@media (min-width: 600px) and (max-width: 1023px) {
  .nav { width: 48px; }
  .nav-btn { width: 32px; height: 32px; }
}
