/* ============================================================
   GuestAgent — feuille de style principale
   ============================================================ */

:root {
  /* ----- Palette (§14.3) ----- */
  --color-primary:       #1E3A5F;
  --color-primary-dark:  #142A45;
  --color-primary-soft:  #E8EEF6;
  --color-accent:        #E8A838;
  --color-accent-dark:   #C68A1E;
  --color-background:    #F6F8FB;
  --color-surface:       #FFFFFF;
  --color-text:          #172033;
  --color-text-muted:    #6B7280;
  --color-border:        #E4E8EF;
  --color-success:       #1F9D68;
  --color-warning:       #D88A18;
  --color-danger:        #D64545;
  --color-info:          #3B82F6;

  /* ----- Typographie ----- */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.08);
  --shadow-lg: 0 12px 32px rgba(15,23,42,0.10);

  --sidebar-width: 240px;
}

/* ----- Mode nuit ----- */
[data-theme="dark"] {
  color-scheme: dark;
  --color-primary:       #5B9BD5;
  --color-primary-dark:  #7AB3E0;
  --color-primary-soft:  #152535;
  --color-accent:        #E8A838;
  --color-accent-dark:   #F0B84A;
  --color-background:    #0E1622;
  --color-surface:       #172032;
  --color-text:          #DDE3EE;
  --color-text-muted:    #7F8FA8;
  --color-border:        #28384F;
  --color-success:       #30C97E;
  --color-warning:       #E8A838;
  --color-danger:        #E85555;
  --color-info:          #5BA3F5;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.35);
  --shadow-md: 0 4px 14px rgba(0,0,0,.45);
  --shadow-lg: 0 12px 36px rgba(0,0,0,.55);
}

/* Rétablir le fond des éléments de formulaire que le navigateur
   force en blanc même quand les custom properties changent */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background-color: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder { color: var(--color-text-muted); }

/* Bouton bascule clair/nuit */
.ga-theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: .2rem .25rem;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  line-height: 1;
  transition: color .15s, background .15s;
  flex-shrink: 0;
}
.ga-theme-toggle:hover { color: var(--color-primary); background: var(--color-primary-soft); }

/* ----- Reset léger ----- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-background);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-dark); text-decoration: underline; }
h1, h2, h3, h4 { color: var(--color-text); margin: 0 0 .5em; line-height: 1.3; }
h1 { font-size: 1.6rem; font-weight: 600; }
h2 { font-size: 1.3rem; font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; }
p  { margin: 0 0 .8em; }

/* ----- Layout dashboard ----- */
.ga-layout { display: flex; min-height: 100vh; }

.ga-sidebar {
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
  flex-shrink: 0;
}
.ga-sidebar .ga-brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 0 1.25rem 1.25rem;
  font-size: 1.05rem; font-weight: 600; color: var(--color-primary);
}
.ga-sidebar .ga-brand img { width: 28px; height: 28px; }
.ga-sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 0 .75rem; }
.ga-sidebar nav a {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .75rem;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: .92rem;
}
.ga-sidebar nav a:hover { background: var(--color-primary-soft); text-decoration: none; }
.ga-sidebar nav a.active {
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  font-weight: 600;
}
.ga-sidebar nav .ga-submenu a { padding-left: 2.2rem; font-size: .87rem; color: var(--color-text-muted); }

/* Clochette d'alerte dans les items de menu */
.ga-sidebar a .ga-alert-bell {
  margin-left: auto;
  color: #800020;
  flex-shrink: 0;
  animation: gaAlertPulse 2s ease-in-out infinite;
}
@keyframes gaAlertPulse {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%      { opacity: .55; transform: scale(.9); }
}

/* ----- Bloc bas de sidebar (admin + support) ----- */
.ga-sidebar-bottom { margin-top: auto; }

/* ----- Section admin (uniquement pour id_client = 7) ----- */
.ga-admin-section {
  background: var(--color-primary);
  padding: 1rem .75rem;
  color: #ffffff;
}

/* ----- Section support (tout le monde, tout en bas) ----- */
.ga-support-section {
  background: var(--color-primary-dark);
  padding: .6rem .75rem;
}
.ga-support-section a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .75rem;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, .85);
  font-size: .9rem;
  font-weight: 500;
  text-decoration: none;
}
.ga-support-section a:hover {
  background: rgba(255, 255, 255, .1);
  color: #ffffff;
  text-decoration: none;
}
.ga-support-section a.active {
  background: rgba(255, 255, 255, .15);
  color: #ffffff;
  font-weight: 600;
}
.ga-admin-section-title {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255, 255, 255, .55);
  padding: 0 .75rem .5rem;
}
.ga-admin-section nav { padding: 0; }
.ga-admin-section nav a {
  color: #ffffff;
  font-size: .9rem;
  padding: .55rem .75rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: .6rem;
}
.ga-admin-section nav a:hover {
  background: rgba(255, 255, 255, .12);
  text-decoration: none;
}
.ga-admin-section nav a.active {
  background: var(--color-primary-dark);
  font-weight: 600;
}
.ga-sidebar { display: flex; flex-direction: column; }

.ga-main {
  flex: 1;
  display: flex; flex-direction: column;
  min-width: 0;
}
.ga-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.5rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 30;
}
.ga-topbar .ga-actions { display: flex; align-items: center; gap: 1rem; }

/* Burger (mobile uniquement) */
.ga-burger {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--color-text);
  padding: .4rem;
  margin-right: .5rem;
}
.ga-burger:hover { color: var(--color-primary); }

.ga-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 40;
}
.ga-sidebar-backdrop.is-open { display: block; }

body.ga-no-scroll { overflow: hidden; }
.ga-content { padding: 1.5rem; }

/* ----- Cartes ----- */
.ga-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.ga-card h2 { margin-top: 0; }

.ga-stat-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-bottom: 1.5rem;
}
.ga-stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm);
}
.ga-stat .ga-stat-label { font-size: .8rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .03em; }
.ga-stat .ga-stat-value { font-size: 1.7rem; font-weight: 700; color: var(--color-primary-dark); margin-top: .25rem; }
.ga-stat .ga-stat-delta { font-size: .8rem; margin-top: .35rem; }
.ga-stat .ga-stat-delta.up { color: var(--color-success); }
.ga-stat .ga-stat-delta.down { color: var(--color-danger); }

/* ----- Boutons ----- */
.ga-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .92rem; font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
  font-family: inherit;
}
.ga-btn,
.ga-btn:hover,
.ga-btn:focus,
.ga-btn:active { text-decoration: none; }

.ga-btn-primary { background: var(--color-primary); color: #fff; }
.ga-btn-primary:hover { background: var(--color-primary-dark); color: #fff; }
.ga-btn-accent { background: var(--color-accent); color: var(--color-primary-dark); }
.ga-btn-accent:hover { background: var(--color-accent-dark); color: #fff; }
.ga-btn-outline {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-border);
}
.ga-btn-outline:hover { border-color: var(--color-primary); background: var(--color-primary-soft); }
.ga-btn-danger { background: var(--color-danger); color: #fff; }
.ga-btn-ghost { background: transparent; color: var(--color-text-muted); }
.ga-btn-ghost:hover { color: var(--color-text); background: var(--color-primary-soft); }
.ga-btn:disabled, .ga-btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ----- Formulaires ----- */
.ga-form { display: flex; flex-direction: column; gap: 1rem; max-width: 520px; }
.ga-form label {
  display: block;
  font-size: .85rem; font-weight: 500; color: var(--color-text);
  margin-bottom: .3rem;
}
.ga-form input[type=text],
.ga-form input[type=email],
.ga-form input[type=password],
.ga-form input[type=number],
.ga-form input[type=tel],
.ga-form input[type=date],
.ga-form input[type=url],
.ga-form select,
.ga-form textarea {
  width: 100%;
  padding: .55rem .75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: .95rem;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.ga-form input:focus, .ga-form select:focus, .ga-form textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(30,58,95,.12);
}
.ga-form .ga-help { font-size: .8rem; color: var(--color-text-muted); margin-top: .25rem; }

/* ----- Tableaux ----- */
.ga-table { width: 100%; border-collapse: collapse; background: var(--color-surface); }
.ga-table th, .ga-table td {
  padding: .7rem .85rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  font-size: .92rem;
}
.ga-table th {
  font-weight: 600; color: var(--color-text-muted);
  font-size: .78rem; text-transform: uppercase; letter-spacing: .03em;
  background: var(--color-background);
}
.ga-table tr:last-child td { border-bottom: none; }
.ga-table tbody tr:hover { background: var(--color-primary-soft); }

/* Lignes sélectionnables (clic sur ligne entière pour cocher) */
.ga-clickable-rows tr.ga-row-selectable { transition: background .15s; }
.ga-clickable-rows tr.ga-row-selectable.is-selected {
  background: rgba(31, 157, 104, .10);
}
.ga-clickable-rows tr.ga-row-selectable.is-selected:hover {
  background: rgba(31, 157, 104, .18);
}

/* ----- Badges de statut (§14.2) ----- */
.ga-badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .75rem; font-weight: 500;
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
}
.ga-badge-success { background: rgba(31,157,104,.12); color: var(--color-success); }
.ga-badge-warning { background: rgba(216,138,24,.13); color: var(--color-warning); }
.ga-badge-danger  { background: rgba(214,69,69,.12); color: var(--color-danger); }
.ga-badge-info    { background: rgba(59,130,246,.12); color: var(--color-info); }
.ga-badge-muted   { background: var(--color-background); color: var(--color-text-muted); }

/* Alias par statut métier */
.ga-status-available     { background: rgba(59,130,246,.12); color: var(--color-info); }
.ga-status-assigned      { background: rgba(31,157,104,.12); color: var(--color-success); }
.ga-status-not_interested{ background: var(--color-background); color: var(--color-text-muted); }
.ga-status-to_invite     { background: rgba(216,138,24,.13); color: var(--color-warning); }
.ga-status-invited       { background: rgba(31,157,104,.18); color: var(--color-success); }
.ga-status-paused        { background: var(--color-background); color: var(--color-text-muted); }
.ga-status-archived      { background: var(--color-background); color: var(--color-text-muted); }
.ga-status-callback      { background: rgba(59,130,246,.12); color: var(--color-info); }

/* ----- Alertes ----- */
.ga-alert {
  padding: .8rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border-left: 3px solid var(--color-info);
  background: rgba(59,130,246,.06);
  font-size: .92rem;
}
.ga-alert-success { border-color: var(--color-success); background: rgba(31,157,104,.06); }
.ga-alert-warning { border-color: var(--color-warning); background: rgba(216,138,24,.07); }
.ga-alert-danger  { border-color: var(--color-danger); background: rgba(214,69,69,.06); }

/* ----- Carte de connexion ----- */
.ga-auth-shell {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1.5rem;
  background: linear-gradient(135deg, var(--color-primary-soft), var(--color-background));
}
.ga-auth-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
}
.ga-auth-card .ga-brand {
  text-align: center;
  font-size: 1.4rem; font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 1.5rem;
}

/* ----- Page action membre (mobile-first) ----- */
.ga-member-action-shell {
  max-width: 540px;
  margin: 0 auto;
  padding: 1.25rem;
}
.ga-member-action-card { padding: 1.5rem; }
.ga-member-action-actions {
  display: grid; gap: .6rem; margin-top: 1.25rem;
}
.ga-member-action-actions .ga-btn { width: 100%; justify-content: center; }

/* ----- Responsive ----- */
@media (max-width: 880px) {
  .ga-content { padding: 1rem; }
  .ga-stat .ga-stat-value { font-size: 1.4rem; }

  /* Sidebar en overlay coulissant depuis la gauche */
  .ga-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 80%;
    max-width: 300px;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 50;
    box-shadow: var(--shadow-lg);
  }
  .ga-sidebar.is-open { transform: translateX(0); }

  /* Burger visible, titre caché sur mobile */
  .ga-burger { display: inline-flex; }
  .ga-topbar .ga-page-title { display: none; }

  /* Actions topbar plus compactes */
  .ga-topbar { padding: .7rem .9rem; gap: .5rem; }
  .ga-topbar .ga-actions { gap: .4rem; }
  .ga-topbar .ga-btn-ghost span,
  .ga-topbar .ga-lang-switcher { display: none; }
}

/* ----- Toggle switch (on/off slider) ----- */
.ga-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}
.ga-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.ga-switch-slider {
  position: absolute;
  inset: 0;
  background: #D1D5DB;
  border-radius: 28px;
  cursor: pointer;
  transition: background .2s;
}
.ga-switch-slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  top: 3px;
  left: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .2s;
}
.ga-switch input:checked + .ga-switch-slider {
  background: var(--color-accent);
}
.ga-switch input:checked + .ga-switch-slider::before {
  transform: translateX(24px);
}
.ga-switch input:focus-visible + .ga-switch-slider {
  box-shadow: 0 0 0 3px rgba(232, 168, 56, .35);
}

/* ----- Onglets bordés ----- */
.ga-tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1.25rem;
  padding: 0 .25rem;
}
.ga-tabs .ga-tab {
  padding: .65rem 1.2rem;
  text-decoration: none;
  color: var(--color-text-muted);
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  font-weight: 500;
  font-size: .92rem;
  margin-bottom: -1px;
  transition: background .15s, color .15s;
}
.ga-tabs .ga-tab:hover {
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  text-decoration: none;
}
.ga-tabs .ga-tab.is-active {
  background: var(--color-surface);
  color: var(--color-primary);
  font-weight: 600;
  border-color: var(--color-border);
  border-bottom-color: var(--color-surface);
  position: relative;
  z-index: 1;
}

/* ----- Spinner (roue qui tourne) ----- */
.ga-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  margin-right: .5rem;
  vertical-align: -2px;
  animation: gaSpin .8s linear infinite;
}
tr.is-loading .ga-spinner { display: inline-block; }
@keyframes gaSpin {
  to { transform: rotate(360deg); }
}

/* ----- Tooltip-bulle (argumentaire IA au hover du téléphone) ----- */
.ga-phone-cell {
  position: relative;
  display: inline-block;
}
.ga-phone-cell .ga-phone-link {
  cursor: help;
}
.ga-phone-cell .ga-tip-bubble {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  left: auto;
  width: min(420px, 90vw);
  background: var(--color-primary-dark);
  color: #fff;
  font-size: .8rem;
  line-height: 1.45;
  padding: .75rem .9rem;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity .15s, transform .15s, visibility .15s;
  z-index: 60;
  pointer-events: none;
  white-space: normal;
}
.ga-phone-cell .ga-tip-bubble::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 1.2rem;
  left: auto;
  border: 6px solid transparent;
  border-top-color: var(--color-primary-dark);
}
.ga-phone-cell:hover .ga-tip-bubble,
.ga-phone-cell:focus-within .ga-tip-bubble {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ----- Empty states ----- */
.ga-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--color-text-muted);
}
.ga-empty h3 { color: var(--color-text); }

/* ----- Sélecteur de langue ----- */
.ga-lang-switcher select {
  font-size: .85rem;
  padding: .3rem .5rem;
}
