/* -- INNOVADEF Control de Acceso - Frontend CSS -- */
@import url('https://fonts.googleapis.com/css2?family=Work+Sans:wght@400;500;600;700;800;900&display=swap');

:root {
  --idef-green:      #00C471;
  --idef-green-dark: #009a58;
  --idef-green-glow: rgba(0,196,113,0.12);
  --idef-bg:         #0d1117;
  --idef-bg-card:    #141920;
  --idef-border:     #1e2a38;
  --idef-text:       #e5e7eb;
  --idef-text-muted: #9ca3af;
  --idef-red:        #ef4444;
  --idef-yellow:     #f59e0b;
}

/* ============================================================
   FORMULARIO DE REGISTRO — tema claro
   ============================================================ */

/* Variables locales para el formulario (sobreescriben el :root oscuro) */
.idef-form-wrap {
  --form-bg:          #ffffff;
  --form-bg-card:     #ffffff;
  --form-border:      #e2e8f0;
  --form-text:        #111827;
  --form-text-muted:  #6b7280;
  --form-input-bg:    #f9fafb;
  --form-input-focus: #ffffff;
  width: 100%;
  max-width: 100%;
  font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--form-text);
}
.idef-form-wrap * { box-sizing: border-box; }
.idef-form-wrap, .idef-form { overflow-x: hidden; }

.idef-form-header { margin-bottom: 32px; }
.idef-tag {
  display: inline-block;
  background: var(--idef-green);
  color: #000;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 20px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.idef-form-header h2 { font-size: 26px; font-weight: 800; margin: 0 0 8px; color: var(--form-text); }
.idef-form-header p  { color: var(--form-text-muted); font-size: 15px; margin: 0; line-height: 1.6; }

.idef-form {
  background: var(--form-bg-card);
  border: 1px solid var(--form-border);
  border-radius: 14px;
  padding: 36px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.idef-form-row    { margin-bottom: 22px; }
.idef-form-row--2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 640px) {
  .idef-form-row--2       { grid-template-columns: 1fr; gap: 0; }
  .idef-form              { padding: 20px 16px; }
  .idef-field input[type="text"],
  .idef-field input[type="email"],
  .idef-field input[type="tel"],
  .idef-field select,
  .idef-field textarea    { font-size: 16px; /* evita zoom en iOS */ }
}

.idef-field          { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.idef-field label    { font-size: 13px; font-weight: 600; color: var(--form-text); }
.idef-field .req     { color: var(--idef-green); }

.idef-field input[type="text"],
.idef-field input[type="email"],
.idef-field input[type="tel"],
.idef-field select,
.idef-field textarea {
  width: 100%;
  min-width: 0;
  background: var(--form-input-bg);
  border: 1px solid var(--form-border);
  border-radius: 8px;
  color: var(--form-text);
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color .2s, box-shadow .2s, background .2s;
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
}
.idef-field input[type="text"]:hover,
.idef-field input[type="email"]:hover,
.idef-field input[type="tel"]:hover,
.idef-field select:hover,
.idef-field textarea:hover {
  border-color: #cbd5e1;
}
.idef-field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}
.idef-field textarea { resize: vertical; min-height: 100px; }
.idef-field input:focus,
.idef-field select:focus,
.idef-field textarea:focus {
  outline: none;
  background: var(--form-input-focus);
  border-color: var(--idef-green);
  box-shadow: 0 0 0 3px rgba(0,196,113,0.12);
}
.idef-field input.idef-input-error,
.idef-field select.idef-input-error { border-color: var(--idef-red) !important; }
.idef-error { font-size: 12px; color: var(--idef-red); display: none; }
.idef-error.visible { display: block; }

.idef-field--check   { flex-direction: row; align-items: flex-start; gap: 0; }
.idef-check-label    { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 13px; color: var(--form-text-muted); line-height: 1.5; }
.idef-check-label input[type="checkbox"] { margin-top: 2px; accent-color: var(--idef-green); flex-shrink: 0; width: 16px; height: 16px; }
.idef-check-label a  { color: var(--idef-green); text-decoration: underline; }

.idef-form-footer  { display: flex; flex-direction: column; gap: 10px; padding-top: 8px; }
.idef-form-note    { font-size: 12px; color: var(--form-text-muted); margin: 0; }

.idef-btn           { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 32px; border-radius: 8px; font-size: 15px; font-weight: 700; cursor: pointer; border: none; transition: all .2s; font-family: inherit; width: 50%; text-align: center; margin: 0; }
@media (max-width: 600px) {
  .idef-btn { width: 100%; }
}
.idef-btn--primary  { background: var(--idef-green); color: #000; }
.idef-btn--primary:hover    { background: var(--idef-green-dark); color: #fff; }
.idef-btn--primary:disabled { opacity: 0.6; cursor: not-allowed; }

.idef-notice        { border-radius: 12px; padding: 32px 36px; text-align: center; margin-top: 24px; }
.idef-notice--success { background: #f0fdf4; border: 1px solid #bbf7d0; }
.idef-notice--error   { background: #fef2f2; border: 1px solid #fecaca; }
.idef-notice-icon   { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; font-size: 22px; font-weight: 900; }
.idef-notice--success .idef-notice-icon { background: rgba(0,196,113,0.15); color: var(--idef-green); }
.idef-notice--error   .idef-notice-icon { background: rgba(239,68,68,0.12);  color: var(--idef-red); }
.idef-notice h3     { font-size: 20px; margin: 0 0 10px; }
.idef-notice--success h3 { color: #15803d; }
.idef-notice--error   h3 { color: var(--idef-red); }
.idef-notice p      { font-size: 14px; color: #374151; margin: 0 0 8px; line-height: 1.6; }


/* ============================================================
   ESCANADOR DE PUERTA
   ============================================================ */

/* -- Contenedor principal: 100% ancho de la columna de contenido -- */
.idef-scanner-wrap {
  width: 100%;
  background: var(--idef-bg);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--idef-border);
  font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* -- Cabecera -- */
.idef-scanner-header {
  background: linear-gradient(160deg, #0a2a1a 0%, #0d1117 100%);
  border-bottom: 3px solid var(--idef-green);
  padding: 20px 28px 24px;
  text-align: center;
}
/* Fila superior: logo + botón salir */
.idef-scanner-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.idef-scanner-logo        { margin-bottom: 0; }
.idef-scanner-logo-img    { height: 44px; width: auto; display: block; }
.idef-scan-logo-text      { font-size: 26px; font-weight: 900; color: var(--idef-green); letter-spacing: 2px; }
.idef-scan-logo-text span { color: #fff; }
.idef-scanner-title       { font-size: 18px; font-weight: 700; color: #fff; margin: 6px 0 4px; }
.idef-scanner-subtitle    { font-size: 13px; color: var(--idef-text-muted); margin: 0; }

/* Botón de logout */
.idef-logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--idef-border);
  border-radius: 8px;
  color: var(--idef-text-muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color .2s, color .2s, background .2s;
  flex-shrink: 0;
}
.idef-logout-btn:hover {
  border-color: var(--idef-red);
  color: var(--idef-red);
  background: rgba(239,68,68,.08);
  text-decoration: none;
}
.idef-logout-btn svg { flex-shrink: 0; }

/* -- Panel de resultado -- */
.idef-scan-result {
  padding: 40px 28px;
  text-align: center;
  animation: idef-result-in .3s ease;
}
@keyframes idef-result-in { from { opacity:0; transform:scale(.97); } to { opacity:1; transform:scale(1); } }

.idef-scan-result--success { background: #021a0e; }
.idef-scan-result--warning  { background: #1a1200; }
.idef-scan-result--error    { background: #1a0202; }

.idef-result-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 28px;
  font-weight: 900;
}
.idef-result-icon--success { background: rgba(0,196,113,0.15); color: var(--idef-green); }
.idef-result-icon--success::after { content: 'OK'; font-size: 13px; font-weight: 800; letter-spacing: 1px; }
.idef-result-icon--warning { background: rgba(245,158,11,0.15); color: var(--idef-yellow); }
.idef-result-icon--warning::after { content: '!'; font-size: 26px; font-weight: 800; }
.idef-result-icon--error   { background: rgba(239,68,68,0.15);  color: var(--idef-red); }
.idef-result-icon--error::after   { content: 'X'; font-size: 20px; font-weight: 800; letter-spacing: 1px; }

.idef-result-title { font-size: 22px; font-weight: 800; margin: 0 0 14px; }
.idef-scan-result--success .idef-result-title { color: var(--idef-green); }
.idef-scan-result--warning  .idef-result-title { color: var(--idef-yellow); }
.idef-scan-result--error    .idef-result-title { color: var(--idef-red); }

.idef-result-info           { font-size: 15px; color: var(--idef-text-muted); line-height: 1.6; margin-bottom: 24px; }
.idef-result-name           { font-size: 20px; font-weight: 800; color: #fff; margin-bottom: 4px; }
.idef-result-meta           { font-size: 14px; color: var(--idef-text-muted); }
.idef-result-perfil         { display: inline-block; margin-top: 8px; padding: 2px 10px; border-radius: 20px; background: rgba(0,196,113,0.12); color: var(--idef-green); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.idef-result-warning-note   { font-size: 12px; color: var(--idef-yellow); margin-top: 8px; }
.idef-result-error-msg      { font-size: 16px; color: var(--idef-red); font-weight: 600; }

/* -- Viewport de la camara -- */
.idef-scanner-viewport {
  position: relative;
  width: 100%;
  background: #000;
  overflow: hidden;
}
/* html5-qrcode: forzar camara a ocupar todo el ancho */
#idef-qr-reader {
  width: 100% !important;
  border: none !important;
  background: #000 !important;
}
#idef-qr-reader video {
  width: 100% !important;
  object-fit: cover !important;
}
#idef-qr-reader img,
#idef-qr-reader__dashboard,
#idef-qr-reader__dashboard_section,
#idef-qr-reader__header_message,
#idef-qr-reader__status_span,
#idef-qr-reader__filescan_input,
#idef-qr-reader__camera_permission_button { display: none !important; }
#idef-qr-reader__scan_region { border: none !important; }

/* -- Overlay con marco de escaneo -- */
.idef-scan-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.idef-scan-frame {
  position: relative;
  width: min(62vw, 240px);
  height: min(62vw, 240px);
}
/* Oscurecer alrededor del marco */
.idef-scan-frame::before {
  content: '';
  position: absolute;
  inset: -9999px;
  background: rgba(0,0,0,0.5);
  z-index: 0;
}
/* Esquinas */
.idef-corner {
  position: absolute;
  width: 26px;
  height: 26px;
  z-index: 1;
}
.idef-corner--tl { top: 0;    left: 0;  border-top: 3px solid var(--idef-green); border-left:  3px solid var(--idef-green); border-radius: 3px 0 0 0; }
.idef-corner--tr { top: 0;    right: 0; border-top: 3px solid var(--idef-green); border-right: 3px solid var(--idef-green); border-radius: 0 3px 0 0; }
.idef-corner--bl { bottom: 0; left: 0;  border-bottom: 3px solid var(--idef-green); border-left:  3px solid var(--idef-green); border-radius: 0 0 0 3px; }
.idef-corner--br { bottom: 0; right: 0; border-bottom: 3px solid var(--idef-green); border-right: 3px solid var(--idef-green); border-radius: 0 0 3px 0; }
/* Laser */
.idef-scan-laser {
  position: absolute;
  top: 8%;
  left: 4%; right: 4%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--idef-green), transparent);
  box-shadow: 0 0 8px var(--idef-green);
  z-index: 2;
  animation: idef-laser 2s ease-in-out infinite;
}
@keyframes idef-laser {
  0%   { top: 8%;  }
  50%  { top: 86%; }
  100% { top: 8%;  }
}
.idef-scan-hint {
  position: absolute;
  bottom: 16px;
  font-size: 13px;
  color: rgba(255,255,255,0.8);
  background: rgba(0,0,0,0.55);
  padding: 5px 14px;
  border-radius: 20px;
  pointer-events: none;
  white-space: nowrap;
}

/* -- Entrada manual -- */
.idef-scanner-manual {
  padding: 16px 20px;
  border-top: 1px solid var(--idef-border);
  background: #0a0f14;
}
.idef-manual-label { font-size: 12px; color: var(--idef-text-muted); text-align: center; margin: 0 0 10px; }
.idef-manual-input-wrap { display: flex; gap: 8px; }
.idef-manual-input {
  flex: 1;
  background: var(--idef-bg);
  border: 1px solid var(--idef-border);
  border-radius: 7px;
  color: var(--idef-text);
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
}
.idef-manual-input:focus { outline: none; border-color: var(--idef-green); box-shadow: 0 0 0 3px var(--idef-green-glow); }

/* -- Boton principal -- */
.idef-scan-btn {
  background: var(--idef-green);
  color: #000;
  border: none;
  padding: 10px 18px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
}
.idef-scan-btn:hover { background: var(--idef-green-dark); color: #fff; }
.idef-scan-btn--secondary {
  background: transparent;
  color: var(--idef-green);
  border: 2px solid var(--idef-green);
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  border-radius: 8px;
  font-size: 14px;
  display: block;
  text-align: center;
}
.idef-scan-btn--secondary:hover { background: var(--idef-green); color: #000; }

/* -- Contador -- */
.idef-scanner-stats {
  padding: 16px 20px;
  border-top: 1px solid var(--idef-border);
  background: #0a0f14;
  text-align: center;
}
.idef-scan-stat__num   { display: block; font-size: 32px; font-weight: 900; color: var(--idef-green); line-height: 1; }
.idef-scan-stat__label { display: block; font-size: 11px; color: var(--idef-text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

/* -- Acceso bloqueado -- */
.idef-scanner-locked { text-align: center; }
.idef-scanner-locked .idef-scanner-logo { padding: 28px 20px 16px; }
.idef-locked-body { padding: 20px 32px 40px; }
.idef-locked-body h2 { font-size: 20px; color: #fff; margin: 0 0 8px; }
.idef-locked-body p  { font-size: 14px; color: var(--idef-text-muted); margin: 0 0 20px; line-height: 1.6; }
