/**
 * Estilos para Generador de Tarjeta Médica de Emergencia SOS (fijate.com)
 * Tarjeta de cartera recortable (85x54 mm), mockup de smartphone y @media print
 */

:root {
  --bg-primary: #0f172a;
  --bg-card: #1e293b;
  --bg-card-subtle: #182234;
  --bg-input: #0b1120;
  --border-color: #334155;
  --border-color-hover: #475569;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-primary: #dc2626;
  --accent-hover: #b91c1c;
  --accent-glow: rgba(220, 38, 38, 0.2);
  --color-danger: #ef4444;
  --color-blood: #b91c1c;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
}

[data-theme="light"], body.light-theme {
  --bg-primary: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #cbd5e1;
  --border-color-hover: #94a3b8;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent-primary: #dc2626;
  --accent-hover: #b91c1c;
  --accent-glow: rgba(220, 38, 38, 0.15);
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
}

.mono-num {
  font-family: 'JetBrains Mono', monospace;
}

.tool-layout {
  max-width: 1200px;
  width: 100%;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  flex: 1 0 auto;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.card-main {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

.card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.card-title {
  font-size: 1.35rem;
  margin-bottom: 0.25rem;
}

.card-desc {
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.form-section-subtitle {
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.35rem;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-private {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Formularios */
.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
}

.input-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.label-danger {
  color: #ef4444 !important;
}

.form-input {
  width: 100%;
  height: 44px;
  padding: 0 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.border-danger {
  border-color: rgba(239, 68, 68, 0.6) !important;
}

.border-danger:focus {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25) !important;
}

.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 40px 0 0.85rem;
  background-color: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.form-select option {
  background-color: var(--bg-card);
  color: var(--text-primary);
}

.input-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
}

/* Tabs */
.card-tabs-section {
  padding: 0;
  overflow: hidden;
}

.tabs-nav-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card-subtle);
  padding: 0 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.tabs-nav {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  white-space: nowrap;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.9rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.tabs-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

.btn-action-sm {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-action-sm:hover { background: var(--border-color); }
.btn-accent-action {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}
.btn-accent-action:hover {
  background: var(--accent-hover);
}

.tab-pane {
  display: none;
  padding: 1.5rem;
}

.tab-pane.active { display: block; }

.wallet-instructions, .wallpaper-intro {
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Tarjeta física para cartera (85x54 mm) */
.wallet-card-printable-wrap {
  display: flex;
  gap: 2rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  padding: 1.5rem 0;
}

.wallet-card-face {
  width: 350px;
  height: 220px;
  border-radius: 12px;
  border: 2px solid #b91c1c;
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Anverso */
.card-front .card-header-badge {
  background: linear-gradient(135deg, #b91c1c, #991b1b);
  color: #ffffff;
  padding: 0.45rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.star-of-life {
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-header-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}

.card-sup {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  opacity: 0.9;
}

.card-main-title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.blood-badge {
  background: #ffffff;
  color: #991b1b;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  font-weight: 900;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid #7f1d1d;
}

.card-body-info {
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: space-between;
}

.card-patient-name {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
}

.card-meta-line {
  font-size: 0.65rem;
  color: #64748b;
  margin-bottom: 0.25rem;
}

.card-danger-strip {
  background: #fef2f2;
  border: 1px solid #f87171;
  border-radius: 4px;
  padding: 0.2rem 0.4rem;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.strip-label {
  font-size: 0.55rem;
  font-weight: 800;
  color: #b91c1c;
}

.strip-val {
  font-size: 0.7rem;
  font-weight: 800;
  color: #991b1b;
}

.card-key-fields {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.2rem;
}

.key-field {
  display: flex;
  font-size: 0.68rem;
  line-height: 1.2;
}

.kf-label {
  font-weight: 700;
  color: #475569;
  width: 105px;
  flex-shrink: 0;
}

.kf-val {
  color: #0f172a;
  font-weight: 600;
}

.card-sos-contacts {
  background: #f8fafc;
  border-top: 1px dashed #cbd5e1;
  padding-top: 0.25rem;
  margin-top: 0.25rem;
}

.sos-label {
  font-size: 0.55rem;
  font-weight: 800;
  color: #dc2626;
  display: block;
}

.sos-phones {
  font-size: 0.68rem;
  font-weight: 700;
  color: #0f172a;
}

/* Reverso de la tarjeta */
.card-back {
  border-color: #475569;
}

.card-back-header {
  background: #334155;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
  text-align: center;
  padding: 0.3rem 0;
  letter-spacing: 0.04em;
}

.card-back-content {
  display: flex;
  padding: 0.6rem;
  gap: 0.6rem;
  flex: 1;
}

.card-qr-box {
  width: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.card-qr-box canvas {
  width: 85px;
  height: 85px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
}

.qr-caption {
  font-size: 0.52rem;
  color: #64748b;
  margin-top: 0.25rem;
  line-height: 1.1;
}

.card-back-notes {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 0.68rem;
}

.back-instruction strong {
  color: #0f172a;
  display: block;
  margin-bottom: 0.15rem;
}

.back-instruction p {
  color: #334155;
  line-height: 1.25;
}

.back-footer-legal {
  border-top: 1px solid #e2e8f0;
  padding-top: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.disclaimer {
  font-size: 0.52rem;
  color: #94a3b8;
}

/* Mockup de teléfono móvil para fondo de pantalla */
.wallpaper-preview-wrapper {
  display: flex;
  gap: 2.5rem;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
}

.phone-frame-mockup {
  width: 280px;
  height: 560px;
  border-radius: 36px;
  border: 7px solid #1e293b;
  background: #090d16;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.25rem 0.85rem;
  color: #ffffff;
}

.phone-speaker {
  width: 60px;
  height: 5px;
  background: #334155;
  border-radius: 3px;
  align-self: center;
  margin-bottom: 0.5rem;
}

.phone-clock-area {
  text-align: center;
  margin-top: 0.5rem;
}

.phone-clock {
  font-family: 'Inter', sans-serif;
  font-size: 2.8rem;
  font-weight: 300;
  line-height: 1;
}

.phone-date {
  font-size: 0.78rem;
  color: #cbd5e1;
  margin-top: 0.25rem;
}

.phone-emergency-card-overlay {
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(8px);
  border: 1.5px solid #dc2626;
  border-radius: 16px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  box-shadow: 0 4px 15px rgba(220, 38, 38, 0.3);
}

.phone-sos-badge {
  background: #dc2626;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  align-self: flex-start;
  letter-spacing: 0.03em;
}

.phone-patient-name {
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  color: #ffffff;
}

.phone-patient-blood {
  font-size: 0.72rem;
  color: #fca5a5;
}

.phone-alert-box {
  background: rgba(220, 38, 38, 0.2);
  border-left: 3px solid #ef4444;
  padding: 0.25rem 0.4rem;
  font-size: 0.66rem;
  line-height: 1.2;
}

.phone-alert-box strong {
  color: #f87171;
}

.phone-med-box {
  font-size: 0.66rem;
  color: #cbd5e1;
  line-height: 1.2;
}

.phone-contacts-box {
  border-top: 1px dashed rgba(255, 255, 255, 0.2);
  padding-top: 0.25rem;
  font-size: 0.68rem;
}

.phone-sos-title {
  font-size: 0.58rem;
  font-weight: 800;
  color: #f87171;
  display: block;
}

.phone-qr-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.2rem;
  padding-top: 0.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.phone-qr-area canvas {
  width: 44px;
  height: 44px;
  border-radius: 4px;
  background: #ffffff;
  padding: 2px;
}

.phone-qr-area span {
  font-size: 0.6rem;
  color: #94a3b8;
}

.wallpaper-export-sidebar {
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.wallpaper-steps {
  padding-left: 1.2rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.wallpaper-canvas-hidden {
  display: none;
}

/* FAQ */
.faq-section { margin-top: 1rem; }
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card-subtle);
  padding: 0.85rem 1.15rem;
}

.faq-question {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  cursor: pointer;
}

.faq-answer {
  margin-top: 0.6rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Modales */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
  backdrop-filter: blur(4px);
}

.modal-overlay.active { display: flex; }

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  max-width: 480px;
  width: 100%;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
}

.modal-body {
  padding: 1.25rem;
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background: var(--bg-card-subtle);
  border-top: 1px solid var(--border-color);
}

/* Responsive */
@media (max-width: 768px) {
  .form-grid-3, .form-grid-2 {
    grid-template-columns: 1fr;
  }
  .form-actions .btn {
    width: 100%;
  }
  .wallet-card-printable-wrap {
    flex-direction: column;
  }
}

/* @media print para tarjeta recortable A4 */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .app-header,
  .fijate-footer,
  .tool-ad-sidebar,
  .tools-ad-banner-section,
  .form-sos,
  .tabs-nav-wrapper,
  .wallet-instructions,
  .faq-section,
  #tab-movil {
    display: none !important;
  }
  .tool-layout {
    margin: 0 !important;
    padding: 0 !important;
  }
  .card-main {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .tab-pane {
    display: block !important;
    padding: 0 !important;
  }
  .wallet-card-printable-wrap {
    display: flex !important;
    flex-direction: row !important;
    gap: 0 !important;
    justify-content: center !important;
    margin-top: 40px !important;
  }
  .wallet-card-face {
    width: 85mm !important;
    height: 54mm !important;
    border: 1px dashed #444 !important;
    box-shadow: none !important;
    page-break-inside: avoid !important;
  }
  .card-front {
    border-right: 1px dashed #999 !important;
  }
}
