/* =========================================
   1. VARIABLES Y RESET
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

:root {
  --color-primary: #3498db;
  --color-primary-dark: #2980b9;
  --color-success: #27ae60;
  --color-danger: #e74c3c;
  --color-warning: #f39c12;
  --bg-light: #f4f6f9;
  --border-radius: 8px;
  --shadow: 0 4px 10px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; }

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-light);
    margin: 0;
    padding: 10px;
    color: #333;
    line-height: 1.5;
    height: 100vh;
    overflow: hidden; /* el scroll va en reception-container, no en body */
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

/* =========================================
   2. HEADER Y CONTENEDOR
   ========================================= */
.sticky-header {
    position: sticky;
    top: 0;
    z-index: 1100;
    background: white;
    border-bottom: 3px solid var(--color-primary);
    padding: 15px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    margin-bottom: 15px;
    /* Fallback para iframes/contenedores con overflow */
    -webkit-position: sticky;
}

#headerSubTitle {
    font-size: 13px;
    font-weight: 500;
    margin-top: 5px;
    color: var(--color-primary-dark);
}

.reception-container {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 25px;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto 20px auto;
    /* Ocupa el espacio restante y scrollea internamente */
    flex: 1;
    overflow-y: auto;
    /* Altura = viewport - header (~65px) - wizard (~52px) - padding body (~20px) */
    height: calc(100vh - 155px);
}

.step-content-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 25px;
    border: 1px solid #e0e6ed;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}

/* =========================================
   3. BARRA DE PROGRESO Y BOTONES NAV
   ========================================= */
.step-progress {
    position: sticky;
    top: 72px; /* justo debajo del sticky header — ajusta si el header tiene otra altura */
    z-index: 1050;
    display: flex;
    justify-content: space-between;
    background: white;
    border-bottom: 2px solid #e8f4fd;
    padding: 10px 15px;
    margin-bottom: 20px;
    overflow-x: auto;
    gap: 10px;
    scrollbar-width: none;
    box-shadow: 0 3px 8px rgba(0,0,0,0.06);
}

.step-progress::-webkit-scrollbar { display: none; }

.step-badge {
    padding: 10px 18px; 
    background: #f1f3f5;
    border-radius: 20px;
    font-size: 13px;
    font-weight: bold;
    white-space: nowrap;
    color: #7f8c8d;
    flex-shrink: 0;
    transition: 0.3s;
}
.step-badge.active {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.4);
}

.nav-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.nav-buttons .btn {
    padding: 12px 28px; 
    border-radius: 50px;
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
}

.btn-primary { background: linear-gradient(135deg, #3498db, #2980b9); color: white; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 15px rgba(52, 152, 219, 0.4); }
.btn-secondary { background: #95a5a6; color: white; }
.btn-secondary:hover { background: #7f8c8d; }
.btn-success { background: linear-gradient(135deg, #2ecc71, #27ae60); color: white; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* =========================================
   4. CALENDARIO
   ========================================= */
.calendar-wrapper { width: 100%; margin: 0 auto; }
.calendar-header { 
    display: flex; justify-content: space-between; align-items: center; 
    margin-bottom: 10px; background: #f8f9fa; padding: 10px 15px; border-radius: 8px; 
}
.calendar-header .btn-secondary {
    background: white; color: var(--color-primary); border: 1px solid #dee2e6;
    border-radius: 50%; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); padding: 0;
}
.calendar-header .btn-secondary:hover { background: var(--color-primary); color: white; }

.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-day { 
    height: 85px; border: 1px solid #e3f2fd; border-radius: 8px; padding: 8px; 
    cursor: pointer; position: relative; display: flex; flex-direction: column; 
    justify-content: space-between; transition: 0.2s; background: white;
}
.cal-day:hover { background: #f0f7ff; }
.cal-day.disabled { background: #f9f9f9; color: #ccc; cursor: default; border-color: #eee; }
.cal-day.has-appointments { background-color: #e3f2fd; border-color: #3498db; }
.cal-day.selected { background-color: var(--color-primary); color: white; transform: scale(1.05); z-index: 2; box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3); }
.appt-dot { width: 8px; height: 8px; background: #e74c3c; border-radius: 50%; display: inline-block; }

.cita-card {
    border: 1px solid #e0e6ed; border-radius: 8px; padding: 15px; cursor: pointer; 
    margin-bottom: 10px; background: #fff; transition: 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.cita-card:hover { border-color: var(--color-primary); transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.05); }

/* =========================================
   5. PASOS MODERNOS (DATOS, OBSERVACIONES)
   ========================================= */

/* Nuevo diseño vertical para el Paso 2 */
.form-grid-vertical {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
}

/* Cada fila = label fijo a la izquierda + input flexible a la derecha */
.form-grid-vertical .modern-field {
    display: grid;
    grid-template-columns: 175px 1fr;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    gap: 0 12px;
}

/* Label: ancho fijo, alineado a la derecha para quedar pegado al input */
.form-grid-vertical .modern-field > label {
    display: flex !important;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
    color: #34495e;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    margin: 0;
    padding: 0;
    line-height: 1.3;
    min-width: 175px;
    max-width: 175px;
    width: 175px;
}

/* Contenedor del input siempre al 100% de su columna */
.form-grid-vertical .input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

/* Icono decorativo izquierdo */
.form-grid-vertical .input-with-icon i {
    position: absolute;
    left: 13px;
    color: #7f8c8d;
    font-size: 14px;
    z-index: 2;
    pointer-events: none;
}

/* Input y select: mismo alto, mismo padding, mismo ancho */
.form-grid-vertical .input-with-icon .form-control {
    width: 100%;
    box-sizing: border-box;
    height: 46px;
    padding-left: 40px;
    padding-right: 12px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    background: #f8f9fa;
    font-size: 14px;
    color: #2c3e50;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    appearance: auto;
}

.form-grid-vertical .input-with-icon .form-control:focus {
    border-color: var(--color-primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
    outline: none;
}

/* Fallback para usos de .modern-field fuera del grid vertical */
.modern-field label {
    margin-bottom: 8px; color: #34495e; font-size: 14px; font-weight: 600; display: block;
}
.input-with-icon {
    position: relative; display: flex; align-items: center; width: 100%;
}
.input-with-icon i {
    position: absolute; left: 15px; color: #7f8c8d; font-size: 16px; z-index: 2;
}
.input-with-icon .form-control {
    width: 100%; padding-left: 45px; height: 50px; border: 1px solid #ced4da;
    background: #f8f9fa; transition: all 0.3s; border-radius: 8px; font-size: 15px;
}
.input-with-icon .form-control:focus {
    border-color: var(--color-primary); background: white; box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15); outline: none;
}

/* Estilo para Validaciones de Error */
.error-field {
    border-color: #e74c3c !important;
    background-color: #fdf2f2 !important;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.2) !important;
}

/* =========================================
   6. MEDIDOR DE COMBUSTIBLE
   ========================================= */
.fuel-mode-selector { display: flex; justify-content: center; gap: 12px; margin-bottom: 25px; flex-wrap: wrap; }
.fuel-radio-label { cursor: pointer; }
.fuel-radio-label input { display: none; }
.fuel-radio-card {
    padding: 12px 25px; background: white; border: 2px solid #e9ecef; border-radius: 50px; 
    font-weight: bold; color: #6c757d; display: flex; align-items: center; gap: 8px; transition: 0.3s;
}
.fuel-radio-label input:checked + .fuel-radio-card { border-color: var(--color-primary); background-color: #e3f2fd; color: var(--color-primary); }

.btn-averiado-card { border-color: #fab1a0; color: #e17055; }
.fuel-radio-label input:checked + .btn-averiado-card { background-color: #e74c3c; color: white; border-color: #c0392b; box-shadow: 0 4px 10px rgba(231, 76, 60, 0.3); }

.fuel-gauge-wrapper { display: flex; justify-content: center; align-items: center; min-height: 220px; }

/* Analógico */
.analog-gauge {
    width: 240px; height: 120px; border: 15px solid #e0e0e0; border-bottom: none;
    border-top-left-radius: 120px; border-top-right-radius: 120px; position: relative; margin: 0 auto;
}
.analog-gauge::before { content: "E"; position: absolute; left: -25px; bottom: -5px; font-weight: 900; color: #e74c3c; font-size: 20px; }
.analog-gauge::after { content: "F"; position: absolute; right: -25px; bottom: -5px; font-weight: 900; color: #27ae60; font-size: 20px; }
.analog-needle {
    width: 4px; height: 105px; background: #c0392b; position: absolute; bottom: 0; left: calc(50% - 2px);
    transform-origin: bottom center; transform: rotate(-90deg); transition: transform 0.4s ease-out; border-radius: 2px;
}

/* Digital */
.digital-gauge {
    width: 80px; height: 180px; border: 4px solid #2c3e50; border-radius: 8px; background: #1a1a1a; position: relative; overflow: visible;
}
.digital-gauge::before { content: 'F'; position: absolute; top: 0; right: -25px; color: #27ae60; font-weight: 900; font-size: 18px; }
.digital-gauge::after { content: 'E'; position: absolute; bottom: 0; right: -25px; color: #e74c3c; font-weight: 900; font-size: 18px; }
.digital-bar {
    position: absolute; bottom: 0; width: 100%; height: 0%;
    background: linear-gradient(to top, #e74c3c, #f1c40f, #2ecc71); transition: height 0.4s ease;
}

/* =========================================
   7. CHECKLIST DINÁMICO
   ========================================= */
.checklist-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
.checklist-category { background: white; border: 1px solid #e0e6ed; border-radius: 8px; padding: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.02); }
.form-grid-table { width: 100%; border-collapse: collapse; }
.form-grid-table th, .form-grid-table td { border: 1px solid #eee; padding: 10px; text-align: center; }
.form-grid-table td:first-child { text-align: left; font-weight: 500; }

/* =========================================
   8. CARROCERÍA Y CANVAS
   ========================================= */
.view-selector-top { display: flex; gap: 10px; margin-bottom: 20px; }
.view-btn-lg { flex: 1; padding: 15px; font-weight: bold; border-radius: 8px; border: 1px solid #ced4da; background: #f8f9fa; cursor: pointer; font-size: 14px; transition: 0.2s; }
.view-btn-lg.active { background: var(--color-primary); color: white; border-color: var(--color-primary); box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3); }
.view-btn-lg.has-damage::after { content: ' ●'; color: #e74c3c; }

.bodywork-main-layout { display: flex; gap: 15px; align-items: flex-start; }
.canvas-sidebar { width: 90px; display: flex; flex-direction: column; gap: 10px; background: #f1f3f5; padding: 12px; border-radius: 8px; border: 1px solid #dee2e6; }
.tool-btn { width: 100%; padding: 12px 5px; border: 1px solid #ced4da; border-radius: 8px; background: white; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 5px; transition: 0.2s; color: #34495e; }
.tool-btn i { font-size: 20px; }
.tool-btn span { font-size: 9px; font-weight: bold; text-transform: uppercase; }
.tool-btn.active { background: var(--color-primary); color: white; border-color: var(--color-primary); }

.bodywork-container { flex: 1; border: 2px solid #e0e6ed; border-radius: 8px; background: white; position: relative; overflow: hidden; touch-action: none; }
canvas { width: 100%; height: auto; display: block; }

/* =========================================
   9. FOTOS
   ========================================= */
.photos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 15px; }
.photo-slot { border: 2px dashed #bdc3c7; border-radius: 10px; height: 140px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #f8f9fa; cursor: pointer; position: relative; overflow: hidden; transition: 0.2s; }
.photo-slot:hover { border-color: var(--color-primary); background: #f0f7ff; }
.photo-slot.completed { border-color: var(--color-success); border-style: solid; background: #f0fff4; }
.photo-slot img { width: 100%; height: 100%; object-fit: cover; }
.photo-label { font-size: 11px; font-weight: bold; text-align: center; padding: 8px; background: rgba(255,255,255,0.9); position: absolute; bottom: 0; width: 100%; border-top: 1px solid #eee; }

/* =========================================
   10. OBSERVACIONES (LISTA DINÁMICA)
   ========================================= */
.obs-list { margin-top: 15px; display: flex; flex-direction: column; gap: 8px; }
.obs-item { display: flex; justify-content: space-between; align-items: center; background: #f8f9fa; padding: 12px 15px; border-left: 4px solid var(--color-primary); border-radius: 6px; font-size: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.btn-delete-obs { background: #fee2e2; color: #e74c3c; border: none; border-radius: 50%; width: 28px; height: 28px; display: flex; justify-content: center; align-items: center; cursor: pointer; transition: 0.2s; }
.btn-delete-obs:hover { background: #e74c3c; color: white; }

/* Estilos Mejorados para el Buscador de Recomendación */
.sugerencias-box { 
    border: 1px solid #3498db; 
    background: white; 
    max-height: 250px; 
    overflow-y: auto; 
    position: absolute; 
    width: 100%; 
    z-index: 1000; 
    box-shadow: 0 8px 25px rgba(52, 152, 219, 0.2); 
    border-radius: 0 0 8px 8px; 
    margin-top: -3px; 
}

.sugerencias-box::-webkit-scrollbar { width: 6px; }
.sugerencias-box::-webkit-scrollbar-thumb { background-color: #bdc3c7; border-radius: 10px; }

.sugerencia-item { 
    padding: 14px 15px; 
    cursor: pointer; 
    border-bottom: 1px solid #f1f3f5; 
    font-size: 14px; 
    color: #2c3e50;
    transition: background 0.2s;
}

.sugerencia-item:last-child { border-bottom: none; }
.sugerencia-item:hover { 
    background: #e3f2fd; 
    color: var(--color-primary-dark); 
}

/* =========================================
   11. FAB BUTTON Y SIDEBAR
   ========================================= */
.fab-adicionales {
    position: fixed; bottom: 30px; right: 30px; width: 65px; height: 65px; border-radius: 50%;
    background: linear-gradient(135deg, #f39c12, #d35400); color: white;
    display: none; align-items: center; justify-content: center;
    box-shadow: 0 6px 20px rgba(211, 84, 0, 0.4); cursor: pointer; z-index: 9000; font-size: 24px;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.fab-adicionales.visible { display: flex; }
.fab-adicionales:hover { transform: scale(1.1); }
.fab-adicionales.fab-in-header {
    position: relative; bottom: auto; right: auto;
    width: 48px; height: 48px; font-size: 18px;
    display: none; flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(211, 84, 0, 0.4);
}
.fab-adicionales.fab-in-header.visible {
    display: flex;
}
.fab-badge {
    position: absolute; top: -5px; right: -5px; background: #e74c3c; color: white; border-radius: 50%;
    width: 26px; height: 26px; font-size: 12px; display: flex; align-items: center; justify-content: center;
    font-weight: bold; border: 2px solid white;
}

.sidebar-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 9998; display: none; backdrop-filter: blur(2px); }
.sidebar-right { position: fixed; top: 0; right: -400px; width: 380px; height: 100vh; background: white; z-index: 9999; box-shadow: -5px 0 25px rgba(0,0,0,0.15); transition: 0.3s ease; display: flex; flex-direction: column; }
.sidebar-right.open { right: 0; }
.sidebar-header { padding: 25px 20px; background: var(--color-primary); color: white; display: flex; justify-content: space-between; align-items: center; }
.sidebar-content { flex: 1; overflow-y: auto; padding: 20px; } 

/* =========================================
   12. RESPONSIVE
   ========================================= */
@media (max-width: 768px) {
    .form-grid-auto { grid-template-columns: 1fr; }
    .bodywork-main-layout { flex-direction: column; }
    .canvas-sidebar { width: 100%; flex-direction: row; overflow-x: auto; padding: 8px; }
    .tool-btn { flex: 0 0 auto; width: 60px; padding: 8px 4px; }
    .view-selector-top { flex-wrap: wrap; }
    .nav-buttons .btn { padding: 12px 20px; font-size: 14px; width: 100%; margin: 5px 0; }
    .nav-buttons { flex-direction: column; gap: 10px; }
}
.hidden { display: none !important; }

/* --- ALERTA SOAT / CITV --- */
@keyframes blink-alert {
    0% { opacity: 1; box-shadow: 0 0 0px rgba(231, 76, 60, 0); }
    50% { opacity: 0.6; box-shadow: 0 0 8px rgba(231, 76, 60, 0.6); }
    100% { opacity: 1; box-shadow: 0 0 0px rgba(231, 76, 60, 0); }
}

.alert-blink {
    color: #c0392b;
    font-weight: bold;
    animation: blink-alert 1.5s infinite;
    margin-left: 10px;
    padding: 3px 8px;
    background: #fdf2f2;
    border: 1px solid #e74c3c;
    border-radius: 6px;
    display: inline-block;
    font-size: 11px;
    vertical-align: middle;
}

/* =========================================
   PASO 8 — RESUMEN DE RECEPCIÓN
   ========================================= */

.summ-card {
    background: #ffffff;
    border: 1px solid #e0e6ed;
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.summ-card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-primary-dark);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e8f4fd;
}

.summ-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.summ-field {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px 12px;
    border: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.summ-label {
    font-size: 11px;
    color: #95a5a6;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.4px;
}

.summ-value {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    word-break: break-word;
}


/* Mayúsculas automáticas en todos los campos de texto del módulo */
.reception-container input[type="text"],
.reception-container input[type="number"],
.reception-container input[type="search"],
.reception-container textarea,
.sidebar-content input[type="text"],
.sidebar-content input[type="number"] {
    text-transform: uppercase;
}

/* Asegurar que el popup de SweetAlert quede sobre el header sticky */
.swal-over-header {
    z-index: 99999 !important;
}
.swal-over-header .swal2-popup {
    margin-top: 80px !important; /* Desplaza el popup debajo del sticky header */
}