:root {
  --color-primary: #0f4f9a;
  --color-primary-soft: #2e73bf;
  --color-primary-deep: #0a2f63;
  --color-accent: #f3b11a;
  --color-surface: #f4f5f7;
  --color-card: #ffffff;
  --color-text: #18253a;
  --color-muted: #66758f;
  --color-border: #e2e8f0;
  --color-success: #10b981;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;
  --color-info: #3b82f6;
  --color-sidebar-bg: #0a2f63;
  --color-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
  --color-primary: #3b82f6;
  --color-primary-soft: #60a5fa;
  --color-primary-deep: #1e3a5f;
  --color-accent: #f3b11a;
  --color-surface: #0f172a;
  --color-card: #1e293b;
  --color-text: #e2e8f0;
  --color-muted: #64748b;
  --color-border: #334155;
  --color-sidebar-bg: #0d1526;
  --color-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

[data-theme="dark"] body {
  background-color: var(--color-surface);
  color: var(--color-text);
}

[data-theme="dark"] .dash-card,
[data-theme="dark"] .kpi-card {
  background: var(--color-card);
  border-color: var(--color-border);
  color: var(--color-text);
}

[data-theme="dark"] .data-table thead tr {
  background: #1e293b;
}

[data-theme="dark"] .data-table tbody tr:hover {
  background: rgba(255,255,255,0.04);
}

/* form-textarea dark mode géré dans components.css */

[data-theme="dark"] .sidebar {
  background: var(--color-sidebar-bg);
}

[data-theme="dark"] .app-body {
  background: var(--color-surface);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Sora", "Segoe UI", sans-serif;
  color: var(--color-text);
}

.auth-page {
  min-height: 100dvh;
  background: var(--color-primary-deep);
  position: relative;
}

.auth-page::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 6px;
  background: var(--color-accent);
  z-index: 3;
}

.auth-layout {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(380px, 1fr);
}

.auth-left-panel {
  background:
    linear-gradient(145deg, rgba(14, 39, 70, 0.76) 0%, rgba(12, 42, 70, 0.842) 58%, rgba(10, 77, 145, 0.86) 100%),
    radial-gradient(circle at 20% 12%, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0) 42%),
    url("../img/background_login.png") center/cover no-repeat;
  color: #f1f8ff;
  padding: clamp(1.3rem, 3vw, 2.4rem);
}

.auth-left-content {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.25rem;
  max-width: 680px;
  margin: 0 auto;
}

.auth-identity-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #ffffff;
  border-radius: 0.8rem;
  padding: 0.8rem;
  color: #0a2f63;
  box-shadow: 0 20px 40px rgba(7, 30, 62, 0.22);
}

.auth-identity-logo {
  width: 76px;
  height: 76px;
  border-radius: 0.7rem;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid #e8edf4;
}

.auth-identity-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.auth-identity-text strong {
  display: block;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.auth-identity-text p {
  margin: 0.3rem 0 0;
  font-size: 0.84rem;
  line-height: 1.4;
  color: #365071;
}

.auth-title-wrap {
  text-align: center;
}

.auth-app-name {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.7rem);
  font-weight: 800;
  letter-spacing: 0.03em;
}

.auth-app-tagline {
  margin: 0.45rem 0 0;
  color: rgba(232, 243, 255, 0.9);
}

.auth-feature-list {
  display: grid;
  gap: 0.72rem;
}

.auth-feature-item {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.8rem;
  padding: 0.9rem 1rem;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  transition: background 0.25s, border-color 0.25s;
}

.auth-feature-item:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.35);
}

.auth-feature-icon {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 0.6rem;
  background: rgba(243, 177, 26, 0.18);
  border: 1px solid rgba(243, 177, 26, 0.3);
  display: grid;
  place-items: center;
  color: #ffd56a;
}

.auth-feature-icon svg {
  width: 20px;
  height: 20px;
}

.auth-feature-text h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
}

.auth-feature-text p {
  margin: 0.25rem 0 0;
  color: rgba(230, 241, 255, 0.78);
  font-size: 0.84rem;
  line-height: 1.4;
}

.auth-left-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  margin-top: 0.3rem;
  padding-top: 0.85rem;
  display: grid;
  gap: 0.35rem;
  text-align: center;
}

.auth-left-footer-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.auth-left-footer-row svg {
  color: #ffd56a;
  flex-shrink: 0;
}

.auth-left-footer strong {
  color: #ffd56a;
}

.auth-left-footer span {
  color: rgba(228, 242, 255, 0.7);
  font-size: 0.84rem;
}

.auth-right-panel {
  background: linear-gradient(135deg, #f4f5f7 0%, #eef1f7 100%);
  display: grid;
  place-items: center;
  padding: clamp(1rem, 3vw, 2.3rem);
  position: relative;
  overflow: hidden;
}

.auth-right-panel::before {
  content: "";
  position: absolute;
  top: -50%;
  right: -50%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(47, 104, 207, 0.08) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.auth-right-panel::after {
  content: "";
  position: absolute;
  bottom: -30%;
  left: -30%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(243, 177, 26, 0.06) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.auth-login-box {
  width: min(100%, 520px);
  padding: clamp(2rem, 3vw, 2.8rem);
  border-radius: 1.2rem;
  background: #ffffff;
  box-shadow: 0 20px 60px rgba(15, 79, 154, 0.12), 0 0 1px rgba(15, 79, 154, 0.08);
  position: relative;
  z-index: 1;
  border: 1px solid rgba(255, 255, 255, 0.8);
}

.auth-mobile-hero {
  display: none;
  margin-bottom: 1.5rem;
}

.auth-mobile-hero-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-mobile-identity-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  border: 2px solid #2f68cf;
  border-radius: 0.9rem;
  background: #ffffff;
  padding: 1rem;
  box-shadow: 0 10px 25px rgba(24, 52, 92, 0.12);
}

.auth-mobile-identity-logos {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-shrink: 0;
}

.auth-mobile-identity-logo {
  width: 54px;
  height: 54px;
  border-radius: 0.5rem;
  object-fit: cover;
  border: 2px solid #e8edf4;
}

.auth-mobile-identity-text {
  flex: 1;
  min-width: 0;
}

.auth-mobile-identity-text strong {
  display: block;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  line-height: 1.3;
  color: #0a2f63;
  font-weight: 700;
}

.auth-mobile-identity-text p {
  margin: 0.25rem 0 0;
  font-size: 0.72rem;
  line-height: 1.3;
  color: #4d607d;
}

.auth-mobile-title {
  text-align: center;
  background: linear-gradient(135deg, #072061 0%, #072061 100%);
  border-radius: 0.9rem;
  padding: 1.2rem 1rem;
  color: #ffffff;
}

.auth-mobile-app-name {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #ffffff;
}

.auth-mobile-app-subtitle {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
}

.auth-login-header {
  margin-bottom: 0.5rem;
}

.auth-login-header h1 {
  margin: 0;
  font-size: clamp(1.9rem, 2.7vw, 2.25rem);
  letter-spacing: 0.01em;
  color: #0f1f35;
}

.auth-login-header p {
  margin: 0.5rem 0 0;
  color: var(--color-muted);
  font-size: 1rem;
}

.auth-alert {
  padding: 1rem 1.1rem;
  border-radius: 0.8rem;
  margin-bottom: 1.2rem;
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  font-size: 0.95rem;
  line-height: 1.5;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-alert svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 2px;
}

.auth-alert--error {
  background: #fef2f2;
  border: 1px solid #fee2e2;
  color: #991b1b;
}

.auth-alert--error svg {
  color: #dc2626;
}

.auth-alert--success {
  background: #f0fdf4;
  border: 1px solid #dcfce7;
  color: #166534;
}

.auth-alert--success svg {
  color: #16a34a;
}

.auth-form {
  margin-top: 1.8rem;
  display: grid;
  gap: 1.4rem;
}

.auth-form-group {
  display: grid;
  gap: 0.55rem;
  position: relative;
}

.auth-label-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.auth-form label {
  font-weight: 600;
  color: #1f3552;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.auth-label-text {
  display: block;
}

.auth-label-required {
  color: #dc2626;
  font-weight: 700;
  font-size: 1em;
  line-height: 1;
}

.auth-forgot-link {
  font-size: 0.82rem;
  color: #2d4f89;
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
  transition: color 0.25s ease, background 0.25s ease;
  padding: 0.25rem 0.6rem;
  border-radius: 0.4rem;
  text-transform: none;
  letter-spacing: normal;
}

.auth-forgot-link:hover {
  color: #2d6ee4;
  background: rgba(45, 110, 228, 0.08);
}

.auth-forgot-link:active {
  transform: scale(0.98);
}

.auth-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: #f8fafc;
  border: 1.5px solid #dde3ed;
  border-radius: 0.75rem;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
  overflow: hidden;
}

.auth-input-wrapper:hover {
  border-color: #b8c4d6;
  background: #f4f7fb;
}

.auth-input-wrapper:focus-within {
  border-color: #2d6ee4;
  background: #ffffff;
  box-shadow: 0 0 0 3.5px rgba(45, 110, 228, 0.1);
}

.auth-input-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: #4a6490;
  pointer-events: none;
  flex-shrink: 0;
  transition: color 0.25s ease, transform 0.25s ease;
  z-index: 3;
  opacity: 1;
  visibility: visible;
}

.auth-input-icon * {
  stroke: currentColor;
  stroke-width: 1.8;
}

.auth-input-wrapper:hover .auth-input-icon {
  color: #6b7fa0;
}

.auth-input-wrapper:focus-within .auth-input-icon {
  color: #2d6ee4;
  transform: translateY(-50%) scale(1.05);
}

.auth-form input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0.85rem 1rem 0.85rem 2.85rem;
  font: inherit;
  color: #0f1f35;
  font-size: 0.95rem;
  transition: color 0.25s ease;
}

.auth-form input::placeholder {
  color: #b5bcc9;
  font-weight: 400;
}

.auth-form input:focus {
  outline: none;
}

.auth-input-wrapper--password {
  padding-right: 0.5rem;
}

.auth-password-toggle {
  position: absolute;
  right: 0.7rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.45rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  transition: color 0.25s ease, background 0.25s ease;
  border-radius: 0.45rem;
  z-index: 3;
}

.auth-password-toggle:hover {
  color: #2d6ee4;
  background: rgba(45, 110, 228, 0.08);
}

.auth-password-toggle:active {
  transform: scale(0.95);
}

.auth-password-icon {
  width: 20px;
  height: 20px;
  display: none;
}

.auth-password-icon--hidden {
  display: block;
}

.auth-password-toggle.auth-password-toggle--visible .auth-password-icon--hidden {
  display: none;
}

.auth-password-toggle.auth-password-toggle--visible .auth-password-icon--visible {
  display: block;
}

.auth-submit {
  margin-top: 1rem;
  border: none;
  border-radius: 0.75rem;
  background: #072061;
  color: #ffffff;
  padding: 0.95rem 1.4rem;
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(7, 32, 97, 0.25);
  width: 100%;
  transition: background 0.25s ease, box-shadow 0.25s ease, transform 0.2s ease;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.auth-submit:hover {
  background: #0a2d7a;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(7, 32, 97, 0.3);
}

.auth-submit:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(7, 32, 97, 0.2);
}

.auth-submit-icon {
  width: 17px;
  height: 17px;
  transition: transform 0.25s ease;
}

.auth-submit:hover .auth-submit-icon {
  transform: translateX(3px);
}

button.is-loading {
  cursor: wait;
}

button.is-loading::after {
  content: "";
  width: 14px;
  height: 14px;
  margin-left: 0.5rem;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-top-color: currentColor;
  display: inline-block;
  animation: buttonSpinner 0.75s linear infinite;
}

button:disabled.is-loading {
  opacity: 0.96;
}

@keyframes buttonSpinner {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-login-footer {
  margin-top: 1.8rem;
  padding-top: 1.2rem;
  border-top: 2px solid #e5e7eb;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem;
  color: #1f3552;
  font-weight: 600;
  letter-spacing: 0.01em;
  opacity: 1;
  visibility: visible;
  animation: fadeInUp 0.6s ease-out 0.3s both;
}

.auth-login-footer span {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  opacity: 1;
  visibility: visible;
}

.auth-login-footer svg {
  width: 22px;
  height: 22px;
  color: #2d6ee4;
  flex-shrink: 0;
  stroke-width: 1.8;
  opacity: 1;
  visibility: visible;
  display: block;
}

.auth-bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 6px;
  background: var(--color-accent);
  z-index: 3;
}

/* ── Preloader ───────────────────────────────────────────────── */
.preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--color-primary-deep);
  display: grid;
  place-items: center;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.preloader--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}

.preloader__logo {
  width: 64px;
  height: 64px;
  border-radius: 0.85rem;
  background: linear-gradient(135deg, var(--color-accent), #e6a10d);
  color: #1a1a1a;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.8rem;
  font-family: "Sora", "Segoe UI", sans-serif;
  animation: preloaderPulse 1.8s ease-in-out infinite;
}

.preloader__spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: preloaderSpin 0.8s linear infinite;
}

.preloader__text {
  margin: 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

@keyframes preloaderSpin {
  to { transform: rotate(360deg); }
}

@keyframes preloaderPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

/* ── Auth Dark Mode ──────────────────────────────────────────── */
[data-theme="dark"] .auth-page {
  background: #0a0f1a;
}

[data-theme="dark"] .auth-right-panel {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

[data-theme="dark"] .auth-right-panel::before {
  background: radial-gradient(circle, rgba(74, 142, 222, 0.06) 0%, transparent 70%);
}

[data-theme="dark"] .auth-right-panel::after {
  background: radial-gradient(circle, rgba(243, 177, 26, 0.04) 0%, transparent 70%);
}

[data-theme="dark"] .auth-login-box {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .auth-login-header h1 {
  color: #e2e8f0;
}

[data-theme="dark"] .auth-login-header p {
  color: #94a3b8;
}

[data-theme="dark"] .auth-label-text {
  color: #cbd5e1;
}

[data-theme="dark"] .auth-input-wrapper {
  background: #0f172a;
  border-color: #334155;
}

[data-theme="dark"] .auth-input-wrapper:hover {
  border-color: #475569;
  background: #1a2332;
}

[data-theme="dark"] .auth-input-wrapper:focus-within {
  border-color: #4a8ede;
  background: #0f172a;
  box-shadow: 0 0 0 3.5px rgba(74, 142, 222, 0.15);
}

[data-theme="dark"] .auth-input-icon {
  color: #64748b;
}

[data-theme="dark"] .auth-input-wrapper:focus-within .auth-input-icon {
  color: #4a8ede;
}

[data-theme="dark"] .auth-form input {
  color: #e2e8f0;
}

[data-theme="dark"] .auth-form input::placeholder {
  color: #475569;
}

[data-theme="dark"] .auth-password-toggle {
  color: #64748b;
}

[data-theme="dark"] .auth-password-toggle:hover {
  color: #4a8ede;
  background: rgba(74, 142, 222, 0.1);
}

[data-theme="dark"] .auth-submit {
  background: #1e40af;
  box-shadow: 0 4px 14px rgba(30, 64, 175, 0.35);
}

[data-theme="dark"] .auth-submit:hover {
  background: #2563eb;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

[data-theme="dark"] .auth-forgot-link {
  color: #4a8ede;
}

[data-theme="dark"] .auth-login-footer {
  border-top-color: #334155;
  color: #94a3b8;
}

[data-theme="dark"] .auth-login-footer svg {
  color: #4a8ede;
}

[data-theme="dark"] .auth-alert--error {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

[data-theme="dark"] .auth-alert--success {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.25);
  color: #6ee7b7;
}

[data-theme="dark"] .auth-left-panel {
  background:
    linear-gradient(145deg, rgba(8, 18, 35, 0.9) 0%, rgba(10, 20, 40, 0.92) 58%, rgba(15, 40, 75, 0.9) 100%),
    url("../img/background_login.png") center/cover no-repeat;
}

[data-theme="dark"] .auth-bottom-bar,
[data-theme="dark"] .auth-page::before {
  background: var(--color-accent);
}

[data-theme="dark"] .auth-mobile-hero-wrapper {
  background: transparent;
}

[data-theme="dark"] .auth-mobile-identity-card {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

[data-theme="dark"] .auth-mobile-identity-text strong {
  color: #e2e8f0;
}

[data-theme="dark"] .auth-mobile-identity-text p {
  color: #94a3b8;
}

[data-theme="dark"] .auth-mobile-title {
  background: #0f172a;
  border-color: #334155;
}

[data-theme="dark"] .auth-mobile-app-name {
  color: #e2e8f0;
}

[data-theme="dark"] .auth-mobile-app-subtitle {
  color: #94a3b8;
}

[data-theme="dark"] .preloader {
  background: #060a14;
}

[data-theme="dark"] .preloader__spinner {
  border-color: rgba(255, 255, 255, 0.08);
  border-top-color: var(--color-accent);
}
