/**
 * Modal Component Styles - Heiwa Edition
 * Larger border radius (24px), softer shadows
 */

:root {
  --modal-overlay-bg: rgba(0, 0, 0, 0.4);
  --modal-bg: var(--bg-card, #ffffff);
  --modal-border-radius: var(--heiwa-radius-2xl, 24px);
  --modal-shadow: var(--heiwa-shadow-modal, 0 25px 50px -12px rgba(0, 0, 0, 0.15));
  --modal-header-border: var(--border-color, #e5e7eb);
  --modal-title-color: var(--text-primary, #1f2937);
  --modal-close-color: var(--text-muted, #6b7280);
  --modal-close-hover: var(--text-secondary, #374151);
  --modal-transition: var(--transition-slow, 0.3s ease);
}

/* Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--modal-overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--modal-transition), visibility var(--modal-transition);
  padding: 1rem;
}

.modal-overlay--visible {
  opacity: 1;
  visibility: visible;
}

/* Modal Container - Heiwa: 24px radius */
.modal {
  background: var(--modal-bg);
  border-radius: var(--modal-border-radius);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--modal-shadow);
  transform: scale(0.95);
  transition: transform var(--modal-transition);
}

.modal-overlay--visible .modal {
  transform: scale(1);
}

/* Size variants */
.modal--small {
  max-width: 400px;
}

.modal--medium {
  max-width: 600px;
}

.modal--large {
  max-width: 800px;
}

/* Header */
.modal__header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--modal-header-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal__title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--modal-title-color);
  margin: 0;
}

.modal__close {
  background: transparent;
  border: none;
  color: var(--modal-close-color);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;                           /* Heiwa: Circular close button */
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.modal__close:hover {
  background: #f3f4f6;
  color: var(--modal-close-hover);
}

.modal__close:focus {
  outline: 2px solid #00bcb4;                   /* Heiwa teal */
  outline-offset: 2px;
}

.modal__close svg {
  width: 20px;
  height: 20px;
}

/* Body */
.modal__body {
  padding: 1.5rem 2rem;
}

/* Footer (optional, added via content) */
.modal__footer {
  padding: 1rem 2rem 1.5rem;
  border-top: 1px solid var(--modal-header-border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* No Header variant - floating close button */
.modal--no-header .modal__header {
  position: absolute;
  top: 0;
  right: 0;
  border: none;
  padding: 1rem;
  background: transparent;
  z-index: 10;
}

.modal--no-header .modal__header .modal__title {
  display: none;
}

.modal--no-header .modal__close {
  width: 36px;
  height: 36px;
  background: #f3f4f6;
  border-radius: 50%;
}

.modal--no-header .modal__close:hover {
  background: #e5e7eb;
}

.modal--no-header {
  position: relative;
}

.modal--no-header .modal__body {
  padding-top: 2.5rem;
}

/* Common modal content patterns */
.modal__detail-group {
  margin-bottom: 1rem;
}

.modal__detail-group:last-child {
  margin-bottom: 0;
}

.modal__detail-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.modal__detail-value {
  font-size: 1rem;
  color: #1f2937;
  font-weight: 500;
}

.modal__actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.modal__actions--centered {
  justify-content: center;
}

.modal__actions--spread {
  justify-content: space-between;
}

/* ===== OTP Modal Styles ===== */
.otp-modal {
  text-align: center;
  padding: 1.5rem 2rem 1rem;
  max-width: 420px;
  margin: 0 auto;
}

.otp-modal__icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--heiwa-primary-light, #e0f7f6) 0%, #ccf5f3 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  position: relative;
}

.otp-modal__icon::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: var(--heiwa-primary, #00bcb4);
  opacity: 0.15;
  animation: otp-pulse 2s ease-out infinite;
}

@keyframes otp-pulse {
  0% { transform: scale(0.95); opacity: 0.15; }
  50% { transform: scale(1.05); opacity: 0.08; }
  100% { transform: scale(0.95); opacity: 0.15; }
}

.otp-modal__icon svg {
  width: 32px;
  height: 32px;
  color: var(--heiwa-primary, #00bcb4);
  position: relative;
  z-index: 1;
}

.otp-modal__title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary, #1f2937);
  margin: 0 0 0.5rem 0;
}

.otp-modal__subtitle {
  font-size: 0.9375rem;
  color: var(--text-secondary, #4b5563);
  margin: 0 0 0.25rem 0;
  line-height: 1.5;
}

.otp-modal__email {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary, #1f2937);
  margin: 0 0 2rem 0;
  word-break: break-word;
}

.otp-modal__input-wrapper {
  margin-bottom: 1.5rem;
}

.otp-modal__error {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--color-error-light, #fee2e2);
  color: var(--color-error-dark, #dc2626);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  margin-top: 1rem;
  animation: otp-shake 0.4s ease;
}

@keyframes otp-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.otp-modal__error svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.otp-modal__success {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--color-success-light, #d1fae5);
  color: var(--color-success-dark, #059669);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  margin-top: 1rem;
}

.otp-modal__success svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.otp-modal__divider {
  height: 1px;
  background: var(--border-color, #e5e7eb);
  margin: 1.5rem 0;
}

.otp-modal__resend {
  font-size: 0.875rem;
  color: var(--text-muted, #6b7280);
  margin: 0;
}

.otp-modal__resend-link {
  color: var(--heiwa-primary, #00bcb4);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.otp-modal__resend-link:hover {
  color: var(--heiwa-primary-hover, #00a39c);
  text-decoration: underline;
}

.otp-modal__resend-link--disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.otp-modal__timer {
  display: inline-block;
  font-size: 0.8125rem;
  color: var(--text-muted, #6b7280);
  font-weight: 500;
  margin-left: 0.25rem;
}

.otp-modal__help {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color, #e5e7eb);
}

.otp-modal__help-text {
  font-size: 0.8125rem;
  color: var(--text-muted, #6b7280);
  margin: 0;
}

.otp-modal__help-link {
  color: var(--heiwa-primary, #00bcb4);
  font-weight: 500;
  cursor: pointer;
}

/* OTP Modal Responsive */
@media (max-width: 480px) {
  .otp-modal {
    padding: 0.5rem 0 0;
  }

  .otp-modal__icon {
    width: 64px;
    height: 64px;
    margin-bottom: 1.25rem;
  }

  .otp-modal__icon svg {
    width: 28px;
    height: 28px;
  }

  .otp-modal__title {
    font-size: 1.25rem;
  }

  .otp-modal__subtitle,
  .otp-modal__email {
    font-size: 0.875rem;
  }

  .otp-modal__email {
    margin-bottom: 1.5rem;
  }

  .otp-modal__help {
    margin-top: 1rem;
    padding-top: 1rem;
  }

  .otp-modal__help-text {
    font-size: 0.75rem;
  }
}

/* Responsive */
@media (max-width: 640px) {
  .modal-overlay {
    padding: 0.5rem;
    align-items: flex-end;
  }

  .modal {
    max-width: 100%;
    border-radius: 24px 24px 0 0;               /* Heiwa: Larger radius on mobile */
    max-height: 95vh;
  }

  .modal__header {
    padding: 1.25rem 1.5rem;
  }

  .modal__title {
    font-size: 1.125rem;
  }

  .modal__body {
    padding: 1.25rem 1.5rem;
  }

  .modal__actions {
    flex-direction: column;
  }
}

/* Print styles */
@media print {
  .modal-overlay {
    display: none;
  }
}

/* ===== Dark Mode ===== */
html.dark-mode .modal-overlay {
  background: rgba(0, 0, 0, 0.7);
}

html.dark-mode .modal-content {
  background: #1a1f26;
  border-color: #2d3640;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

html.dark-mode .modal-header {
  border-bottom-color: #2d3640;
}

html.dark-mode .modal-title {
  color: #f5f5f5;
}

html.dark-mode .modal-close {
  color: #a8b2bd;
}

html.dark-mode .modal-close:hover {
  color: #f5f5f5;
  background: #242b33;
}

html.dark-mode .modal-body {
  color: #a8b2bd;
}

html.dark-mode .modal-footer {
  border-top-color: #2d3640;
}
