/* ═══ CyberEnquête — Design System CSS ═══ */

/* ─── Base ──────────────────────────────────────────────── */
[x-cloak] { display: none !important; }
* { transition-property: background-color, border-color, color, box-shadow; transition-duration: 0s; }
body { transition: none; }

/* ─── Sidebar drag & drop ──────────────────────────────── */
.nav-item[draggable="true"] { user-select: none; }
.nav-item[draggable="true"]:hover { outline: 1px dashed rgba(255,255,255,0.15); outline-offset: -1px; }
.nav-item.drag-over { border-top: 2px solid #00C9A7; }

/* ─── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
.dark ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
.dark ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
.light ::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 3px; }
.light ::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); }

/* ─── Focus ─────────────────────────────────────────────── */
*:focus-visible { outline: 2px solid rgba(0,201,167,0.5); outline-offset: 0; }
/* Boutons à fond plein : pas d'outline qui crée des artefacts visuels sur fond coloré */
.btn-start:focus, .btn-start:focus-visible,
.btn-create:focus, .btn-create:focus-visible,
.btn-save:focus, .btn-save:focus-visible,
.btn-launch:focus, .btn-launch:focus-visible,
.btn-login:focus, .btn-login:focus-visible,
.btn-send:focus, .btn-send:focus-visible,
.btn-back:focus, .btn-back:focus-visible,
.btn-forward:focus, .btn-forward:focus-visible,
.btn-logout:focus, .btn-logout:focus-visible {
    outline: none;
}

/* ─── Utilities ─────────────────────────────────────────── */
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
dialog::backdrop { background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); }
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-indicator { display: none; }

/* ─── Toggle Switch iOS ────────────────────────────────── */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}
.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch.active {
    background: #00C9A7;
}
.toggle-switch.active::after {
    transform: translateX(20px);
}
.toggle-switch.active-cyber { background: #7B5CC4; }
.toggle-switch.active-accent { background: #FF6B35; }
.light .toggle-switch { background: #e2e8f0; }
.light .toggle-switch.active { background: #00C9A7; }

/* ─── Boutons Design System ────────────────────────────── */

/* btn-send: Envoyer un email/rapport (royalblue, animation avion) */
.btn-send {
  font-family: inherit; font-size: 14px; background: royalblue; color: white;
  padding: 0.6em 1em 0.6em 0.9em; display: inline-flex; align-items: center;
  border: none; border-radius: 16px; overflow: hidden; transition: all 0.2s; cursor: pointer;
}
.btn-send span { display: block; margin-left: 0.3em; transition: all 0.3s ease-in-out; }
.btn-send svg { display: block; transform-origin: center; transition: transform 0.3s ease-in-out; width: 18px; height: 18px; }
.btn-send:hover .svg-wrapper { animation: btn-fly 0.6s ease-in-out infinite alternate; }
.btn-send:hover svg { transform: translateX(1.2em) rotate(45deg) scale(1.1); }
.btn-send:hover span { transform: translateX(5em); }
.btn-send:active { transform: scale(0.95); }
@keyframes btn-fly { from { transform: translateY(0.1em); } to { transform: translateY(-0.1em); } }

/* btn-create: Nouveau / Créer (brand, icône +) */
.btn-create {
  border: 2px solid #00C9A7; background-color: #00C9A7; border-radius: 0.9em;
  cursor: pointer; padding: 0.55em 1em 0.55em 0.8em; transition: all 0.2s; font-size: 14px;
  display: inline-flex; align-items: center; color: #fff; font-weight: 600; gap: 0.3em;
}
.btn-create svg { width: 20px; height: 20px; }
.btn-create:hover { background-color: #00A88A; border-color: #00A88A; }
.btn-create:active { transform: scale(0.96); }
.btn-create.cyber { border-color: #7B5CC4; background-color: #7B5CC4; }
.btn-create.cyber:hover { background-color: #6848B0; border-color: #6848B0; }

/* btn-start: Commencer / Reprendre (gradient violet, flèche glissante) */
.btn-start {
  background: #a370f0; color: white; font-family: inherit;
  padding: 0.35em; padding-left: 1.2em; font-size: 14px; font-weight: 500;
  border-radius: 0.9em; border: none; letter-spacing: 0.05em;
  display: inline-flex; align-items: center; box-shadow: inset 0 0 1.6em -0.6em #714da6;
  overflow: hidden; position: relative; height: 2.5em; padding-right: 3em; cursor: pointer;
}
.btn-start .icon {
  background: white; margin-left: 1em; position: absolute; display: flex;
  align-items: center; justify-content: center; height: 1.9em; width: 1.9em;
  border-radius: 0.7em; box-shadow: 0.1em 0.1em 0.6em 0.2em #7b52b9;
  right: 0.3em; transition: all 0.3s;
}
.btn-start:hover .icon { box-shadow: 0.1em 0.1em 0.9em 0.35em #7b52b9; }
.btn-start .icon svg { width: 1.1em; transition: transform 0.3s; color: #7b52b9; }
.btn-start:hover .icon svg { transform: translateX(0.15em); }
.btn-start:active .icon { transform: scale(0.95); }
.btn-start.accent { background: #FF6B35; box-shadow: inset 0 0 1.6em -0.6em #c74e1f; }
.btn-start.accent .icon { box-shadow: 0.1em 0.1em 0.6em 0.2em #c74e1f; }
.btn-start.accent:hover .icon { box-shadow: 0.1em 0.1em 0.9em 0.35em #c74e1f; }
.btn-start.accent .icon svg { color: #FF6B35; }
/* Small variant for tables/grids */
.btn-start.sm { font-size: 11px; height: 2em; padding-left: 0.8em; padding-right: 2.4em; }
.btn-start.sm .icon { height: 1.5em; width: 1.5em; }

/* btn-save: Sauvegarder (gradient reveal on hover) */
.btn-save {
  position: relative; overflow: hidden; height: 2.5rem; padding: 0 1.5rem;
  border-radius: 1.25rem; background: #3d3a4e; color: #fff; border: none;
  cursor: pointer; font-size: 13px; font-weight: 500; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-save::before {
  content: ""; position: absolute; top: 0; left: 0; transform: scaleX(0);
  transform-origin: 0 50%; width: 100%; height: inherit; border-radius: inherit;
  background: linear-gradient(82.3deg, rgba(150,93,233,1) 10.8%, rgba(99,88,238,1) 94.3%);
  transition: all 0.475s;
}
.btn-save:hover::before { transform: scaleX(1); }
.btn-save .btn-save-content { position: relative; z-index: 1; }
.btn-save:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-save:disabled::before { display: none; }

/* btn-back: Retour (sliding green arrow) */
.btn-back {
  display: inline-flex; align-items: center; position: relative;
  background: var(--surface-card, #1e293b); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 1rem; height: 2.5rem; padding: 0; cursor: pointer;
  text-decoration: none; overflow: hidden; min-width: 10rem;
  margin-bottom: 1rem;
}
.btn-back .btn-back-arrow {
  background: #00C9A7; border-radius: 0.75rem; height: 2rem; width: 2rem;
  display: flex; align-items: center; justify-content: center;
  position: absolute; left: 4px; top: 50%; transform: translateY(-50%);
  transition: width 0.5s; z-index: 2;
}
.btn-back:hover .btn-back-arrow { width: calc(100% - 8px); }
.btn-back .btn-back-arrow svg { width: 18px; height: 18px; color: white; }
.btn-back .btn-back-text {
  flex: 1; text-align: center; font-size: 12px; font-weight: 600;
  color: var(--text-primary, #e2e8f0); padding: 0 0.75rem 0 2.5rem;
  position: relative; z-index: 1; white-space: nowrap;
}
.light .btn-back { background: #fff; border-color: #e2e8f0; }
.light .btn-back .btn-back-text { color: #1e293b; }

/* btn-forward: same as btn-back but arrow on the right */
.btn-forward {
  display: inline-flex; align-items: center; position: relative;
  background: var(--surface-card, #1e293b); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 1rem; height: 2.5rem; padding: 0; cursor: pointer;
  text-decoration: none; overflow: hidden; min-width: 10rem;
}
.btn-forward .btn-forward-arrow {
  background: #00C9A7; border-radius: 0.75rem; height: 2rem; width: 2rem;
  display: flex; align-items: center; justify-content: center;
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  transition: width 0.5s; z-index: 2;
}
.btn-forward:hover .btn-forward-arrow { width: calc(100% - 8px); right: 4px; }
.btn-forward .btn-forward-arrow svg { width: 18px; height: 18px; color: white; }
.btn-forward .btn-forward-text {
  flex: 1; text-align: center; font-size: 12px; font-weight: 600;
  color: var(--text-primary, #e2e8f0); padding: 0 2.5rem 0 0.75rem;
  position: relative; z-index: 1; white-space: nowrap;
}
.light .btn-forward { background: #fff; border-color: #e2e8f0; }
.light .btn-forward .btn-forward-text { color: #1e293b; }

/* btn-logout: Déconnexion (cercle rouge expansible) */
.btn-logout {
  display: flex; align-items: center; justify-content: flex-start;
  width: 36px; height: 36px; border: none; border-radius: 50%;
  cursor: pointer; position: relative; overflow: hidden; transition: all 0.3s;
  box-shadow: 2px 2px 10px rgba(0,0,0,0.199); background-color: rgb(255,65,65);
  padding: 0;
}
.btn-logout .btn-logout-icon {
  width: 100%; display: flex; align-items: center; justify-content: center; transition: all 0.3s;
}
.btn-logout .btn-logout-icon svg { width: 15px; height: 15px; fill: white; }
.btn-logout .btn-logout-label {
  position: absolute; right: 0; width: 0; opacity: 0;
  color: white; font-size: 12px; font-weight: 600; transition: all 0.3s; white-space: nowrap;
}
.btn-logout:hover { width: 110px; border-radius: 40px; }
.btn-logout:hover .btn-logout-icon { width: 30%; padding-left: 12px; }
.btn-logout:hover .btn-logout-label { opacity: 1; width: 70%; padding-right: 10px; }
.btn-logout:active { transform: translate(2px, 2px); }

/* btn-launch: Login / Questionnaire / Webapp launch (dark gradient + rocket) */
.btn-launch {
  display: inline-flex; align-items: center; font-family: inherit; cursor: pointer;
  font-weight: 500; font-size: 14px; padding: 0.7em 1.2em 0.7em 0.8em; color: white;
  background: linear-gradient(to right, #0f0c29, #302b63, #24243e);
  border: none; letter-spacing: 0.05em; border-radius: 16px;
}
.btn-launch svg { margin-right: 4px; transform: rotate(30deg); transition: transform 0.5s cubic-bezier(0.76,0,0.24,1); width: 20px; height: 20px; }
.btn-launch span { transition: transform 0.5s cubic-bezier(0.76,0,0.24,1); }
.btn-launch:hover svg { transform: translateX(5px) rotate(90deg); }
.btn-launch:hover span { transform: translateX(7px); }
.btn-launch:active { transform: scale(0.96); }

/* btn-login: Login page buttons (gradient slide reveal) */
.btn-login {
  position: relative; font-family: inherit; font-weight: 500; font-size: 16px;
  letter-spacing: 0.05em; border-radius: 0.8em; cursor: pointer; border: none;
  background: linear-gradient(to right, #8e2de2, #4a00e0); color: ghostwhite;
  overflow: hidden; width: 100%; display: block;
}
.btn-login span {
  position: relative; z-index: 10; transition: color 0.4s;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.8em 1.2em; width: 100%;
}
.btn-login span svg { width: 1.2em; height: 1.2em; margin-right: 0.5em; }
.btn-login::before {
  content: ""; position: absolute; top: 0; left: -10%; width: 120%; height: 100%;
  background: #000; z-index: 0; transform: skew(30deg);
  transition: transform 0.4s cubic-bezier(0.3, 1, 0.8, 1);
}
.btn-login:hover::before { transform: translate3d(100%, 0, 0); }
.btn-login:active { transform: scale(0.95); }
.btn-login:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-login:disabled::before { display: none; }

/* Light mode overrides */
.light .btn-save { background: #e2e8f0; color: #1e293b; }
.light .btn-create { border-color: #00C9A7; }
.light .btn-create.cyber { border-color: #7B5CC4; }
.light .btn-create.cyber:hover { border-color: #6848B0; }

/* ─── Animations ────────────────────────────────────────── */
@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
@keyframes slideInLeft { from { opacity:0; transform:translateX(-16px); } to { opacity:1; transform:translateX(0); } }
@keyframes pulse-brand { 0%,100% { box-shadow:0 0 0 0 rgba(0,201,167,0.4); } 50% { box-shadow:0 0 0 8px rgba(0,201,167,0); } }
.animate-fade-in { animation: fadeIn 0.3s ease-out; }
.animate-slide-in { animation: slideInLeft 0.3s ease-out; }
.animate-pulse-brand { animation: pulse-brand 2s ease-in-out infinite; }

/* ─── Page Loader (thème brand/cyber/accent) ───────────── */
@keyframes l24 { 100% { transform: rotate(1turn); } }
.page-loader {
  width: 50px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 8px solid transparent;
  border-right-color: rgba(0,201,167,0.6);
  position: relative;
  animation: l24 1s infinite linear;
}
.page-loader:before,
.page-loader:after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: inherit;
  animation: inherit;
  animation-duration: 2s;
}
.page-loader:before { border-right-color: rgba(123,92,196,0.5); }
.page-loader:after { border-right-color: rgba(255,107,53,0.4); animation-duration: 4s; }

/* ─── Page transition — anti-flash layout ──────────────── */
#page-loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease-out;
}
.dark #page-loader-overlay { background: #0a0f1a; }
.light #page-loader-overlay { background: #f1f5f9; }
#page-loader-overlay.fade-out { opacity: 0; pointer-events: none; }

/* Cacher le contenu principal tant qu'Alpine n'est pas prêt */
[x-cloak-layout] { opacity: 0; }
[x-cloak-layout].layout-ready { opacity: 1; transition: opacity 0.2s ease-out; }

/* ─── Sidebar ───────────────────────────────────────────── */
.sidebar-collapsed .sidebar-label { display: none; }
.sidebar-collapsed .sidebar-section-title { display: none; }
.sidebar-collapsed .sidebar-user-info { display: none; }

/* ═══ FORM ELEMENTS — Fix select/input en dark & light ═══ */

/* Select et Input globaux — DARK */
.dark select,
.dark dialog select {
    background-color: rgba(255,255,255,0.05) !important;
    color: #e2e8f0 !important;
    border-color: rgba(255,255,255,0.1) !important;
}
.dark select option {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
}
.dark input[type="text"],
.dark input[type="email"],
.dark input[type="password"],
.dark input[type="url"],
.dark input[type="number"],
.dark input[type="date"],
.dark input[type="search"],
.dark textarea {
    color: #e2e8f0 !important;
}

/* Select et Input globaux — LIGHT */
.light select,
.light dialog select {
    background-color: #ffffff !important;
    color: #1e293b !important;
    border-color: #e2e8f0 !important;
}
.light select option {
    background-color: #ffffff !important;
    color: #1e293b !important;
}
.light input[type="text"],
.light input[type="email"],
.light input[type="password"],
.light input[type="url"],
.light input[type="number"],
.light input[type="date"],
.light input[type="search"],
.light textarea {
    color: #1e293b !important;
}

/* Dialog/Modal dark */
.dark dialog { background-color: #0f172a; color: #e2e8f0; }
.light dialog { background-color: #ffffff; color: #1e293b; border-color: #e2e8f0; }

/* ═══ LAYOUT — Full-width cards ═══ */
/* Main content utilise tout l'espace avec un petit spacing */
main { padding: 1rem !important; }
@media (min-width: 1024px) { main { padding: 1.25rem !important; } }

/* Pré-margin sidebar : appliqué par inline style via --sidebar-w, uniquement desktop */
@media (max-width: 1023px) { main[style*="margin-left"] { margin-left: 0 !important; } }

/* ═══ CHART.JS — Fix container overflow ═══ */
canvas { max-height: 300px !important; }

/* ═══ LIGHT THEME ═══ */
.light {
    --surface-bg: #f1f5f9;
    --surface-card: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
}
.light .bg-surface-950 { background-color: var(--surface-bg) !important; }
.light .bg-surface-900\/95,
.light .bg-surface-900\/80,
.light .bg-surface-900\/60,
.light .bg-surface-900 { background-color: var(--surface-card) !important; }
.light .text-white { color: var(--text-primary) !important; }
.light .text-gray-100 { color: var(--text-primary) !important; }
.light .text-gray-200 { color: #334155 !important; }
.light .text-gray-300 { color: #475569 !important; }
.light .text-gray-400 { color: var(--text-secondary) !important; }
.light .text-gray-500 { color: #94a3b8 !important; }
.light .border-white\/5,
.light .border-white\/10 { border-color: var(--border-color) !important; }
.light .bg-white\/5,
.light .bg-white\/\[0\.02\],
.light .bg-white\/\[0\.03\] { background-color: #f8fafc !important; }
.light .hover\:bg-white\/5:hover,
.light .hover\:bg-white\/10:hover { background-color: #e2e8f0 !important; }
.light .bg-black\/50 { background-color: rgba(0,0,0,0.25) !important; }
.light .text-brand { color: #009e84 !important; }
.light .text-accent { color: #e55a2b !important; }
.light .text-cyber { color: #6347a8 !important; }
.light .shadow-lg { box-shadow: 0 4px 12px rgba(0,0,0,0.08) !important; }
