/* === 1. RESET GLOBAL Y VARIABLES === */
:root {
    --bg-color: #f4f7f6;
    --text-main: #1a1a1a;
    --text-muted: #666666;
    --primary: #0056b3;
    --primary-disabled: #cccccc;
    --surface: #ffffff;
    --border: #e0e0e0;
    --success: #28a745;
    --danger: #dc3545;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #333; /* Fondo oscuro para escritorio */
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

/* === 2. ESTRUCTURA PRINCIPAL (FLEXBOX) === */
.app-container {
    background-color: var(--bg-color);
    width: 100%;
    max-width: 450px; /* Ancho máximo de celular/tablet */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    overflow: hidden; /* Evita que nada salga de este marco */
}

/* === 3. HEADER (Z-Index: 100) === */
.app-header {
    background-color: var(--surface);
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 8px;
}

.progress-bar-container {
    height: 6px;
    background-color: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background-color: var(--primary);
    transition: width 0.3s ease;
}

/* === 4. CONTENIDO DINÁMICO === */
.app-content {
    flex: 1; /* Ocupa todo el espacio central disponible */
    padding: 20px;
    overflow-y: auto;
}

.step-section {
    display: none;
}

.step-section.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-title {
    font-size: 22px;
    color: var(--text-main);
    margin-bottom: 24px;
}

/* === 5. FORMULARIOS Y BOTONES === */
.input-group { margin-bottom: 24px; }

.input-group label {
    display: block;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 12px;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.btn-option {
    flex: 1;
    min-width: 30%;
    padding: 14px 10px;
    background-color: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-option.selected {
    background-color: #e6f0fa;
    border-color: var(--primary);
    color: var(--primary);
}

textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    background-color: var(--surface);
    color: var(--text-main);
    resize: none;
}

textarea:focus { outline: none; border-color: var(--primary); }

/* === 6. MÓDULO DE CÁMARA === */
.instruction-text {
    font-size: 14px;
    color: var(--danger);
    margin-bottom: 20px;
    font-weight: 500;
}

.photo-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.photo-item { display: flex; flex-direction: column; }
.camera-input { display: none; }

.camera-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 80px;
    background-color: #eef2f5;
    border: 2px dashed var(--primary);
    border-radius: 8px;
    color: var(--primary);
    font-weight: 600;
    font-size: 14px;
    text-align: center;
    cursor: pointer;
    background-size: cover;
    background-position: center;
    transition: all 0.2s ease;
}

.camera-btn.has-photo {
    border-style: solid;
    color: transparent;
    text-shadow: none;
}

/* === 7. ESCALA DE EVALUACIÓN DINÁMICA === */
.eval-item {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.eval-item label { display: block; font-weight: 600; margin-bottom: 12px; color: var(--text-main); }
.state-group { display: flex; gap: 8px; }

.btn-state {
    flex: 1;
    padding: 10px 5px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background-color: #f9f9f9;
    font-size: 13px;
    font-weight: bold;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-state.active[data-value="Optimo"] { background-color: #d4edda; border-color: #28a745; color: #155724; }
.btn-state.active[data-value="Aceptable"] { background-color: #fff3cd; border-color: #ffc107; color: #856404; }
.btn-state.active[data-value="Deficiente"] { background-color: #f8d7da; border-color: #dc3545; color: #721c24; }

.hidden { display: none !important; }

.deficiente-box {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed var(--border);
    animation: fadeIn 0.3s ease;
}

.obs-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 10px;
}
.small-btn { height: 50px; font-size: 13px; }

/* === 8. FOOTER Y BOTÓN PRINCIPAL (La solución al desborde) === */
.app-footer {
    position: sticky; /* Sticky en lugar de Fixed lo mantiene dentro del contenedor */
    bottom: 0;
    width: 100%;
    background-color: var(--surface);
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    z-index: 100;
}

.btn-primary {
    width: 100%;
    padding: 16px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn-primary:disabled {
    background-color: var(--primary-disabled);
    cursor: not-allowed;
}

/* === 9. CAPAS DE SEGURIDAD Y DESPACHO (Z-Index Hierarchy) === */
.app-locked { display: none !important; }

/* Bandeja de Despacho (Z-Index: 900) */
.dispatch-container {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--bg-color);
    z-index: 900;
    display: flex;
    flex-direction: column;
}

.dispatch-header {
    background-color: var(--primary);
    color: white;
    padding: 40px 20px 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.dispatch-header h2 { font-size: 24px; margin-bottom: 5px; }
.dispatch-header p { font-size: 14px; opacity: 0.9; }

.assignments-list { padding: 20px; overflow-y: auto; flex-grow: 1; }

.assignment-card {
    background-color: var(--surface);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border-left: 5px solid var(--primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.assignment-info h3 { color: var(--text-main); font-size: 18px; margin-bottom: 5px; }
.assignment-info .plate { display: inline-block; background-color: #f0f0f0; padding: 4px 8px; border-radius: 4px; font-family: monospace; font-weight: bold; border: 1px solid #ccc; }
.assignment-time { text-align: right; color: var(--text-muted); font-size: 14px; font-weight: 600; }

/* Modal de Emergencia (Z-Index: 999) */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.8);
    z-index: 999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-content { background-color: white; padding: 24px; border-radius: 12px; text-align: center; width: 100%; }
.modal-icon { font-size: 48px; margin-bottom: 10px; }
.modal-content h3 { color: var(--danger); margin-bottom: 10px; font-size: 22px; }
.modal-content p { color: var(--text-main); margin-bottom: 20px; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; }
.btn-danger { background-color: var(--danger); color: white; padding: 14px; border: none; border-radius: 8px; font-weight: bold; }
.btn-secondary { background-color: #e0e0e0; color: #333; padding: 14px; border: none; border-radius: 8px; font-weight: bold; }

/* Pantalla de Login (Z-Index: 1000 - Tapa todo) */
.login-container {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.login-box { background-color: var(--surface); padding: 40px 20px; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); width: 100%; text-align: center; }
.logo-placeholder { font-size: 32px; font-weight: 900; color: var(--text-main); margin-bottom: 24px; letter-spacing: 1px; }
.login-box h2 { margin-bottom: 24px; color: var(--text-muted); font-size: 18px; }
.login-box input { width: 100%; padding: 16px; border: 2px solid var(--border); border-radius: 8px; font-size: 16px; margin-bottom: 16px; background-color: #f9f9f9; }
.login-box input:focus { outline: none; border-color: var(--primary); background-color: white; }
.error-msg { color: var(--danger); font-size: 14px; margin-top: 15px; font-weight: 600; } 

/* === ESTILOS PARA LA CÁMARA DINÁMICA === */

/* Oculta el input file real feo de los navegadores */
.dynamic-camera {
    display: none !important;
}

/* El botón que hace de previsualizador */
.camera-btn {
    display: inline-block;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s ease;
    min-height: 40px; /* Dale un alto mínimo para que el dedo acierte */
    line-height: 40px;
    padding: 0 15px;
}

/* Cuando el botón tiene una foto cargada */
.camera-btn.has-photo {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: transparent !important; /* Ocultamos las letras "Foto Evidencia" */
    border: 2px solid #28a745; /* Le ponemos un borde verde de éxito */
    height: 120px; /* Lo hacemos más grande para que el técnico vea su foto */
    width: 100%;
    border-radius: 8px;
}
/* === FOOTER FIJO (SIEMPRE VISIBLE) === */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #ffffff;
    padding: 15px 20px;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.08); /* Sombra suave hacia arriba */
    z-index: 1000;
    box-sizing: border-box;
}

/* Evita que el último botón del formulario quede tapado por el footer */
.app-content {
    padding-bottom: 100px !important; 
}
/* === ESTILOS BASE PARA LA MATRIZ DE BOTONES (B, R, M, NA) === */
.state-group {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    gap: 5px; /* Separación entre botones */
}

.btn-state {
    flex: 1;
    padding: 12px 0;
    font-size: 15px;
    font-weight: bold;
    border: 1px solid #ced4da;
    background-color: #f8f9fa;
    color: #495057;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

/* === COLORES DE ESTADO ACTIVO (FORZADOS CON !IMPORTANT) === */
.btn-state.active[data-value="B"] { 
    background-color: #d4edda !important; 
    border-color: #28a745 !important; 
    color: #155724 !important; 
}
.btn-state.active[data-value="R"] { 
    background-color: #fff3cd !important; 
    border-color: #ffc107 !important; 
    color: #856404 !important; 
}
.btn-state.active[data-value="M"] { 
    background-color: #f8d7da !important; 
    border-color: #dc3545 !important; 
    color: #721c24 !important; 
}
.btn-state.active[data-value="NA"] { 
    background-color: #e2e3e5 !important; 
    border-color: #6c757d !important; 
    color: #383d41 !important; 
}