/* AmDi Fideliza — Estilos Nativos Autónomos con Soporte Modo Oscuro y Modo Claro */

:root {
  --primary-emerald: #10b981;
  --primary-hover: #059669;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  
  /* Valores por defecto: Modo Oscuro (Dark Theme) */
  --bg-main: #090d16;
  --bg-surface: #111827;
  --bg-card: #1f2937;
  --border-color: #374151;
  --text-primary: #f9fafb;
  --text-muted: #9ca3af;
  --input-bg: #090d16;
  --header-bg: #111827;
  --table-header: rgba(9, 13, 22, 0.8);
  --table-row-hover: rgba(17, 24, 39, 0.7);
  --card-gradient: radial-gradient(circle at top, #064e3b 0%, #022c22 100%);
}

/* Modo Claro (Light Theme) */
[data-theme="light"] {
  --bg-main: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-card: #f8fafc;
  --border-color: #cbd5e1;
  --text-primary: #0f172a;
  --text-muted: #64748b;
  --input-bg: #ffffff;
  --header-bg: #ffffff;
  --table-header: #e2e8f0;
  --table-row-hover: #f1f5f9;
  --card-gradient: radial-gradient(circle at top, #065f46 0%, #064e3b 100%);
}

/* Reglas de Modo Claro para Alto Contraste y Legibilidad (goAmdi.com) */
html[data-theme="light"],
html[data-theme="light"] body,
body[data-theme="light"] {
  background-color: #f1f5f9 !important;
  color: #0f172a !important;
}

[data-theme="light"] .fideliza-header {
  border-bottom-color: #cbd5e1 !important;
}

[data-theme="light"] .register-box {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.08) !important;
  color: #0f172a !important;
}

[data-theme="light"] .form-input {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

[data-theme="light"] .form-input::placeholder {
  color: #94a3b8 !important;
}

[data-theme="light"] .form-label {
  color: #475569 !important;
}

[data-theme="light"] .theme-toggle-btn,
[data-theme="light"] .header-btn {
  background: #e2e8f0 !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

[data-theme="light"] .status-pill {
  background: #ecfdf5 !important;
  color: #065f46 !important;
  border-color: #a7f3d0 !important;
}

[data-theme="light"] .hero-badge {
  background: #ecfdf5 !important;
  color: #065f46 !important;
  border-color: #a7f3d0 !important;
}

[data-theme="light"] .feature-item {
  color: #334155 !important;
}

[data-theme="light"] .request-card {
  background: #ffffff !important;
  border-color: #10b981 !important;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.15) !important;
}

[data-theme="light"] .reward-box {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}

[data-theme="light"] .brand-text {
  color: #475569 !important;
}

[data-theme="light"] .brand-text strong {
  color: #0f172a !important;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.25s ease, color 0.25s ease;
  overflow-x: hidden;
  max-width: 100vw;
}

/* Encabezados y barras */
.fideliza-header {
  width: 100%;
  max-width: 420px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 16px;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-emerald);
  font-size: 14px;
  overflow: hidden;
}

.brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-text {
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-pill {
  font-size: 11px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--primary-emerald);
  padding: 3px 10px;
  border-radius: 9999px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary-emerald);
}

/* Botón Interruptor Modo Claro / Modo Oscuro */
.theme-toggle-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
  border-color: var(--primary-emerald);
  transform: scale(1.05);
}

/* Contenedor principal de la tarjeta */
.fideliza-main {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
}

/* Caja de Formulario de Registro */
.register-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
  margin-top: 16px;
  text-align: left;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}

.form-input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--primary-emerald);
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #022c22;
  font-weight: 800;
  font-size: 15px;
  padding: 14px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.3);
  transition: transform 0.1s, opacity 0.2s;
}

.btn-primary:active {
  transform: scale(0.98);
}

/* Tarjeta de Fidelización (Estilo Móvil Moderno) */
.loyalty-card {
  position: relative;
  background-color: #064e3b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 28px;
  padding: 20px;
  box-shadow: 0 25px 35px -5px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  margin-bottom: 12px;
  color: #ffffff;
  transition: background-color 0.25s ease;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.card-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.card-logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  overflow: hidden;
}

.card-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-title {
  font-size: 17px;
  font-weight: 900;
  color: #ffffff;
  line-height: 1.2;
}

.card-subtitle {
  font-size: 12px;
  color: #6ee7b7;
  font-weight: 600;
}

/* Banner de Recompensa dentro de la Tarjeta */
.reward-banner {
  margin: 14px 0;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.reward-info-title {
  font-size: 10px;
  text-transform: uppercase;
  color: #34d399;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.reward-info-name {
  font-size: 15px;
  font-weight: 800;
  color: #ffffff;
}

/* Grilla de Sellos */
.stamps-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 700;
  color: #a7f3d0;
}

.stamps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stamp-slot {
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.4);
  font-size: 20px;
  transition: all 0.3s;
}

.stamp-slot.filled {
  background: #10b981;
  border-color: #6ee7b7;
  color: #022c22;
  box-shadow: 0 8px 16px rgba(16, 185, 129, 0.35);
  transform: scale(1.03);
}

.stamp-slot.prize-slot {
  border: 1px dashed #fbbf24;
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

.stamp-slot.prize-slot.filled {
  background: #f59e0b;
  border-color: #fde68a;
  color: #000000;
}

.stamp-num {
  font-size: 9px;
  font-weight: 900;
  margin-top: 4px;
}

/* Contenedor del QR del Cliente */
.qr-client-box {
  background: #ffffff;
  border-radius: 20px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #0f172a;
  text-align: center;
}

.qr-caption {
  font-size: 12px;
  font-weight: 800;
  color: #0f172a;
  margin-top: 8px;
}

.qr-phone {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
}

/* Barra de acciones inferior */
.card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 6px;
}

.action-link {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.action-link:hover {
  color: var(--primary-emerald);
}

.hidden {
  display: none !important;
}

/* =========================================================================
   SISTEMA DE MODALES PERSONALIZADOS (goAmdi.com)
   ========================================================================= */
.amdi-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(10, 15, 29, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.22s ease-out;
  overflow-y: auto;
}
.amdi-modal-backdrop.amdi-active {
  opacity: 1;
}
.amdi-modal-card {
  position: relative;
  width: 100%;
  max-width: min(420px, calc(100vw - 32px));
  max-height: 90vh;
  overflow-y: auto;
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 26px;
  padding: 24px 20px 20px;
  box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.05);
  transform: scale(0.92) translateY(12px);
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease-out;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  text-align: center;
}
[data-theme="light"] .amdi-modal-card {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  box-shadow: 0 30px 60px -12px rgba(15, 23, 42, 0.2), 0 0 0 1px rgba(15, 23, 42, 0.04);
}
.amdi-modal-backdrop.amdi-active .amdi-modal-card {
  transform: scale(1) translateY(0);
}
.amdi-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: all 0.2s;
  outline: none;
}
[data-theme="light"] .amdi-modal-close {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #64748b;
}
.amdi-modal-close:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}
[data-theme="light"] .amdi-modal-close:hover {
  background: #e2e8f0;
  color: #0f172a;
}
.amdi-modal-icon-badge {
  width: 68px;
  height: 68px;
  margin: 0 auto 16px;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.2s;
}
.amdi-modal-icon-badge.success {
  background: rgba(16, 185, 129, 0.16);
  border: 2px solid rgba(16, 185, 129, 0.45);
  color: #10b981;
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.3);
}
.amdi-modal-icon-badge.error {
  background: rgba(239, 68, 68, 0.16);
  border: 2px solid rgba(239, 68, 68, 0.45);
  color: #ef4444;
  box-shadow: 0 0 30px rgba(239, 68, 68, 0.3);
}
.amdi-modal-icon-badge.warning {
  background: rgba(245, 158, 11, 0.16);
  border: 2px solid rgba(245, 158, 11, 0.45);
  color: #f59e0b;
  box-shadow: 0 0 30px rgba(245, 158, 11, 0.3);
}
.amdi-modal-icon-badge.info {
  background: rgba(14, 165, 233, 0.16);
  border: 2px solid rgba(14, 165, 233, 0.45);
  color: #0ea5e9;
  box-shadow: 0 0 30px rgba(14, 165, 233, 0.3);
}
.amdi-modal-title {
  font-size: 19px;
  font-weight: 900;
  margin-bottom: 8px;
  letter-spacing: -0.015em;
  line-height: 1.25;
}
.amdi-modal-message {
  font-size: 14px;
  line-height: 1.55;
  color: #94a3b8;
  margin-bottom: 24px;
  word-break: break-word;
}
[data-theme="light"] .amdi-modal-message {
  color: #475569;
}
.amdi-modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.amdi-modal-btn {
  flex: 1;
  padding: 13px 20px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  border: none;
  transition: all 0.18s;
  outline: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.amdi-modal-btn:active {
  transform: scale(0.97);
}
.amdi-modal-btn-primary {
  background: #10b981;
  color: #022c22;
  box-shadow: 0 10px 22px -5px rgba(16, 185, 129, 0.38);
}
.amdi-modal-btn-primary:hover {
  background: #34d399;
}
.amdi-modal-btn-error {
  background: #ef4444;
  color: #ffffff;
  box-shadow: 0 10px 22px -5px rgba(239, 68, 68, 0.38);
}
.amdi-modal-btn-error:hover {
  background: #f87171;
}
.amdi-modal-footer-brand {
  margin-top: 16px;
  font-size: 11px;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
[data-theme="light"] .amdi-modal-footer-brand {
  color: #94a3b8;
}

@media (max-width: 480px) {
  .amdi-modal-card {
    padding: 20px 16px 18px;
    border-radius: 20px;
  }
  .amdi-modal-title {
    font-size: 17px;
  }
  .amdi-modal-message {
    font-size: 13px;
    margin-bottom: 20px;
  }
  .amdi-modal-actions {
    flex-direction: column-reverse;
    gap: 8px;
  }
  .amdi-modal-btn {
    width: 100%;
    padding: 12px 16px;
    font-size: 13px;
  }
}
