/**
 * Estilos para Interfaz de Cámara
 * Centro de Estudios Plugin
 * 
 * @package Centro_Estudios
 * @subpackage Inscripciones_Public
 * @version 2.7.0
 * @since 2.7.0
 */

/* Animación para destacar botón "Subir Archivo" cuando hay error de cámara */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* Modal de cámara */
.ces-camera-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ces-camera-modal-content {
    background: #fff;
    border-radius: 16px;
    padding: 0;
    max-width: 90vw;
    max-height: 90vh;
    width: 100%;
    max-width: 500px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

/* Header del modal */
.ces-camera-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.ces-camera-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.ces-camera-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.ces-camera-close:hover {
    background: #e9ecef;
    color: #333;
}

/* Preview de cámara */
.ces-camera-preview {
    position: relative;
    width: 100%;
    height: 300px;
    background: #000;
    overflow: hidden;
}

#ces-camera-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Espejo para cámara frontal */
}

/* Sin rotación para documentos (cámara trasera) - cámara normal */
#ces-camera-video.document-rotation {
    transform: scaleX(-1) !important;
    transform-origin: center center !important;
    -webkit-transform: scaleX(-1) !important;
    -webkit-transform-origin: center center !important;
}

/* Sin rotación para personas (cámara frontal) */
#ces-camera-video.person-rotation {
    transform: scaleX(-1) !important;
    transform-origin: center center !important;
    -webkit-transform: scaleX(-1) !important;
    -webkit-transform-origin: center center !important;
}

/* Cámara normal sin rotaciones - HTML nativo */
#ces-camera-video.normal-camera {
    transform: scaleX(-1) !important;
    transform-origin: center center !important;
    -webkit-transform: scaleX(-1) !important;
    -webkit-transform-origin: center center !important;
}

/* Controles de cámara */
.ces-camera-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    gap: 16px;
}

.ces-camera-controls .ces-btn {
    flex: 1;
    min-height: 48px;
    font-size: 16px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.ces-btn-primary {
    background: #0073aa;
    color: #fff;
    border: none;
}

.ces-btn-primary:hover {
    background: #005a87;
    transform: translateY(-1px);
}

.ces-btn-secondary {
    background: #6c757d;
    color: #fff;
    border: none;
}

.ces-btn-secondary:hover {
    background: #545b62;
}

/* Instrucciones */
.ces-camera-instructions {
    padding: 16px 20px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.ces-camera-instructions p {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #666;
    text-align: center;
}

.ces-camera-instructions p:last-child {
    margin-bottom: 0;
}

/* Vista previa de imágenes */
.ces-image-preview {
    position: relative;
    display: inline-block;
    margin: 8px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 200px;
}

.ces-image-preview img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 150px;
    object-fit: cover;
}

.ces-image-info {
    padding: 8px 12px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.ces-image-name {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #333;
    margin-bottom: 2px;
}

.ces-image-size {
    display: block;
    font-size: 11px;
    color: #666;
}

.ces-btn-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.ces-btn-remove:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

/* Campos de archivo con cámara */
.ces-file-field {
    margin-bottom: 20px;
}

.ces-file-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.ces-file-field .ces-required {
    color: #d63638;
}

.ces-file-options {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.ces-file-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    background: #fff;
    color: #333;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

.ces-file-option:hover {
    border-color: #0073aa;
    background: #f8f9fa;
    transform: translateY(-1px);
}

.ces-file-option.camera {
    border-color: #28a745;
    color: #28a745;
}

.ces-file-option.camera:hover {
    background: #d4edda;
}

.ces-file-option.upload {
    border-color: #0073aa;
    color: #0073aa;
    /* Por defecto, ocultar el botón "Subir Archivo" */
    display: none !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Mostrar solo cuando hay un error de cámara */
.ces-file-option.upload.show-on-error {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.ces-file-option.upload:hover {
    background: #d1ecf1;
}

.ces-file-input {
    display: none !important; /* Ocultar el input nativo por defecto */
    width: 100%;
    padding: 12px;
    border: 2px solid #ABA7A7;
    border-radius: 6px;
    font-size: 16px;
    background: #ffffff;
    color: #000000;
    margin-top: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
    position: absolute;
    left: -9999px;
}

/* Mostrar el input cuando hay error de cámara */
.ces-file-input.show-on-error {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    position: relative !important;
    left: auto !important;
    border-color: #0073aa !important;
    border-width: 3px !important;
    animation: pulse 2s infinite;
}

.ces-file-input:hover {
    border-color: #0073aa;
    background: #f8f9fa;
}

.ces-file-input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

.ces-file-input.ces-error {
    border-color: #d63638 !important;
    background-color: #fef7f7 !important;
}

.ces-form-group.has-error .ces-file-input {
    border-color: #d63638 !important;
    background-color: #fef7f7 !important;
}

/* Estrategia Híbrida - Estilos para botones de cámara */
.ces-camera-primary {
    background: linear-gradient(135deg, #0073aa 0%, #005a87 100%) !important;
    color: white !important;
    font-weight: 600 !important;
    border: 2px solid #0073aa !important;
    box-shadow: 0 2px 8px rgba(0, 115, 170, 0.3) !important;
    position: relative !important;
}

.ces-camera-primary::before {
    content: "📸 ";
    font-size: 1.1em;
}

.ces-camera-primary:hover {
    background: linear-gradient(135deg, #005a87 0%, #004466 100%) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.4) !important;
}

.ces-camera-flexible {
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%) !important;
    color: white !important;
    font-weight: 500 !important;
    border: 2px solid #28a745 !important;
    box-shadow: 0 2px 6px rgba(40, 167, 69, 0.3) !important;
}

.ces-camera-flexible::before {
    content: "📷 ";
    font-size: 1.1em;
}

.ces-camera-flexible:hover {
    background: linear-gradient(135deg, #1e7e34 0%, #155724 100%) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 10px rgba(40, 167, 69, 0.4) !important;
}

/* Indicadores visuales para estrategia híbrida */
.ces-file-option.upload.show-on-error {
    background: linear-gradient(135deg, #0073aa 0%, #005a87 100%) !important;
    color: white !important;
    font-weight: 500 !important;
    border: 2px solid #0073aa !important;
    opacity: 1 !important;
    display: flex !important;
}

.ces-file-option.upload::before {
    content: "📁 ";
    font-size: 1.1em;
}

.ces-file-option.upload:hover {
    background: linear-gradient(135deg, #495057 0%, #343a40 100%) !important;
    opacity: 1 !important;
    transform: translateY(-1px) !important;
}

/* Mensajes informativos */
.ces-camera-info {
    font-size: 0.85em;
    color: #6c757d;
    margin-top: 4px;
    font-style: italic;
}

.ces-camera-primary + .ces-camera-info {
    color: #0073aa;
}

.ces-camera-flexible + .ces-camera-info {
    color: #28a745;
}

.ces-file-preview {
    display: none;
    margin-top: 12px;
}

/* Responsive */
@media (max-width: 768px) {
    .ces-camera-modal-content {
        max-width: 95vw;
        max-height: 95vh;
        margin: 20px;
    }
    
    .ces-camera-preview {
        height: 250px;
    }
    
    .ces-camera-header {
        padding: 16px;
    }
    
    .ces-camera-header h3 {
        font-size: 16px;
    }
    
    .ces-camera-controls {
        padding: 16px;
        flex-direction: column;
    }
    
    .ces-camera-controls .ces-btn {
        width: 100%;
        min-height: 44px;
    }
    
    .ces-camera-instructions {
        padding: 12px 16px;
    }
    
    .ces-camera-instructions p {
        font-size: 13px;
    }
    
    .ces-file-options {
        flex-direction: column;
    }
    
    .ces-file-option {
        padding: 10px 14px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .ces-camera-modal-content {
        margin: 10px;
        border-radius: 12px;
    }
    
    .ces-camera-preview {
        height: 200px;
    }
    
    .ces-camera-header {
        padding: 12px;
    }
    
    .ces-camera-controls {
        padding: 12px;
    }
    
    .ces-camera-instructions {
        padding: 10px 12px;
    }
    
    .ces-image-preview {
        max-width: 150px;
    }
    
    .ces-image-preview img {
        max-height: 120px;
    }
}

/* Estados de carga */
.ces-camera-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    text-align: center;
}

.ces-camera-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #fff;
    border-radius: 50%;
    animation: ces-spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes ces-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Animaciones */
.ces-camera-modal {
    animation: ces-fadeIn 0.3s ease;
}

.ces-camera-modal-content {
    animation: ces-slideIn 0.3s ease;
}

@keyframes ces-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes ces-slideIn {
    from { 
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
