/* ==========================================================================
   Composant Alerts, Toasts & Bannières
   Design System Standardisé - Kiosk Manager
   ========================================================================== */

/* Structure de base pour les alertes en ligne (.alert) */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  line-height: 1.45;
  opacity: var(--alert-opacity, 1);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  box-sizing: border-box;
}

.alert-icon {
  font-size: 16px;
  line-height: 1.2;
  flex-shrink: 0;
}

.alert-content {
  flex: 1 1 auto;
  min-width: 0;
}

.alert-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 2px;
}

.alert-desc {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.9;
}

/* Typologies d'alertes */
.alert--success {
  background-color: var(--alert-success-bg);
  border-color: var(--alert-success-border);
  color: var(--alert-success-text);
}

.alert--warning {
  background-color: var(--alert-warning-bg);
  border-color: var(--alert-warning-border);
  color: var(--alert-warning-text);
}

.alert--error {
  background-color: var(--alert-error-bg);
  border-color: var(--alert-error-border);
  color: var(--alert-error-text);
}

.alert--info {
  background-color: var(--alert-info-bg);
  border-color: var(--alert-info-border);
  color: var(--alert-info-text);
}

/* ==========================================================================
   Bannière d'avertissement intégrée dans les onglets (.editor-unsaved-banner)
   ========================================================================== */
.editor-unsaved-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  opacity: var(--alert-opacity, 1);
  background-color: var(--alert-warning-bg);
  border: 1px solid var(--alert-warning-border);
  color: var(--alert-warning-text);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
}

.editor-unsaved-banner::before {
  content: '⚠️';
  font-size: 15px;
  flex-shrink: 0;
}

/* ==========================================================================
   Toasts flottants au centre (.admin-toast-stack / .admin-toast)
   ========================================================================== */
.admin-toast-stack {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 140;
  display: grid;
  gap: 8px;
  width: min(430px, calc(100vw - 36px));
  justify-items: center;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.admin-toast-stack.admin-toast-stack--bottom {
  top: auto;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 300;
}

.admin-toast {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--alert-success-border);
  border-radius: 8px;
  padding: 10px 14px 10px 18px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22), 0 2px 6px rgba(0, 0, 0, 0.08);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.4;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(16px);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.admin-toast.is-visible {
  opacity: var(--alert-opacity, 1) !important;
  transform: translateY(0);
}

.admin-toast.is-hiding {
  opacity: 0 !important;
  transform: translateY(-12px) !important;
  pointer-events: none;
}

.admin-toast-text {
  flex: 1 1 auto;
  text-align: left;
}

.admin-toast-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: inherit;
  opacity: 0.65;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.admin-toast-close:hover,
.admin-toast-close:focus {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.08);
  transform: scale(1.1);
}

:root[data-theme="dark"] .admin-toast-close:hover {
  background-color: rgba(255, 255, 255, 0.12);
}

.admin-toast-success {
  background: var(--alert-success-bg);
  border-color: var(--alert-success-border);
  color: var(--alert-success-text);
}

.admin-toast-warning {
  background: var(--alert-warning-bg);
  border-color: var(--alert-warning-border);
  color: var(--alert-warning-text);
}

.admin-toast-info {
  background: var(--alert-info-bg);
  border-color: var(--alert-info-border);
  color: var(--alert-info-text);
}

.admin-toast-error {
  background: var(--alert-error-bg);
  border-color: var(--alert-error-border);
  color: var(--alert-error-text);
}

/* ==========================================================================
   Bannière Flottante Haute / Pilule (.top-notice)
   Utilisée pour les notifications globales d'en-tête (connexion, statuts de page)
   ========================================================================== */
.top-notice {
  position: fixed;
  top: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(-22px);
  z-index: 250;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: max-content;
  max-width: min(calc(100vw - 32px), 560px);
  box-sizing: border-box;
  padding: 10px 18px 10px 24px;
  border-radius: 9999px;
  border: 1px solid var(--alert-warning-border);
  background: var(--alert-warning-bg);
  color: var(--alert-warning-text);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.45;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  backdrop-filter: blur(14px) saturate(180%);
  transition: opacity 0.42s ease, transform 0.42s ease;
}

@media (max-width: 600px) {
  .top-notice {
    white-space: normal;
    width: min(calc(100vw - 32px), 560px);
    padding: 10px 16px;
  }
}

.top-notice[hidden] {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.top-notice.is-visible {
  opacity: var(--alert-opacity, 1);
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.top-notice.is-hiding {
  opacity: 0;
  transform: translateX(-50%) translateY(-18px);
  pointer-events: none;
}

.top-notice--warning {
  border-color: var(--alert-warning-border);
  background: var(--alert-warning-bg);
  color: var(--alert-warning-text);
}

.top-notice--success {
  border-color: var(--alert-success-border);
  background: var(--alert-success-bg);
  color: var(--alert-success-text);
}

.top-notice--info {
  border-color: var(--alert-info-border);
  background: var(--alert-info-bg);
  color: var(--alert-info-text);
}

.top-notice--error {
  border-color: var(--alert-error-border);
  background: var(--alert-error-bg);
  color: var(--alert-error-text);
}

.top-notice-text {
  flex: 1 1 auto;
  text-align: center;
}

.top-notice-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: inherit;
  opacity: 0.65;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.top-notice-close:hover,
.top-notice-close:focus {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.08);
  transform: scale(1.1);
}

:root[data-theme="dark"] .top-notice-close:hover,
:root[data-theme="dark"] .top-notice-close:focus {
  background-color: rgba(255, 255, 255, 0.14);
}

/* ==========================================================================
   Alerte / Bannière flottante basse (.footer-notice)
   ========================================================================== */
.footer-notice,
.screen-editor-unsaved-notice {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(560px, calc(100vw - 32px));
  box-sizing: border-box;
  padding: 12px 18px;
  background: var(--alert-warning-bg);
  border: 1px solid var(--alert-warning-border);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  color: var(--alert-warning-text);
  opacity: 0;
  pointer-events: none;
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.footer-notice[hidden],
.screen-editor-unsaved-notice[hidden] {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.footer-notice.is-visible,
.screen-editor-unsaved-notice.is-visible {
  opacity: var(--alert-opacity, 1);
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.footer-notice.is-hiding,
.screen-editor-unsaved-notice.is-hiding {
  opacity: 0;
  transform: translateX(-50%) translateY(16px);
  pointer-events: none;
}

.footer-notice,
.footer-notice--warning,
.screen-editor-unsaved-notice {
  background: var(--alert-warning-bg);
  border-color: var(--alert-warning-border);
  color: var(--alert-warning-text);
}

.footer-notice--warning .footer-notice-text,
.screen-editor-unsaved-notice .footer-notice-text,
.screen-editor-unsaved-notice-text {
  color: var(--alert-warning-text);
}

.footer-notice--success {
  background: var(--alert-success-bg);
  border-color: var(--alert-success-border);
  color: var(--alert-success-text);
}

.footer-notice--success .footer-notice-text {
  color: var(--alert-success-text);
}

.footer-notice--success .footer-notice-close {
  color: var(--alert-success-text);
}

.footer-notice--error,
.screen-editor-unsaved-notice--error {
  background: var(--alert-error-bg);
  border-color: var(--alert-error-border);
  color: var(--alert-error-text);
}

.footer-notice--error .footer-notice-text,
.footer-notice--error .screen-editor-unsaved-notice-text,
.screen-editor-unsaved-notice--error .footer-notice-text,
.screen-editor-unsaved-notice--error .screen-editor-unsaved-notice-text {
  color: var(--alert-error-text);
}

.footer-notice--error .footer-notice-close,
.footer-notice--error .screen-editor-unsaved-notice-close,
.screen-editor-unsaved-notice--error .footer-notice-close,
.screen-editor-unsaved-notice--error .screen-editor-unsaved-notice-close {
  color: var(--alert-error-text);
}

.footer-notice-text,
.screen-editor-unsaved-notice-text {
  font-size: 13px;
  line-height: 1.45;
  font-weight: 400;
  flex: 1 1 auto;
}

.footer-notice-title,
.screen-editor-unsaved-notice-title {
  display: block;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 2px;
}

.footer-notice-hint,
.screen-editor-unsaved-notice-hint {
  display: block;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.85;
  margin-top: 2px;
}

.footer-notice-close,
.screen-editor-unsaved-notice-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: inherit;
  opacity: 0.65;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.footer-notice-close:hover,
.footer-notice-close:focus,
.screen-editor-unsaved-notice-close:hover,
.screen-editor-unsaved-notice-close:focus {
  opacity: 1;
  background: rgba(0, 0, 0, 0.08);
  transform: scale(1.1);
}

:root[data-theme="dark"] .footer-notice-close:hover,
:root[data-theme="dark"] .screen-editor-unsaved-notice-close:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* ==========================================================================
   Design System - Bannière flottante de tâche progressive (.task-progress-banner)
   Utilisée pour les tâches longues asynchrones (capture d'URL, confirmation, etc.)
   Centrée à l'écran avec rideau d'arrière-plan semi-transparent et flouté (.task-progress-backdrop),
   hauteur confortable, typographie aérée et transitions fluides.
   ========================================================================== */

.task-progress-backdrop {
  position: fixed;
  inset: 0;
  z-index: 145;
  background: rgba(15, 23, 42, 0.38);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.task-progress-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.task-progress-banner,
.capture-progress-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  z-index: 150;
  width: min(460px, calc(100vw - 36px));
  background: var(--panel);
  border: 1px solid var(--alert-info-border);
  border-radius: var(--panel-radius, 14px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.32), 0 4px 16px rgba(0, 0, 0, 0.12);
  padding: 24px 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 140px;
  opacity: 0;
  pointer-events: none;
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.task-progress-banner.is-visible,
.capture-progress-banner.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.task-progress-banner.is-hiding,
.capture-progress-banner.is-hiding {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.95);
  pointer-events: none;
}

.task-progress-header,
.capture-progress-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.task-progress-icon,
.capture-progress-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--alert-info-bg);
  border: 1.5px solid var(--alert-info-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.task-progress-icon svg,
.capture-progress-icon svg {
  width: 16px;
  height: 16px;
  color: var(--alert-info-icon);
  animation: task-progress-spin 1.1s linear infinite;
}

@keyframes task-progress-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.task-progress-text,
.capture-progress-text {
  flex: 1 1 auto;
  min-width: 0;
}

.task-progress-title,
.capture-progress-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  line-height: 1.4;
  white-space: normal;
  word-break: break-word;
}

.task-progress-subtitle,
.capture-progress-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.5;
  white-space: normal;
  word-break: break-word;
}

.task-progress-actions .task-progress-btn {
  font-size: 13.5px;
  padding: 8px 18px;
}

.task-progress-track,
.capture-progress-track {
  height: 6px;
  background: color-mix(in srgb, var(--alert-info-border) 40%, transparent);
  border-radius: 999px;
  overflow: hidden;
}

.task-progress-bar,
.capture-progress-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--alert-info-icon, #2563eb);
  width: 0%;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.task-progress-footer,
.capture-progress-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.task-progress-elapsed,
.capture-progress-elapsed {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.task-progress-cancel,
.capture-progress-cancel {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  line-height: 1.4;
}

.task-progress-cancel:hover,
.capture-progress-cancel:hover {
  background: color-mix(in srgb, var(--danger, #dc2626) 12%, transparent);
  border-color: var(--danger, #dc2626);
  color: var(--danger, #dc2626);
}

/* Actions et boutons du bandeau de confirmation de mise à jour */
.task-progress-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.task-progress-btn {
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--soft, rgba(0, 0, 0, 0.05));
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.35;
}

.task-progress-btn:hover {
  filter: brightness(1.08);
  border-color: color-mix(in srgb, var(--border) 70%, var(--text));
}

.task-progress-btn--primary {
  background: var(--alert-info-icon, #2563eb);
  border-color: var(--alert-info-icon, #2563eb);
  color: #ffffff;
}

.task-progress-btn--primary:hover {
  background: color-mix(in srgb, var(--alert-info-icon, #2563eb) 85%, #000);
  border-color: color-mix(in srgb, var(--alert-info-icon, #2563eb) 85%, #000);
}

.task-progress-btn--secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.task-progress-btn--secondary:hover {
  background: color-mix(in srgb, var(--text) 6%, transparent);
  color: var(--text);
}

/* Pastille / Badge d'avertissement sur l'aperçu quand l'URL a été modifiée sans mise à jour */
.url-preview-stale-badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(245, 158, 11, 0.6);
  border-radius: 6px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  line-height: 1.25;
  color: #fef3c7;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 4;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.url-preview-stale-badge[hidden] {
  display: none !important;
}

.url-preview-stale-emoji {
  font-size: 13px;
  flex-shrink: 0;
}

.url-preview-stale-text {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Avertissement sous l'image d'aperçu d'URL quand elle n'est pas à jour */
.url-preview-stale-notice {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: #d97706;
  line-height: 1.35;
  box-sizing: border-box;
  width: max-content;
  max-width: 100%;
}

:root[data-theme="dark"] .url-preview-stale-notice {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.5);
  color: #fde68a;
}

.url-preview-stale-notice[hidden] {
  display: none !important;
}

.url-preview-stale-icon {
  font-size: 13px;
  flex-shrink: 0;
}

.url-preview-stale-label {
  white-space: normal;
  word-break: break-word;
}
