/* ─────────────────────────────────────────
   DESIGN TOKENS
───────────────────────────────────────── */
:root {
  --blue-950: #0B1F4A;
  --blue-900: #1E3A8A;
  --blue-700: #1D4ED8;
  --blue-600: #2563EB;
  --blue-500: #3B82F6;
  --blue-50:  #EFF6FF;
  --teal-600: #0D9488;
  --teal-500: #14B8A6;
  --teal-400: #2DD4BF;
  --gray-900: #111827;
  --gray-700: #374151;
  --gray-600: #4B5563;
  --gray-500: #6B7280;
  --gray-400: #9CA3AF;
  --gray-300: #D1D5DB;
  --gray-200: #E5E7EB;
  --gray-100: #F3F4F6;
  --gray-50:  #F9FAFB;
  --white:    #FFFFFF;
  --radius:   12px;
  --radius-lg:20px;
  --shadow:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-lg:0 10px 40px rgba(0,0,0,.12);
}

/* ─────────────────────────────────────────
   RESET & BASE
───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Poppins', sans-serif;
  color: var(--gray-900);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.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;
}

/* ─────────────────────────────────────────
   PANEL IZQUIERDO
───────────────────────────────────────── */
.left-panel {
  width: 580px;
  min-width: 580px;
  background: var(--white);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: relative;
  z-index: 1;
  box-shadow: 4px 0 24px rgba(0,0,0,.06);
}

/* App bar */
.app-bar {
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--gray-100);
  flex-shrink: 0;
}
.app-bar-logo img { height: 2rem; width: auto; display: block; }
.app-bar-back {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .78rem; font-weight: 600; color: var(--gray-500);
  text-decoration: none;
  padding: .35rem .7rem;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  transition: all .2s;
}
.app-bar-back:hover { color: var(--blue-600); border-color: #93C5FD; background: var(--blue-50); }

/* Content */
.left-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2.5rem 2rem;
  padding-top: 1rem;
}

/* Intro */
.app-intro { margin-bottom: 2rem; }
.app-intro-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--blue-50); color: var(--blue-700);
  font-size: .7rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; padding: .3rem .85rem;
  border-radius: 99px; margin-bottom: 1rem;
}
.app-intro h1 {
  font-size: 1.6rem; font-weight: 800;
  color: var(--gray-900); letter-spacing: -.025em;
  margin-bottom: .45rem; line-height: 1.2;
}
.app-intro p { font-size: .85rem; color: var(--gray-500); line-height: 1.6; }

/* Form */
.query-label {
  font-size: .75rem; font-weight: 700;
  color: var(--gray-700); margin-bottom: .45rem;
  display: block; letter-spacing: .03em;
}
.query-fieldset { border: none; padding: 0; margin: 0; }
.query-input-group { display: flex; gap: .5rem; margin-bottom: 1.1rem; }
.query-challenge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: .5rem .85rem;
  margin-bottom: .65rem;
}
.captcha-img {
  flex: 1;
  height: 52px;
  border-radius: 4px;
  object-fit: contain;
  display: block;
}
.query-challenge-text {
  font-size: .82rem;
  font-weight: 600;
  color: var(--gray-700);
}
.query-challenge-refresh {
  border: 1px solid var(--gray-300);
  background: var(--white);
  color: var(--blue-700);
  border-radius: 999px;
  padding: .3rem .75rem;
  font-family: 'Poppins', sans-serif;
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}
.query-challenge-refresh:hover {
  border-color: #93C5FD;
  background: var(--blue-50);
}
.query-select {
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: .7rem .85rem;
  font-family: 'Poppins', sans-serif;
  font-size: .88rem; font-weight: 600; color: var(--gray-700);
  cursor: pointer; outline: none;
  transition: border-color .2s;
  flex-shrink: 0;
}
.query-select:focus { border-color: var(--blue-500); }
.query-input {
  flex: 1;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: .7rem 1rem;
  font-family: 'Poppins', sans-serif;
  font-size: .95rem; color: var(--gray-900);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.query-input::placeholder { color: var(--gray-400); }
.query-btn {
  width: 100%;
  background: var(--blue-600); color: var(--white);
  border: none; border-radius: var(--radius);
  padding: .85rem;
  font-family: 'Poppins', sans-serif;
  font-size: .92rem; font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  transition: background .2s, transform .15s;
}
.query-btn:hover { background: var(--blue-700); }
.query-btn:active { transform: scale(.98); }
.query-btn:disabled { background: var(--gray-200); color: var(--gray-400); cursor: not-allowed; }
.query-btn .spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: white; border-radius: 50%;
  animation: spin .7s linear infinite; display: none;
}
.query-btn.loading .spinner { display: block; }
.query-btn.loading .btn-text { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.query-hint { font-size: .72rem; color: var(--gray-600); margin-top: .75rem; }

/* Error */
.query-error {
  display: none;
  background: #FEF2F2; border: 1px solid #FECACA;
  border-radius: var(--radius);
  padding: .75rem 1rem;
  font-size: .8rem; color: #B91C1C;
  margin-top: .85rem;
  align-items: center; gap: .5rem;
}
.query-error.visible { display: flex; }

/* Result card */
.result-card {
  display: none;
  margin-top: 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.result-card.visible { display: block; }

.result-header {
  background: linear-gradient(135deg, var(--blue-900), var(--blue-950));
  padding: 1.25rem 1.5rem;
  display: flex; align-items: center; gap: .85rem;
}
.result-avatar {
  width: 44px; height: 44px;
  background: rgba(255,255,255,.15);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 800; color: var(--white);
  flex-shrink: 0;
}
.result-name { font-size: .9rem; font-weight: 700; color: var(--white); margin-bottom: .1rem; }
.result-cuil { font-size: .75rem; color: rgba(255,255,255,.6); }
.result-status {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: .3rem;
  background: rgba(255,255,255,.1);
  color: var(--teal-400);
  font-size: .68rem; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase;
  padding: .25rem .65rem; border-radius: 99px;
  flex-shrink: 0;
}
.status-dot { width: 6px; height: 6px; background: var(--teal-400); border-radius: 50%; }

/* Credencial preview */
.credencial-preview {
  background: linear-gradient(135deg, #1a3a7a 0%, var(--blue-950) 100%);
  padding: 1.1rem 1.5rem;
  position: relative; overflow: hidden;
}
.credencial-preview::before {
  content: ''; position: absolute;
  top: -20px; right: -20px;
  width: 100px; height: 100px;
  background: rgba(255,255,255,.04); border-radius: 50%;
}
.credencial-logo { height: 1.4rem; margin-bottom: .75rem; opacity: .85; }
.credencial-badge {
  position: absolute; top: 1rem; right: 1.25rem;
  background: var(--teal-500); color: var(--white);
  font-size: .62rem; font-weight: 700;
  padding: .18rem .5rem; border-radius: 99px;
  letter-spacing: .04em; text-transform: uppercase;
}
.credencial-num { font-size: .65rem; color: rgba(255,255,255,.45); letter-spacing: .08em; text-transform: uppercase; margin-bottom: .15rem; }
.credencial-name { font-size: .9rem; font-weight: 700; color: var(--white); }
.credencial-sub { font-size: .72rem; color: rgba(255,255,255,.5); }

/* Result body */
.result-body { background: var(--white); padding: 1rem 1.5rem; }
.result-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: .55rem 0; border-bottom: 1px solid var(--gray-100);
  font-size: .82rem;
}
.result-row:last-child { border-bottom: none; }
.result-row-label { color: var(--gray-500); }
.result-row-val { color: var(--gray-900); font-weight: 600; }
.result-row-val--active { color: #16A34A; }

/* Result actions */
.result-actions {
  background: var(--gray-50);
  padding: 1rem 1.5rem;
  display: flex; gap: .6rem;
}
.btn-download {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--teal-600); color: var(--white);
  border: none; border-radius: var(--radius);
  padding: .7rem .5rem;
  font-family: 'Poppins', sans-serif;
  font-size: .8rem; font-weight: 700; cursor: pointer;
  text-decoration: none; transition: background .2s;
}
.btn-download:hover { background: var(--teal-500); }
.btn-new {
  display: flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--white); color: var(--gray-600);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: .7rem .85rem;
  font-family: 'Poppins', sans-serif;
  font-size: .8rem; font-weight: 600; cursor: pointer;
  transition: all .2s;
}
.btn-new:hover { border-color: var(--gray-400); color: var(--gray-900); }

/* Footer */
.left-footer {
  padding: 1.25rem 2rem;
  border-top: 1px solid var(--gray-100);
  font-size: .72rem; color: var(--gray-600);
  flex-shrink: 0;
}
.left-footer a { color: var(--blue-600); text-decoration: none; }

/* ─────────────────────────────────────────
   PANEL DERECHO
───────────────────────────────────────── */
.right-panel {
  flex: 1;
  background: linear-gradient(135deg, var(--blue-900) 0%, var(--blue-950) 55%, #071530 100%);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3rem;
  overflow: hidden;
}
.right-panel::before {
  content: '';
  position: absolute; top: -100px; right: -100px;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(20,184,166,.15) 0%, transparent 65%);
  pointer-events: none;
}
.right-panel::after {
  content: '';
  position: absolute; bottom: -80px; left: -80px;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(37,99,235,.2) 0%, transparent 65%);
  pointer-events: none;
}

.right-top { position: relative; z-index: 1; }
.right-logo { height: 2.4rem; opacity: .9; margin-bottom: 3rem; }

.right-tagline {
  font-size: clamp(1.6rem, 2.5vw, 2.2rem);
  font-weight: 800;
  color: var(--white);
  line-height: 1.2;
  letter-spacing: -.03em;
  margin-bottom: 1rem;
}
.right-tagline span { color: var(--teal-400); }

.right-sub {
  font-size: .9rem;
  color: rgba(255,255,255,.6);
  line-height: 1.7;
  max-width: 340px;
}

.right-features {
  display: flex;
  flex-direction: column;
  gap: .85rem;
  position: relative; z-index: 1;
}
.right-feature {
  display: flex; align-items: center; gap: .85rem;
  color: rgba(255,255,255,.75);
  font-size: .85rem;
}
.right-feature-icon {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--teal-400);
}

.right-bottom {
  position: relative; z-index: 1;
  font-size: .72rem;
  color: rgba(255,255,255,.3);
}

/* ─────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────── */
@media (max-width: 900px) {
  html, body { height: auto; }
  .right-panel { display: none; }
  .left-panel { width: 100%; min-width: 0; box-shadow: none; min-height: 100vh; height: auto; }
  .left-content { flex: 0 0 auto; justify-content: flex-start; padding: 2rem 1.75rem; }
  .app-intro { margin-bottom: 1.75rem; }
  .app-intro h1 { font-size: 1.45rem; }
}
@media (max-width: 480px) {
  .left-content { padding: 1.5rem 1.25rem; }
  .app-bar { padding: .85rem 1.25rem; }
  .left-footer { padding: 1rem 1.25rem; }
  .query-select, .query-input { font-size: .88rem; padding: .65rem .85rem; }
  .query-btn { font-size: .88rem; }
  .result-header { padding: 1.1rem; }
  .credencial-preview { padding: 1rem 1.1rem; }
  .result-body { padding: .85rem 1.1rem; }
  .result-actions { padding: .85rem 1.1rem 1.1rem; gap: .5rem; }
  .app-intro h1 { font-size: 1.3rem; }
  .app-intro p { font-size: .82rem; }
  .app-intro { margin-bottom: 1.5rem; }
}
@media (max-width: 360px) {
  .left-content { padding: 1.25rem 1rem; }
  .query-input-group { flex-direction: column; }
  .query-select { width: 100%; }
}

/* ─────────────────────────────────────────
   CREDENCIAL FLIP (frente / dorso)
───────────────────────────────────────── */
.cred-flip-wrap {
  padding: .75rem 1rem 0;
}

/* Contenedor con perspectiva 3D */
.cred-flip-scene {
  width: 100%;
  perspective: 900px;
  margin-bottom: .55rem;
}

/* Elemento que rota */
.cred-flip-card {
  width: 100%;
  /* Relación de aspecto 771:471 ≈ 1.638 */
  aspect-ratio: 771 / 471;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0.2, 0.2, 1);
  border-radius: 10px;
}
.cred-flip-card.is-flipped {
  transform: rotateY(180deg);
}

/* Caras comunes */
.cred-face {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.cred-face--back {
  transform: rotateY(180deg);
}

/* Imagen dentro de cada cara */
.cred-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 10px;
}

/* Botón de flip */
.btn-flip-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  background: rgba(30, 58, 138, .07);
  border: 1px solid rgba(30, 58, 138, .18);
  color: var(--blue-700);
  font-family: 'Poppins', sans-serif;
  font-size: .75rem;
  font-weight: 600;
  padding: .45rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .2s, border-color .2s;
  margin-bottom: .75rem;
}
.btn-flip-card:hover {
  background: rgba(30, 58, 138, .13);
  border-color: rgba(30, 58, 138, .35);
}
.btn-flip-icon {
  flex-shrink: 0;
  transition: transform .55s cubic-bezier(0.4, 0.2, 0.2, 1);
}
#btn-flip-card[data-flipped="true"] .btn-flip-icon {
  transform: rotate(180deg);
}
