/**
 * Tabla I/O — Apple Action Sheets & Alert Dialogs (iOS HIG)
 */

/* ─── Backdrop Overlay ─────────────────────────────────────────────── */
.apple-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.22s;
}

.apple-dialog-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ─── Dialog Card ─────────────────────────────────────────────────── */
.apple-dialog-card {
  width: 100%;
  max-width: 360px;
  background: rgba(28, 28, 30, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.45), 0 4px 12px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.92);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  font-family: var(--font-system, -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif);
  color: #ffffff;
  box-sizing: border-box;
}

.apple-dialog-overlay.active .apple-dialog-card {
  transform: scale(1);
  opacity: 1;
}

/* ─── Theme Variants ──────────────────────────────────────────────── */
[data-theme="cream"] .apple-dialog-card {
  background: rgba(253, 248, 242, 0.96);
  border-color: rgba(180, 110, 50, 0.2);
  color: #2C1A0E;
  box-shadow: 0 20px 48px rgba(100, 60, 20, 0.18), 0 4px 12px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .apple-dialog-card {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(0, 0, 0, 0.12);
  color: #111111;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.16), 0 4px 12px rgba(0, 0, 0, 0.06);
}

/* ─── Content Section ─────────────────────────────────────────────── */
.apple-dialog-content {
  padding: 24px 22px 18px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.apple-dialog-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
  background: var(--accent-subtle, rgba(234, 101, 0, 0.12));
  color: var(--accent, #ea6500);
}

.apple-dialog-icon.is-destructive {
  background: rgba(255, 59, 48, 0.12);
  color: #FF3B30;
}

.apple-dialog-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.35;
}

.apple-dialog-message {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--text-secondary, #a0a0a5);
  white-space: pre-line;
}

[data-theme="cream"] .apple-dialog-message {
  color: #6B4A30;
}

[data-theme="light"] .apple-dialog-message {
  color: #555555;
}

/* ─── Buttons Section ─────────────────────────────────────────────── */
.apple-dialog-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 16px 16px;
}

.apple-dialog-btn {
  width: 100%;
  height: 42px;
  border-radius: 12px;
  border: none;
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, opacity 0.15s ease, background 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}

.apple-dialog-btn:active {
  transform: scale(0.97);
}

/* Confirm / Primary Button */
.apple-dialog-btn-primary {
  background: var(--accent, #ea6500);
  color: #ffffff;
}

.apple-dialog-btn-primary:hover {
  filter: brightness(1.06);
}

/* Destructive Button (Apple Red) */
.apple-dialog-btn-destructive {
  background: #FF3B30;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(255, 59, 48, 0.3);
}

.apple-dialog-btn-destructive:hover {
  background: #E0352B;
}

/* Cancel / Secondary Button */
.apple-dialog-btn-cancel {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary, #ffffff);
}

[data-theme="cream"] .apple-dialog-btn-cancel {
  background: rgba(180, 110, 50, 0.1);
  color: #2C1A0E;
}

[data-theme="light"] .apple-dialog-btn-cancel {
  background: rgba(0, 0, 0, 0.06);
  color: #111111;
}

.apple-dialog-btn-cancel:hover {
  background: rgba(255, 255, 255, 0.12);
}

[data-theme="cream"] .apple-dialog-btn-cancel:hover {
  background: rgba(180, 110, 50, 0.16);
}

[data-theme="light"] .apple-dialog-btn-cancel:hover {
  background: rgba(0, 0, 0, 0.1);
}

/* ─── Mobile Action Sheet (Slide up from bottom) ───────────────────── */
@media (max-width: 600px) {
  .apple-dialog-overlay {
    align-items: flex-end;
    padding: 0 12px calc(12px + env(safe-area-inset-bottom)) 12px;
  }

  .apple-dialog-card {
    max-width: 100%;
    border-radius: 24px;
    transform: translateY(100%);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  }

  .apple-dialog-overlay.active .apple-dialog-card {
    transform: translateY(0);
  }

  .apple-dialog-actions {
    gap: 10px;
    padding: 0 16px 16px;
  }

  .apple-dialog-btn {
    height: 46px;
    font-size: 0.98rem;
    border-radius: 14px;
  }
}

/* ─── Reduced Motion ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .apple-dialog-overlay,
  .apple-dialog-card,
  .apple-dialog-btn {
    transition: none !important;
    transform: none !important;
  }
}
