/* Reset y estilos base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    min-height: 100dvh;
    color: #333;
    overflow-x: hidden;
}

/* Botón de regreso */
.back-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
    color: #333;
    font-weight: 600;
    text-decoration: none;
}

.back-btn:hover {
    transform: translateX(-5px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    background: rgba(255, 255, 255, 1);
}

.back-btn svg {
    transition: transform 0.3s ease;
}

.back-btn:hover svg {
    transform: translateX(-2px);
}

/* Container principal */
.search-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Encabezado de búsqueda */
.search-header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

.search-title {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.search-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.9;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.search-header h1 {
    font-size: 3rem;
    margin-bottom: 15px;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.4);
    font-weight: 700;
    background: linear-gradient(45deg, #fff, #f0f0f0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.search-header p {
    font-size: 1.3rem;
    opacity: 0.95;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    max-width: 600px;
    margin: 0 auto;
}

/* Widget de búsqueda - Más grande para fullpage */
.search-widget {
    width: 100%;
    max-width: 800px;
    margin: 0 auto 30px auto;
    background: #000;
    border-radius: 25px;
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);
    position: relative;
    aspect-ratio: 4/3;
    min-height: 500px;
    max-height: 70vh;
    max-height: 70dvh;
}

/* Estados del widget */
.widget-state {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
}

.widget-state.active {
    display: flex;
}

/* Estado inicial */
.init-content {
    text-align: center;
    color: white;
    padding: 60px 40px;
}

.init-icon {
    font-size: 5rem;
    margin-bottom: 30px;
    opacity: 0.9;
    display: inline-block;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.1); opacity: 1; }
}

.init-content h3 {
    font-size: 2.2rem;
    margin-bottom: 15px;
    color: white;
    font-weight: 600;
}

.init-content p {
    font-size: 1.2rem;
    margin-bottom: 40px;
    opacity: 0.9;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.5;
}

/* Estado de carga */
.loading-content, .processing-content {
    text-align: center;
    color: white;
    padding: 60px 40px;
}

.loading-spinner, .processing-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255,255,255,0.3);
    border-top: 5px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 30px;
}

.processing-spinner {
    border-top-color: #ff9800;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-content h3, .processing-content h3 {
    font-size: 1.8rem;
    margin-bottom: 15px;
    font-weight: 600;
}

.loading-content p, .processing-content p {
    opacity: 0.9;
    font-size: 1.1rem;
}

/* Estado de búsqueda (video) */
.search-video-container {
    position: relative;
    width: 100%;
    height: 100%;
}

#video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Efecto espejo */
}

#overlay-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

/* Marco para rostro - Más grande para fullpage */
.face-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(350px, 60vw, 65%);
    height: min(450px, 50vh, 70%);
    transform: translate(-50%, -50%);
    z-index: 3;
    pointer-events: none;
}

.frame-border {
    width: 100%;
    height: 100%;
    border: 5px solid #ff4444;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 
        0 0 30px rgba(255, 68, 68, 0.6),
        inset 0 0 30px rgba(255, 68, 68, 0.3);
}

.frame-border.correct {
    border-color: #4CAF50;
    box-shadow: 
        0 0 30px rgba(76, 175, 80, 0.8),
        inset 0 0 30px rgba(76, 175, 80, 0.4);
}

.face-frame.countdown .frame-border {
    border-color: #4CAF50;
    box-shadow: 
        0 0 40px rgba(76, 175, 80, 0.9),
        inset 0 0 40px rgba(76, 175, 80, 0.6);
    animation: search-pulse-border 1s ease-in-out infinite;
}

@keyframes search-pulse-border {
    0% { 
        border-width: 5px;
        box-shadow: 
            0 0 40px rgba(76, 175, 80, 0.9),
            inset 0 0 40px rgba(76, 175, 80, 0.6);
    }
    50% { 
        border-width: 8px;
        box-shadow: 
            0 0 50px rgba(76, 175, 80, 1),
            inset 0 0 50px rgba(76, 175, 80, 0.8);
    }
    100% { 
        border-width: 5px;
        box-shadow: 
            0 0 40px rgba(76, 175, 80, 0.9),
            inset 0 0 40px rgba(76, 175, 80, 0.6);
    }
}

/* Indicador de estado */
.status-indicator {
    position: absolute;
    top: 25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 4;
    backdrop-filter: blur(15px);
    font-size: 1.1rem;
    font-weight: 500;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff4444;
    transition: background-color 0.3s ease;
    animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-indicator.correct .status-dot {
    background: #4CAF50;
    animation: none;
}

/* Countdown */
.countdown-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 5;
    background: transparent;
    padding: 30px;
    border-radius: 25px;
}

.countdown-number {
    font-size: clamp(5rem, 15vw, 8rem);
    font-weight: bold;
    color: #4CAF50;
    margin-bottom: 15px;
    text-shadow: 
        4px 4px 8px rgba(0,0,0,0.9),
        0 0 30px rgba(76, 175, 80, 0.9),
        0 0 60px rgba(76, 175, 80, 0.7);
    animation: countdown-pulse 1s ease-in-out;
}

.countdown-text {
    color: white;
    font-size: clamp(1.2rem, 4vw, 1.6rem);
    font-weight: 600;
    opacity: 0.95;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.9);
}

@keyframes countdown-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Botón de configuración */
.config-toggle-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 30px;
    padding: 10px 18px;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.config-toggle-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

/* Panel de configuración */
.config-panel {
    display: none;
    background: rgba(255, 255, 255, 0.97);
    border-radius: 20px;
    margin-bottom: 30px;
    backdrop-filter: blur(15px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    overflow: hidden;
    transition: all 0.3s ease;
    max-width: 800px;
    width: 100%;
}

.config-content {
    padding: 30px;
}

.config-item {
    margin-bottom: 20px;
}

.config-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 1.1rem;
}

.config-item select, .config-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 1rem;
    background: white;
    transition: border-color 0.3s ease;
}

.config-item select:focus, .config-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Botones */
.btn-search, .btn-restart {
    padding: 16px 32px;
    border: none;
    border-radius: 30px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.btn-search {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
}

.btn-search:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.4);
}

.btn-restart {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-restart:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

/* Botones de acción */
.action-buttons {
    display: none;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
}

.action-buttons.show {
    display: flex;
}

/* Modals personalizados */
.modal-content {
    border: none;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}

.modal-header {
    border-bottom: none;
    padding: 25px 30px 20px;
}

.modal-body {
    padding: 20px 30px 30px;
}

.modal-footer {
    border-top: 1px solid #e9ecef;
    padding: 20px 30px 25px;
}

/* Foto de persona encontrada */
.person-photo-container {
    margin-bottom: 20px;
}

.person-photo {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #4CAF50;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

/* Información de persona */
.person-info {
    padding: 10px 0;
}

.person-name {
    color: #2c5530;
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: left;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.info-label {
    font-weight: 600;
    color: #555;
    font-size: 1rem;
}

.info-value {
    font-size: 1rem;
    color: #333;
    font-weight: 500;
}

/* Indicador de confianza */
.confidence-indicator {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 12px;
    margin-top: 15px;
}

.confidence-label {
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
    display: block;
    margin-bottom: 8px;
}

.confidence-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #66bb6a);
    border-radius: 4px;
    transition: width 1s ease-out;
}

.confidence-percentage {
    font-weight: 600;
    color: #4CAF50;
    font-size: 1rem;
}

/* Modal sin coincidencias */
.no-match-icon {
    font-size: 4rem;
    opacity: 0.8;
}

/* Utilidades */
.hidden {
    display: none !important;
}

/* Loading global */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    color: white;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255,255,255,0.3);
    border-top: 5px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 30px;
}

.loading p {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* Toast personalizado */
.toast {
    border: none;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

/* Responsive */
@media (max-width: 768px) {
    .search-container {
        padding: 15px;
    }
    
    .back-btn {
        top: 15px;
        left: 15px;
        padding: 10px 16px;
    }
    
    .back-btn span {
        display: none;
    }
    
    .search-header h1 {
        font-size: 2.2rem;
    }
    
    .search-header p {
        font-size: 1.1rem;
    }
    
    .search-icon {
        font-size: 3rem;
    }
    
    .search-widget {
        max-width: 100%;
        min-height: 400px;
        max-height: 60vh;
        border-radius: 20px;
    }
    
    .face-frame {
        width: min(280px, 70vw, 75%);
        height: min(350px, 45vh, 70%);
    }
    
    .init-content, .loading-content, .processing-content {
        padding: 40px 30px;
    }
    
    .init-icon {
        font-size: 3.5rem;
    }
    
    .init-content h3 {
        font-size: 1.8rem;
    }
    
    .init-content p {
        font-size: 1rem;
    }
    
    .status-indicator {
        top: 20px;
        padding: 10px 16px;
        font-size: 1rem;
    }
    
    .config-content {
        padding: 25px 20px;
    }
    
    .btn-search, .btn-restart {
        width: 100%;
        max-width: 300px;
        padding: 14px 28px;
        font-size: 1.1rem;
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .person-name {
        font-size: 1.5rem;
        text-align: center;
        margin-bottom: 15px;
    }
    
    .modal-body {
        padding: 15px 20px 25px;
    }
}

@media (max-width: 480px) {
    .search-header h1 {
        font-size: 1.8rem;
    }
    
    .search-header p {
        font-size: 1rem;
    }
    
    .search-widget {
        min-height: 350px;
        max-height: 55vh;
        border-radius: 15px;
    }
    
    .face-frame {
        width: min(250px, 75vw, 80%);
        height: min(320px, 40vh, 70%);
    }
    
    .frame-border {
        border-width: 4px;
    }
    
    .init-content h3 {
        font-size: 1.5rem;
    }
    
    .init-content p {
        font-size: 0.9rem;
    }
    
    .person-photo {
        width: 120px;
        height: 120px;
    }
    
    .person-name {
        font-size: 1.3rem;
    }
    
    .info-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

/* Media query para landscape en móviles */
@media (max-width: 768px) and (orientation: landscape) {
    .search-container {
        justify-content: flex-start;
        padding-top: 15px;
    }
    
    .search-header {
        margin-bottom: 15px;
    }
    
    .search-header h1 {
        font-size: 1.8rem;
        margin-bottom: 10px;
    }
    
    .search-header p {
        font-size: 0.9rem;
    }
    
    .search-icon {
        font-size: 2.5rem;
        margin-bottom: 10px;
    }
    
    .search-widget {
        max-height: 70vh;
        min-height: 300px;
    }
    
    .face-frame {
        width: min(220px, 50vw, 60%);
        height: min(280px, 60vh, 70%);
    }
}