@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --accent-color: #1e40af;
  /* Gesthispania Deep Navy */
  --accent-hover: #1e3a8a;
  --accent-light: #eff6ff;
  --border-color: #cbd5e1;
  --input-focus: #94a3b8;
  --success-color: #10b981;
  --success-bg: #ecfdf5;
  --highlight-color: #ef4444;
  /* Alert red */
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
}

/* Developer Options Bar */
.dev-banner {
  background-color: #0f172a;
  color: #38bdf8;
  width: 100%;
  max-width: 1200px;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
  display: none;
  /* Controlled by JS dev flag */
  justify-content: space-between;
  align-items: center;
  border: 1px solid #1e293b;
}

.dev-banner-btn {
  background-color: #1e293b;
  border: 1px solid #38bdf8;
  color: #38bdf8;
  padding: 0.35rem 0.75rem;
  border-radius: 0.25rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.dev-banner-btn:hover {
  background-color: #38bdf8;
  color: #0f172a;
}

/* Tabs Navigation (For Dev Mode) */
.nav-tabs-container {
  display: none;
  /* Visible only when DEV_MODE is active */
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  width: 100%;
  max-width: 1200px;
}

.nav-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #64748b;
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.nav-tab:hover {
  color: var(--accent-color);
}

.nav-tab.active {
  color: var(--accent-color);
  border-bottom-color: var(--accent-color);
}

/* Container */
.portal-container {
  background-color: var(--card-bg);
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  box-shadow: var(--shadow-lg);
  max-width: 1200px;
  width: 100%;
  overflow: hidden;
  transition: all 0.3s ease;
}

/* Header */
.portal-header {
  background-color: #ffffff;
  padding: 2.25rem;
  border-bottom: 1px solid #e2e8f0;
  text-align: center;
}

.brand-logo {
  height: 50px;
  margin: 0 auto 1.25rem;
  display: block;
}

.portal-header h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent-color);
  letter-spacing: -0.5px;
}

.portal-header p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 0.4rem;
}

/* Wizard Steps Progressbar */
.wizard-progress {
  display: flex;
  justify-content: space-between;
  background-color: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 1.25rem 3rem;
  position: relative;
}

.wizard-progress::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 4.5rem;
  right: 4.5rem;
  height: 2px;
  background-color: #e2e8f0;
  z-index: 1;
  transform: translateY(-50%);
}

.progress-line-fill {
  position: absolute;
  top: 50%;
  left: 4.5rem;
  width: 0%;
  /* Dynamic width based on step */
  height: 2px;
  background-color: var(--accent-color);
  z-index: 1;
  transform: translateY(-50%);
  transition: width 0.3s ease;
}

.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  z-index: 2;
  position: relative;
}

.step-num {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background-color: #ffffff;
  border: 2px solid #cbd5e1;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  transition: all 0.3s ease;
}

.step-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.wizard-step.active .step-num {
  border-color: var(--accent-color);
  background-color: var(--accent-color);
  color: #ffffff;
  box-shadow: 0 0 0 4px rgba(30, 64, 175, 0.15);
}

.wizard-step.active .step-label {
  color: var(--accent-color);
}

.wizard-step.completed .step-num {
  border-color: var(--success-color);
  background-color: var(--success-color);
  color: #ffffff;
}

.wizard-step.completed .step-label {
  color: var(--success-color);
}

/* Body content layout */
.portal-body {
  padding: 2.5rem;
}

.step-panel {
  display: none;
}

.step-panel.active {
  display: block;
}

.tab-content {
  display: none;
}

.tab-content.show {
  display: block;
}

/* Section Title */
.section-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent-color);
  margin-bottom: 1.25rem;
  margin-top: 1.75rem;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 0.4rem;
}

.section-title:first-of-type {
  margin-top: 0;
}

/* Forms structure */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

label span.required {
  color: var(--highlight-color);
  margin-left: 2px;
}

/* Tooltips */
.tooltip-container {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.4rem;
  position: relative;
  cursor: help;
}

.tooltip-icon {
  background-color: var(--accent-light);
  color: var(--accent-color);
  border-radius: 50%;
  width: 1.2rem;
  height: 1.2rem;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(30, 64, 175, 0.2);
  font-weight: bold;
}

.tooltip-text {
  visibility: hidden;
  width: 250px;
  background-color: #1e293b;
  color: #fff;
  text-align: left;
  border-radius: 6px;
  padding: 0.75rem;
  position: absolute;
  z-index: 50;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.2s;
  font-size: 0.75rem;
  font-weight: 400;
  box-shadow: var(--shadow-lg);
}

.tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #1e293b transparent transparent transparent;
}

.tooltip-container:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

input,
select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text-primary);
  background-color: #ffffff;
  transition: all 0.2s ease;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(30, 64, 175, 0.15);
}

.help-text {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 0.15rem;
  line-height: 1.4;
}

/* Radio buttons list */
.radio-group {
  display: flex;
  gap: 1.5rem;
  padding: 0.5rem 0;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.radio-option input[type="radio"] {
  width: auto;
  cursor: pointer;
}

.radio-option label {
  font-weight: 400;
  cursor: pointer;
}

/* Upload Area */
.upload-box {
  border: 2px dashed var(--border-color);
  background-color: #f8fafc;
  border-radius: 0.5rem;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  position: relative;
  min-height: 120px;
}

.upload-box:hover,
.upload-box.dragover {
  border-color: var(--accent-color);
  background-color: rgba(30, 64, 175, 0.02);
}

.upload-box:focus-visible {
  outline: 3px solid var(--accent-color);
  outline-offset: 3px;
}


.upload-icon {
  width: 2rem;
  height: 2rem;
  color: #64748b;
}

.upload-box span {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.upload-box span strong {
  color: var(--accent-color);
}

.file-input {
  display: none;
}

.file-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 0.5rem 0.85rem;
  border-radius: 0.375rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.file-remove {
  color: #ef4444;
  cursor: pointer;
  font-weight: 600;
  font-size: 1.1rem;
  border: none;
  background: none;
}

/* AI Auto-filled: Two-state verification system */
/* State 1: Pending Review — AI filled but user hasn't confirmed (ORANGE) */
.ai-pending-review {
  background-color: rgba(245, 158, 11, 0.06) !important;
  border-color: #f59e0b !important;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15) !important;
  transition: all 0.4s ease;
}

/* State 2: Verified — User has focused+blurred to confirm the value (GREEN) */
.ai-verified {
  background-color: rgba(16, 185, 129, 0.03) !important;
  border-color: #10b981 !important;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.08) !important;
  transition: all 0.4s ease;
}

/* Legacy class kept for backward compatibility in removal logic */
.ai-autofilled {
  background-color: rgba(16, 185, 129, 0.03) !important;
  border-color: #10b981 !important;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.08) !important;
  transition: all 0.4s ease;
}

.ai-loading-field {
  border-color: var(--accent-color) !important;
  box-shadow: 0 0 0 2px rgba(30, 64, 175, 0.12) !important;
  animation: pulse 1.5s infinite;
  cursor: wait !important;
}

.warning-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background-color: #fee2e2;
  color: #991b1b;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 9999px;
  margin-left: 0.5rem;
  box-shadow: 0 1px 2px rgba(153, 27, 27, 0.1);
}

/* Prioridad 1: ERROR (ROJO) */
html body .is-invalid,
html body input.is-invalid,
html body select.is-invalid,
html body .upload-box.is-invalid {
    border-color: #ef4444 !important;
    background-color: #fef2f2 !important;
}

.is-valid {
  border-color: #10b981 !important;
  background-color: #ecfdf5 !important;
}

.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.65rem;
  background-color: var(--success-bg);
  color: var(--success-color);
  padding: 0.15rem 0.35rem;
  border-radius: 0.25rem;
  font-weight: 700;
  margin-left: 0.5rem;
  text-transform: uppercase;
}

/* Scanning Overlay on Upload card */
.upload-scanning-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-color);
}

.spinner {
  width: 1.75rem;
  height: 1.75rem;
  border: 3px solid rgba(30, 64, 175, 0.1);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Buttons */
.btn-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
}

.submit-btn {
  flex: 1;
  background-color: var(--accent-color);
  color: #ffffff;
  border: none;
  padding: 0.85rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px -1px rgba(30, 64, 175, 0.2);
}

.submit-btn:hover:not(:disabled) {
  background-color: var(--accent-hover);
  box-shadow: 0 10px 15px -3px rgba(30, 64, 175, 0.3);
}

.submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary-btn {
  background-color: #ffffff;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 0.85rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.2s;
}

.secondary-btn:hover {
  background-color: #f1f5f9;
  color: var(--text-primary);
}

/* Success download buttons */
.download-btn-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1.75rem 0;
}

.download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background-color: var(--accent-light);
  color: var(--accent-color);
  border: 1px solid rgba(30, 64, 175, 0.2);
  padding: 0.9rem;
  border-radius: 0.375rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
  font-size: 0.95rem;
}

.download-btn:hover {
  background-color: var(--accent-color);
  color: #ffffff;
  border-color: var(--accent-color);
}

.download-icon {
  width: 1.25rem;
  height: 1.25rem;
}

/* Success View */
.success-card {
  text-align: center;
  padding: 4rem 2.5rem;
}

.success-icon {
  width: 4.5rem;
  height: 4.5rem;
  background-color: var(--success-bg);
  color: var(--success-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  font-size: 2.2rem;
  box-shadow: 0 0 0 8px rgba(16, 185, 129, 0.05);
}

.success-card h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--success-color);
  margin-bottom: 0.75rem;
}

.success-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
  max-width: 500px;
  margin: 0 auto 1.5rem;
}

/* Conditional visibility */
.conditional-block {
  display: none;
}

.conditional-block.show {
  display: block;
}

/* JSON Viewer Syntax Highlighting */
#sandbox-json-output pre {
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.5;
}

.json-key {
  color: #f43f5e;
}

.json-string {
  color: #34d399;
}

.json-number {
  color: #60a5fa;
}

.json-boolean {
  color: #fbbf24;
}

.json-null {
  color: #94a3b8;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive */
@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-group.full-width {
    grid-column: span 1;
  }

  .wizard-progress {
    padding: 1.25rem 1rem;
  }

  .wizard-progress::before {
    left: 2rem;
    right: 2rem;
  }
}

/* Vehicle Cards Collapsible Logic */
.vehicle-block.collapsed .vehicle-body {
  display: none;
}

.vehicle-block.collapsed .icon-collapse {
  transform: rotate(0deg) !important;
}

.vehicle-block .vehicle-header:hover {
  background-color: #f1f5f9 !important;
}

/* ==========================================================================
   ALTCHA Component Styling (Full width, integrated card)
   ========================================================================== */
altcha-widget {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  --altcha-max-width: 100% !important;
  --altcha-border-radius: 0.5rem !important;
  --altcha-color-border: #cbd5e1 !important;
  --altcha-color-base: #f8fafc !important;
  --altcha-color-text: #334155 !important;
  margin: 0 !important;
  box-sizing: border-box !important;
}

altcha-widget .altcha {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  padding: 0.85rem 1rem !important;
  border-radius: 0.5rem !important;
  border: 1px solid #cbd5e1 !important;
  background-color: #f8fafc !important;
  font-family: inherit !important;
  min-height: 52px !important;
}

altcha-widget .altcha-main {
  width: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
}

altcha-widget .altcha-label {
  font-weight: 500 !important;
  color: #334155 !important;
  font-size: 0.9rem !important;
}

/* Tooltip info icon styles */
.field-tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: #3b82f6;
  color: white;
  font-size: 12px;
  font-weight: bold;
  font-style: normal;
  margin-left: 6px;
  cursor: pointer;
  user-select: none;
  vertical-align: middle;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.field-tooltip-icon:hover {
  background-color: #2563eb;
}

.field-tooltip-box {
  display: none;
  background-color: #f8fafc;
  border: 1px solid #cbd5e1;
  border-left: 4px solid #3b82f6;
  padding: 10px 14px;
  margin-top: 6px;
  margin-bottom: 10px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #334155;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  animation: fadeIn 0.2s ease-in-out;
}

.field-tooltip-box.show {
  display: block;
}

/* Tooltip / Info Icon Styles */
.info-icon {
    display: inline-block;
    margin-left: 8px;
    color: #4a90e2;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    user-select: none;
    transition: color 0.2s;
}

.info-icon:hover {
    color: #2171c7;
}

.tooltip-box {
    margin-top: 5px;
    padding: 10px 14px;
    background-color: #eef5fb;
    border-left: 4px solid #4a90e2;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #333;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

