/* ==========================================================================
   ENTERPRISE DESIGN SYSTEM
   - Zero gradients
   - High-contrast neutral palette (Slate / Zinc)
   - Strict 1px border precision
   - Accessible states and monospaced data displays
   ========================================================================== */

:root {
    /* Superficies y fondos */
    --bg-canvas: #09090b;
    --bg-surface: #121215;
    --bg-card: #18181b;
    --bg-card-hover: #202024;
    --bg-input: #121215;
    --bg-subtle: #27272a;

    /* Bordes y separadores */
    --border: #27272a;
    --border-subtle: #1f1f23;
    --border-strong: #3f3f46;
    --border-focus: #3b82f6;

    /* Tipografía y textos */
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --text-disabled: #52525b;

    /* Acentos e indicadores funcionales (colores planos sin gradientes) */
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-active: #1e40af;
    --accent-text: #ffffff;

    --status-success-bg: #052e16;
    --status-success-border: #166534;
    --status-success-text: #4ade80;

    --status-warning-bg: #451a03;
    --status-warning-border: #9a3412;
    --status-warning-text: #fb923c;

    --status-danger-bg: #450a0a;
    --status-danger-border: #991b1b;
    --status-danger-text: #f87171;

    --status-info-bg: #172554;
    --status-info-border: #1e40af;
    --status-info-text: #60a5fa;

    /* Tipografía */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    /* Radios de borde enterprise */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
}

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

body.enterprise-theme {
    background-color: var(--bg-canvas);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   BARRA SUPERIOR (HEADER)
   ========================================================================== */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 24px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

.brand-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.system-name {
    color: var(--text-primary);
    font-weight: 700;
}

.system-divider {
    color: var(--text-muted);
}

.sub-name {
    color: var(--text-secondary);
    font-weight: 500;
}

.system-status {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: var(--font-mono);
    border: 1px solid var(--border);
    background-color: var(--bg-card);
}

.status-indicator.online .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #22c55e;
    box-shadow: 0 0 6px #22c55e;
}

.status-indicator.offline .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #ef4444;
}

.status-label {
    color: var(--text-secondary);
}

.environment-badge {
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--bg-surface);
}

/* ==========================================================================
   LAYOUT PRINCIPAL
   ========================================================================== */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    max-width: 1400px;
    margin: 24px auto;
    padding: 0 24px;
}

@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   COMPONENTES: CARDS (TARJETAS ENTERPRISE)
   ========================================================================== */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background-color: var(--bg-surface);
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ==========================================================================
   FORMULARIO DE CONSULTA
   ========================================================================== */
.query-card {
    margin-bottom: 20px;
}

.query-form {
    padding: 20px;
}

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

.form-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.label-requirement {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
}

.form-input {
    width: 100%;
    height: 44px;
    padding: 0 40px 0 42px;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: border-color 0.15s ease;
}

.form-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 1px var(--border-focus);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.btn-clear {
    position: absolute;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 4px;
    border-radius: var(--radius-sm);
}

.btn-clear:hover {
    color: var(--text-primary);
    background-color: var(--bg-subtle);
}

.input-feedback {
    margin-top: 6px;
    font-size: 12px;
    min-height: 18px;
}

.input-feedback.error {
    color: var(--status-danger-text);
}

.input-feedback.valid {
    color: var(--status-success-text);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
}

/* ==========================================================================
   BOTONES ENTERPRISE
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    padding: 0 16px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--accent);
    color: var(--accent-text);
    border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-primary:active:not(:disabled) {
    background-color: var(--accent-active);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-secondary:hover:not(:disabled) {
    background-color: var(--bg-card-hover);
    border-color: var(--border-strong);
}

.btn-sm {
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
}

.btn-text-only {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
}

.btn-text-only:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

/* ==========================================================================
   TARJETA DE RESULTADOS
   ========================================================================== */
.result-header-left, .result-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.elapsed-time {
    font-size: 12px;
    color: var(--text-muted);
    padding: 3px 8px;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.result-body {
    padding: 24px;
    min-height: 240px;
}

/* Estado: En espera / Vacío */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-icon {
    margin-bottom: 12px;
    color: var(--text-disabled);
}

.empty-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.empty-subtext {
    font-size: 12px;
    max-width: 380px;
}

/* Estado: Cargando */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
}

.spinner-ring {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.loading-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.loading-bar-container {
    width: 240px;
    height: 3px;
    background-color: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.loading-bar-indeterminate {
    width: 40%;
    height: 100%;
    background-color: var(--accent);
    animation: indeterminate 1.5s infinite ease-in-out;
}

@keyframes indeterminate {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* Estado: Resultados y Pestañas */
.result-view-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    padding-bottom: 8px;
}

.tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--text-primary);
    background-color: var(--bg-subtle);
    border-color: var(--border-strong);
}

.structured-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.data-group {
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.data-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 13px;
}

.data-row:last-child {
    border-bottom: none;
}

.data-key {
    color: var(--text-muted);
    font-weight: 500;
}

.data-val {
    color: var(--text-primary);
    font-weight: 500;
}

.data-val.highlight {
    color: #60a5fa;
    font-family: var(--font-mono);
}

.raw-output {
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}

/* Estado: Error */
.error-state {
    padding: 24px;
    background-color: var(--status-danger-bg);
    border: 1px solid var(--status-danger-border);
    border-radius: var(--radius-sm);
    text-align: left;
}

.error-icon {
    color: var(--status-danger-text);
    margin-bottom: 12px;
}

.error-title {
    color: var(--status-danger-text);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}

.error-message {
    color: #fca5a5;
    font-size: 13px;
    white-space: pre-wrap;
}

/* ==========================================================================
   BADGES Y ESTADOS
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.badge-neutral {
    background-color: var(--bg-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.badge-success {
    background-color: var(--status-success-bg);
    color: var(--status-success-text);
    border: 1px solid var(--status-success-border);
}

.badge-warning {
    background-color: var(--status-warning-bg);
    color: var(--status-warning-text);
    border: 1px solid var(--status-warning-border);
}

.badge-error {
    background-color: var(--status-danger-bg);
    color: var(--status-danger-text);
    border: 1px solid var(--status-danger-border);
}

/* ==========================================================================
   SECCIÓN DE HISTORIAL
   ========================================================================== */
.history-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.history-content {
    flex: 1;
    overflow-y: auto;
    max-height: calc(100vh - 220px);
    padding: 12px;
}

.history-empty {
    padding: 40px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.history-item:hover {
    background-color: var(--bg-card-hover);
    border-color: var(--border-strong);
}

.history-item-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-dni {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.history-time {
    font-size: 11px;
    color: var(--text-muted);
}

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

.history-duration {
    font-size: 11px;
    color: var(--text-muted);
}

.meta-footer {
    padding: 12px 16px;
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
}

.meta-item {
    display: flex;
    justify-content: space-between;
}

.meta-key {
    color: var(--text-muted);
}

.meta-val {
    color: var(--text-secondary);
}

/* Utilidades */
.mono {
    font-family: var(--font-mono);
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   SISTEMA DE AUTENTICACIÓN Y LOGIN (ENTERPRISE)
   ========================================================================== */
.user-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-logout:hover {
    background-color: var(--status-danger-bg);
    border-color: var(--status-danger-border);
    color: var(--status-danger-text);
}

/* Pantalla de Login */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 120px);
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 440px;
    padding: 32px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-badge-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    margin-bottom: 16px;
}

.login-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    margin-bottom: 6px;
}

.login-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.btn-toggle-pass {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: color 0.15s ease;
}

.btn-toggle-pass:hover {
    color: var(--text-primary);
}

.login-feedback {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background-color: var(--status-danger-bg);
    border: 1px solid var(--status-danger-border);
    border-radius: var(--radius-sm);
    color: var(--status-danger-text);
    font-size: 12px;
    font-weight: 500;
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    margin-top: 6px;
}

.login-footer-meta {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
    text-align: center;
}

.security-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

/* ==========================================================================
   NUEVAS REGLAS: COLA DE PROCESAMIENTO & MULTI-DNI CON ENFRIAMIENTO 60S
   ========================================================================== */
.form-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.detected-badge {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--accent);
    background-color: var(--status-info-bg);
    border: 1px solid var(--status-info-border);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

.form-textarea {
    resize: vertical;
    min-height: 56px;
    line-height: 1.4;
    padding-top: 10px;
    padding-bottom: 10px;
}

.input-icon-textarea {
    top: 14px;
    transform: none;
}

/* Tarjeta de la Cola */
.queue-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 20px;
    transition: all 0.2s ease;
}

.queue-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.queue-status-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.queue-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #3b82f6;
    box-shadow: 0 0 8px #3b82f6;
    animation: pulseQueue 1.8s infinite;
}

@keyframes pulseQueue {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
    100% { opacity: 1; transform: scale(1); }
}

.queue-status-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.queue-title-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.queue-count-badge {
    font-size: 11px;
    font-family: var(--font-mono);
    background-color: var(--bg-subtle);
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.queue-actions-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cooldown-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
    background-color: var(--status-warning-bg);
    border: 1px solid var(--status-warning-border);
    color: var(--status-warning-text);
    border-radius: var(--radius-sm);
}

.cooldown-pill.ready {
    background-color: var(--status-success-bg);
    border-color: var(--status-success-border);
    color: var(--status-success-text);
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid var(--status-danger-border);
    color: var(--status-danger-text);
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-danger-outline:hover {
    background-color: var(--status-danger-bg);
    color: #ffffff;
}

/* Barra de progreso de 60s */
.cooldown-progress-track {
    width: 100%;
    height: 3px;
    background-color: var(--border-subtle);
    overflow: hidden;
}

.cooldown-progress-bar {
    height: 100%;
    background-color: #3b82f6;
    transition: width 0.3s linear;
}

/* Lista de elementos en cola */
.queue-items-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 18px;
    max-height: 220px;
    overflow-y: auto;
}

.queue-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    transition: all 0.15s ease;
}

.queue-item:hover {
    border-color: var(--border-strong);
}

.queue-item.active-processing {
    border-color: #3b82f6;
    background-color: rgba(37, 99, 235, 0.08);
}

.queue-item.waiting {
    opacity: 0.85;
}

.queue-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.queue-item-dni {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
}

.queue-item-order {
    font-size: 11px;
    color: var(--text-muted);
}

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

.queue-btn-remove {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1;
}

.queue-btn-remove:hover {
    color: var(--status-danger-text);
}


