/**
 * SOURX Margin Report - Authentication UI Stylesheet
 * Modern executive design system matching SOURX brand identity.
 */

/* Overlay complet de protection */
.auth-gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #012e5c;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
}

.auth-gate-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Carte de connexion */
.auth-card {
  width: 100%;
  max-width: 440px;
  background: #FFFFFF;
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.1);
  padding: 40px 36px;
  display: flex;
  flex-direction: column;
  animation: authCardIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

@keyframes authCardIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-card-top-accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: #012e5c;
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo {
  height: 38px;
  width: auto;
  margin-bottom: 16px;
  object-fit: contain;
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  color: #0F172A;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 13px;
  color: #64748B;
  line-height: 1.4;
}

.auth-badge-restricted {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 4px 10px;
  border-radius: 9999px;
  background: #FFF1F2;
  border: 1px solid #FECDD3;
  color: #E11D48;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.auth-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #E11D48;
}

/* Formulaire */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-label {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-icon {
  position: absolute;
  left: 14px;
  color: #94A3B8;
  pointer-events: none;
}

.auth-input {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 42px;
  border-radius: 10px;
  border: 1.5px solid #E2E8F0;
  background: #F8FAFC;
  font-size: 14px;
  color: #0F172A;
  font-family: inherit;
  transition: all 0.15s ease;
}

.auth-input:focus {
  outline: none;
  border-color: #012e5c;
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(1, 46, 92, 0.12);
}

.auth-input::placeholder {
  color: #94A3B8;
}

.auth-password-toggle {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: #64748B;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.15s;
}

.auth-password-toggle:hover {
  color: #012e5c;
}

/* Alert d'erreur */
.auth-error-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #FFF1F2;
  border: 1px solid #FECDD3;
  color: #BE123C;
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 4px;
}

.auth-error-alert.hidden {
  display: none;
}

/* Bouton de validation */
.auth-submit-btn {
  height: 46px;
  border-radius: 10px;
  background: #012e5c;
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
  box-shadow: 0 4px 12px rgba(1, 46, 92, 0.25);
  margin-top: 6px;
}

.auth-submit-btn:hover {
  background: #0a3d75;
  box-shadow: 0 6px 16px rgba(1, 46, 92, 0.35);
  transform: translateY(-1px);
}

.auth-submit-btn:active {
  transform: translateY(0);
}

.auth-submit-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

/* Footer d'information */
.auth-footer {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid #F1F5F9;
  text-align: center;
  font-size: 11px;
  color: #94A3B8;
  line-height: 1.5;
}

/* Spinner de chargement */
.auth-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #FFFFFF;
  animation: authSpin 0.7s linear infinite;
}

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

/* Sidebar Profile UI enrichie */
.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  margin: 8px 10px 10px;
  border-radius: 8px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.sidebar-user-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.user-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #012e5c;
  color: #FFFFFF;
  font-size: 11.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.03em;
}

.user-status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10B981;
  border: 1.5px solid #FFFFFF;
}

.user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: #0F172A;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0px 5px;
  border-radius: 4px;
  width: fit-content;
  margin-top: 1px;
}

.user-role-badge.role-admin {
  background: #FFFBEB;
  color: #B45309;
  border: 1px solid #FDE68A;
}

.user-role-badge.role-accountant {
  background: #F0F9FF;
  color: #0369A1;
  border: 1px solid #BAE6FD;
}

.user-role-badge.role-viewer {
  background: #F8FAFC;
  color: #475569;
  border: 1px solid #E2E8F0;
}

.btn-user-logout {
  background: none;
  border: none;
  color: #94A3B8;
  cursor: pointer;
  padding: 5px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background-color 0.15s ease;
  flex-shrink: 0;
}

.btn-user-logout:hover {
  background: #FFF1F2;
  color: #E11D48;
}

/* ==========================================================================
   Supabase Synchronization Status Indicator & Actions
   ========================================================================== */
.sync-status-badge-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.35;
  transition: all 0.15s ease;
  user-select: none;
}

.sync-pill svg {
  flex-shrink: 0;
}

/* 1. Enregistrement en cours */
.sync-pill.sync-saving {
  background: #FFFBEB;
  color: #B45309;
  border: 1px solid #FDE68A;
}

.sync-pill.sync-saving .sync-spinner {
  width: 10px;
  height: 10px;
  border: 1.5px solid rgba(180, 83, 9, 0.25);
  border-top-color: #B45309;
  border-radius: 50%;
  animation: authSpin 0.7s linear infinite;
}

/* 2. Synchronisé avec succès (Test) */
.sync-pill.sync-synced {
  background: #ECFDF5;
  color: #047857;
  border: 1px solid #A7F3D0;
}

.sync-pill.sync-synced .sync-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #10B981;
}

/* 3. Échec de sauvegarde */
.sync-pill.sync-failed {
  background: #FFF1F2;
  color: #BE123C;
  border: 1px solid #FECDD3;
}

.sync-pill.sync-failed .sync-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #E11D48;
}

/* 4. Local uniquement */
.sync-pill.sync-local {
  background: #F8FAFC;
  color: #475569;
  border: 1px solid #E2E8F0;
}

.sync-pill.sync-local .sync-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #64748B;
}

/* Boutons d'action compacts */
.btn-sync-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  background: #FFFFFF;
}

.btn-sync-action.btn-edit-fix {
  color: #B45309;
  border-color: #FDE68A;
  background: #FFFBEB;
}

.btn-sync-action.btn-edit-fix:hover {
  background: #FEF3C7;
  border-color: #FCD34D;
}

.btn-sync-action.btn-retry {
  color: #BE123C;
  border-color: #FECDD3;
  background: #FFF1F2;
}

.btn-sync-action.btn-retry:hover {
  background: #FFE4E6;
  border-color: #FDA4AF;
}

.btn-sync-action.btn-manual-sync {
  color: #0369A1;
  border-color: #BAE6FD;
  background: #F0F9FF;
}

.btn-sync-action.btn-manual-sync:hover {
  background: #E0F2FE;
  border-color: #7DD3FC;
}

/* Static Netlify Callout in Auth Card */
.auth-static-callout {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-static-callout.hidden {
  display: none !important;
}

.auth-static-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.auth-static-pill {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 9999px;
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FDE68A;
}

.auth-static-info {
  font-size: 11.5px;
  color: #64748B;
  font-weight: 500;
}

.auth-static-msg {
  font-size: 12.5px;
  color: #475569;
  line-height: 1.45;
  margin: 0;
}

.btn-auth-enter-test {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: #012e5c;
  color: #FFFFFF;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-auth-enter-test:hover {
  background: #002244;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(1, 46, 92, 0.2);
}

/* Persistent Test Mode Banner at top of main view */
.test-mode-banner {
  background: #FFFBEB;
  border-bottom: 1px solid #FCD34D;
  padding: 8px 24px;
  width: 100%;
  box-sizing: border-box;
}

.test-mode-banner-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1400px;
  margin: 0 auto;
}

.test-mode-banner-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.test-mode-banner-pill {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 9999px;
  background: #F59E0B;
  color: #FFFFFF;
}

.test-mode-banner-text {
  font-size: 12.5px;
  color: #78350F;
  line-height: 1.4;
}

.test-mode-banner-text code {
  background: #FEF3C7;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11.5px;
}

.btn-banner-storage-info {
  background: #FFFFFF;
  border: 1px solid #F59E0B;
  color: #92400E;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-banner-storage-info:hover {
  background: #FEF3C7;
}

