/* ============================================
   App-Confirm Widget — app-confirm.css
   Prefix: .ac-   |   Themes via data-ac-theme
   Match RomaID / recovery / auth surfaces
   ============================================ */

/* --- Theme tokens --- */

[data-ac-theme="login"] {
  --ac-bg: #202225;
  --ac-fg: #dcddde;
  --ac-muted: #8a8a8a;
  --ac-accent: #0f9af7;
  --ac-accent-hover: #0891ec;
  --ac-accent-soft: rgba(15, 154, 247, 0.12);
  --ac-border: #333;
  --ac-surface: rgba(255, 255, 255, 0.04);
  --ac-error: #ed4245;
  --ac-error-soft: rgba(237, 66, 69, 0.12);
  --ac-success: #3ba55d;
  --ac-success-soft: rgba(59, 165, 93, 0.14);
  --ac-warn: #f0a030;
  --ac-warn-soft: rgba(240, 160, 48, 0.14);
  --ac-radius: 4px;
  --ac-radius-lg: 8px;
  --ac-font: 'Poppins2', 'Poppins', sans-serif;
  --ac-focus: rgba(15, 154, 247, 0.35);
}

[data-ac-theme="recovery"] {
  --ac-bg: #1f1f1f;
  --ac-fg: #ffffff;
  --ac-muted: #b0b0b0;
  --ac-accent: #2194d8;
  --ac-accent-hover: #176ebd;
  --ac-accent-soft: rgba(33, 148, 216, 0.12);
  --ac-border: #333;
  --ac-surface: #2a2a2a;
  --ac-error: #ed4245;
  --ac-error-soft: rgba(237, 66, 69, 0.12);
  --ac-success: #28a745;
  --ac-success-soft: rgba(40, 167, 69, 0.14);
  --ac-warn: #f0a030;
  --ac-warn-soft: rgba(240, 160, 48, 0.14);
  --ac-radius: 12px;
  --ac-radius-lg: 12px;
  --ac-font: 'Poppins2', 'Poppins', sans-serif;
  --ac-focus: rgba(33, 148, 216, 0.25);
}

[data-ac-theme="auth"] {
  --ac-bg: var(--card-background, #1e1e1e);
  --ac-fg: var(--text-primary, #e0e0e0);
  --ac-muted: var(--text-secondary, #aaaaaa);
  --ac-accent: var(--button-background, #2a75f3);
  --ac-accent-hover: var(--button-hover, #5c97f5);
  --ac-accent-soft: rgba(42, 117, 243, 0.14);
  --ac-border: var(--border-color, #444444);
  --ac-surface: rgba(255, 255, 255, 0.04);
  --ac-error: #ed4245;
  --ac-error-soft: rgba(237, 66, 69, 0.12);
  --ac-success: #3ba55d;
  --ac-success-soft: rgba(59, 165, 93, 0.14);
  --ac-warn: #f0a030;
  --ac-warn-soft: rgba(240, 160, 48, 0.14);
  --ac-radius: 8px;
  --ac-radius-lg: 8px;
  --ac-font: 'Poppins2', 'Poppins', sans-serif;
  --ac-focus: var(--focus-color, rgba(66, 133, 244, 0.3));
}

/* --- Panel container --- */

.ac-panel {
  font-family: var(--ac-font);
  color: var(--ac-fg);
  text-align: center;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  box-sizing: border-box;
  padding: 8px 0 0 0;
  animation: ac-fadeIn 0.28s ease-out;
}

@keyframes ac-fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .ac-panel,
  .ac-icon-box,
  .ac-skeleton-icon,
  .ac-countdown-fill {
    animation: none !important;
    transition: none !important;
  }
}

/* --- Waiting: icon hero --- */

.ac-waiting-title {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ac-fg);
  margin: 0 0 16px 0;
}

.ac-icon-box {
  width: 96px;
  height: 96px;
  margin: 0 auto 12px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--ac-radius-lg);
  background: var(--ac-surface);
  border: 1px solid var(--ac-border);
  position: relative;
}

.ac-icon-box--waiting {
  animation: ac-iconPulse 2.4s ease-in-out infinite;
}

@keyframes ac-iconPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--ac-accent-soft); }
  50%      { box-shadow: 0 0 0 8px transparent; }
}

.ac-icon-box svg {
  width: 56px;
  height: 56px;
  fill: var(--ac-accent);
}

.ac-icon-label {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ac-fg);
  margin: 0 0 8px 0;
}

.ac-instruction {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ac-muted);
  margin: 0 auto 20px auto;
  max-width: 300px;
}

/* --- Countdown track --- */

.ac-countdown {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 0 0 20px 0;
}

.ac-countdown-meta {
  font-size: 13px;
  color: var(--ac-muted);
  font-variant-numeric: tabular-nums;
}

.ac-countdown-value {
  font-weight: 600;
  color: var(--ac-fg);
}

.ac-countdown-track {
  width: 100%;
  max-width: 220px;
  height: 4px;
  border-radius: 2px;
  background: var(--ac-surface);
  overflow: hidden;
  border: 1px solid var(--ac-border);
  box-sizing: border-box;
}

.ac-countdown-fill {
  height: 100%;
  width: 100%;
  border-radius: 2px;
  background: var(--ac-accent);
  transform-origin: left center;
  transition: transform 1s linear, background-color 0.2s ease;
  will-change: transform;
}

.ac-countdown--urgent .ac-countdown-value {
  color: var(--ac-warn);
}

.ac-countdown--urgent .ac-countdown-fill {
  background: var(--ac-warn);
}

/* --- Actions --- */

.ac-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}

.ac-actions--center {
  align-items: center;
}

.ac-btn-cancel,
.ac-btn-primary,
.ac-btn-secondary {
  font-family: var(--ac-font);
  cursor: pointer;
  box-sizing: border-box;
  text-align: center;
  text-decoration: none;
  appearance: none;
  -webkit-appearance: none;
}

.ac-btn-cancel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ac-muted);
  background: transparent;
  border: 1px solid var(--ac-border);
  border-radius: var(--ac-radius);
  transition: border-color 0.2s, color 0.2s, background-color 0.2s;
}

.ac-btn-cancel:hover {
  border-color: var(--ac-fg);
  color: var(--ac-fg);
  background: var(--ac-surface);
}

.ac-btn-cancel:active {
  transform: scale(0.98);
}

.ac-btn-cancel:focus-visible {
  outline: 2px solid var(--ac-accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--ac-focus);
}

.ac-btn-cancel:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.ac-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  min-width: 44px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background-color: var(--ac-accent);
  border: none;
  border-radius: var(--ac-radius);
  width: 100%;
  transition: background-color 0.2s, transform 0.1s;
}

.ac-btn-primary:hover {
  background-color: var(--ac-accent-hover);
}

.ac-btn-primary:active {
  transform: scale(0.98);
}

.ac-btn-primary:focus-visible {
  outline: 2px solid var(--ac-accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--ac-focus);
}

.ac-btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.ac-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  min-width: 44px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ac-accent);
  background: transparent;
  border: 1px solid var(--ac-accent);
  border-radius: var(--ac-radius);
  width: 100%;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.ac-btn-secondary:hover {
  background-color: var(--ac-accent-soft);
}

.ac-btn-secondary:active {
  transform: scale(0.98);
}

.ac-btn-secondary:focus-visible {
  outline: 2px solid var(--ac-accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--ac-focus);
}

.ac-btn-secondary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.ac-btn-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

/* --- Skeleton (loading) --- */

.ac-skeleton-icon {
  width: 96px;
  height: 96px;
  margin: 0 auto 12px auto;
  border-radius: var(--ac-radius-lg);
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 25%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.04) 75%
  );
  background-size: 200% 100%;
  animation: ac-shimmer 1.5s ease-in-out infinite;
  border: 1px solid var(--ac-border);
  box-sizing: border-box;
}

.ac-skeleton-label {
  width: 72px;
  height: 14px;
  margin: 0 auto 16px auto;
  border-radius: var(--ac-radius);
  background: rgba(255, 255, 255, 0.06);
}

.ac-skeleton-text {
  width: 80%;
  max-width: 280px;
  height: 12px;
  margin: 8px auto;
  border-radius: var(--ac-radius);
  background: rgba(255, 255, 255, 0.06);
}

.ac-skeleton-text--short {
  width: 48%;
}

@keyframes ac-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --- Result states --- */

.ac-result {
  padding: 16px 0 8px 0;
}

.ac-result-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px auto;
  border-radius: var(--ac-radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
}

.ac-result-icon svg {
  width: 28px;
  height: 28px;
}

.ac-result-icon--approved {
  background-color: var(--ac-success-soft);
  border-color: rgba(59, 165, 93, 0.28);
}

.ac-result-icon--approved svg {
  fill: var(--ac-success);
}

.ac-result-icon--rejected,
.ac-result-icon--error {
  background-color: var(--ac-error-soft);
  border-color: rgba(237, 66, 69, 0.28);
}

.ac-result-icon--rejected svg,
.ac-result-icon--error svg {
  fill: var(--ac-error);
}

.ac-result-icon--mismatch {
  background-color: var(--ac-warn-soft);
  border-color: rgba(240, 160, 48, 0.28);
}

.ac-result-icon--mismatch svg {
  fill: var(--ac-warn);
}

.ac-result-icon--expired,
.ac-result-icon--rate-limited {
  background-color: var(--ac-surface);
  border-color: var(--ac-border);
}

.ac-result-icon--expired svg,
.ac-result-icon--rate-limited svg {
  fill: var(--ac-muted);
}

.ac-result-title {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ac-fg);
  margin: 0 0 8px 0;
}

.ac-result-desc {
  font-size: 14px;
  color: var(--ac-muted);
  margin: 0 auto 20px auto;
  line-height: 1.5;
  max-width: 300px;
}

/* --- Method choice --- */

.ac-methods {
  width: 100%;
  margin-top: 8px;
}

.ac-methods-intro {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ac-muted);
  margin: 0 auto 20px auto;
  max-width: 300px;
}

.ac-methods .ac-actions {
  margin-top: 0;
}

/* --- Link (login_recover offer) --- */

.ac-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 4px 4px;
  font-family: var(--ac-font);
  font-size: 13px;
  font-weight: 500;
  color: var(--ac-accent, #0f9af7);
  text-decoration: none;
  cursor: pointer;
  border-radius: var(--ac-radius, 4px);
}

#ac-login-offer {
  margin-top: 12px;
  text-align: center;
}

.ac-link:hover {
  text-decoration: underline;
  color: var(--ac-accent-hover, #0891ec);
}

.ac-link:focus-visible {
  outline: 2px solid var(--ac-accent, #0f9af7);
  outline-offset: 2px;
}

/* --- Spacer --- */

.ac-spacer {
  height: 16px;
}

/* --- Visually hidden (a11y) --- */

.ac-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Password reset form --- */

.ac-reset-form {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  text-align: left;
}

.ac-reset-form .ac-input-group {
  margin-bottom: 16px;
}

.ac-reset-form label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ac-muted);
  margin-bottom: 8px;
}

.ac-reset-form input[type="password"] {
  width: 100%;
  box-sizing: border-box;
  min-height: 48px;
  padding: 12px 16px;
  background-color: var(--ac-surface);
  border: 2px solid var(--ac-border);
  border-radius: var(--ac-radius);
  color: var(--ac-fg);
  font-family: var(--ac-font);
  font-size: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ac-reset-form input[type="password"]:focus {
  border-color: var(--ac-accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--ac-focus);
}

.ac-reset-form input[type="password"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ac-reset-error {
  color: var(--ac-error);
  font-size: 13px;
  line-height: 1.4;
  margin: 0 0 12px 0;
  min-height: 18px;
}

/* --- Responsive --- */

@media (max-width: 480px) {
  .ac-panel {
    max-width: 100%;
    padding: 4px 0 0 0;
  }

  .ac-icon-box,
  .ac-skeleton-icon {
    width: 88px;
    height: 88px;
  }

  .ac-icon-box svg {
    width: 48px;
    height: 48px;
  }

  .ac-waiting-title,
  .ac-result-title {
    font-size: 17px;
  }

  .ac-btn-primary,
  .ac-btn-secondary {
    min-height: 48px;
  }
}
