/* ========================================================================
   SISTEMA MODAL GENÉRICO - EDICTOS v2.0
   ======================================================================== */

/* ========================================
   VARIABLES BASE PARA MODALES
   ======================================== */
:root {
    /* Z-Index System */
    --edictos-modal-backdrop: 9999;
    --edictos-modal-content: 10000;
    --edictos-modal-loading: 10001;
    
    /* Colors */
    --edictos-modal-overlay-bg: rgba(0, 0, 0, 0.65);
    --edictos-modal-container-bg: #ffffff;
    --edictos-modal-border-color: #e8e8e8;
    --edictos-modal-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    
    /* Timing */
    --edictos-modal-transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    --edictos-modal-transition-fast: all 0.2s ease-out;
    
    /* Spacing */
    --edictos-modal-padding: 20px;
    --edictos-modal-radius: 12px;
    --edictos-modal-max-width: 600px;
    --edictos-modal-max-height: 90vh;
}

/* ========================================
   OVERLAY BASE - PANTALLA COMPLETA
   ======================================== */
.edictos-modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    
    /* Sombreado completo */
    background: var(--edictos-modal-overlay-bg) !important;
    backdrop-filter: blur(3px);
    
    /* Centrado absoluto */
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    
    /* Z-index y transiciones */
    z-index: var(--edictos-modal-backdrop) !important;
    opacity: 0;
    visibility: hidden;
    transition: var(--edictos-modal-transition);
    
    /* Padding para mantener espacios en móvil */
    padding: var(--edictos-modal-padding);
    box-sizing: border-box;
    
    /* Evitar scroll del body cuando modal está abierto */
    overflow: auto;
}

/* Estado activo del overlay */
.edictos-modal-overlay.active,
.edictos-modal-overlay.show {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Bloquear scroll del body cuando modal está abierto */
body.edictos-modal-open {
    overflow: hidden !important;
    padding-right: 15px; /* Compensar barra de scroll */
}

/* ========================================
   CONTENEDOR MODAL - SIEMPRE CENTRADO
   ======================================== */
.edictos-modal-container {
    background: var(--edictos-modal-container-bg);
    border-radius: var(--edictos-modal-radius);
    box-shadow: var(--edictos-modal-shadow);
    
    /* Dimensiones adaptables */
    width: 100%;
    max-width: var(--edictos-modal-max-width);
    max-height: var(--edictos-modal-max-height);
    
    /* Estructura flex */
    display: flex;
    flex-direction: column;
    
    /* Animación de entrada */
    transform: scale(0.85) translateY(30px);
    transition: var(--edictos-modal-transition);
    
    /* Evitar overflow */
    overflow: hidden;
    
    /* Posicionamiento relativo para elementos internos */
    position: relative;
}

/* Animación cuando el modal está activo */
.edictos-modal-overlay.active .edictos-modal-container,
.edictos-modal-overlay.show .edictos-modal-container {
    transform: scale(1) translateY(0);
}

/* ========================================
   VARIANTES DE TAMAÑO
   ======================================== */
.edictos-modal-container.small {
    --edictos-modal-max-width: 400px;
}

.edictos-modal-container.medium {
    --edictos-modal-max-width: 600px;
}

.edictos-modal-container.large {
    --edictos-modal-max-width: 800px;
}

.edictos-modal-container.extra-large {
    --edictos-modal-max-width: 1000px;
}

.edictos-modal-container.full-width {
    --edictos-modal-max-width: 95vw;
}

/* ========================================
   HEADER MODAL
   ======================================== */
.edictos-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 0;
    flex-shrink: 0;
    
    /* Separador visual */
    border-bottom: 1px solid var(--edictos-modal-border-color);
    padding-bottom: 16px;
    margin-bottom: 0;
}

.edictos-modal-title {
    margin: 0;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.3;
}

.edictos-modal-subtitle {
    margin: 4px 0 0;
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 400;
}

/* ========================================
   BOTÓN CERRAR
   ======================================== */
.edictos-modal-close {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--edictos-modal-transition-fast);
    
    /* Iconografía */
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    
    /* Colores */
    color: #6b7280;
    
    /* Hover effect */
    &:hover {
        background: #f3f4f6;
        color: #374151;
    }
    
    /* Icono por defecto (×) */
    font-size: 20px;
    font-weight: 300;
    line-height: 1;
}

.edictos-modal-close::before {
    content: "×";
}

/* ========================================
   BODY MODAL - CONTENIDO SCROLLEABLE
   ======================================== */
.edictos-modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    
    /* Scroll personalizado */
    scrollbar-width: thin;
    scrollbar-color: #d1d5db #f9fafb;
    
    /* Altura máxima calculada dinámicamente */
    max-height: calc(var(--edictos-modal-max-height) - 120px);
}

.edictos-modal-body::-webkit-scrollbar {
    width: 6px;
}

.edictos-modal-body::-webkit-scrollbar-track {
    background: #f9fafb;
}

.edictos-modal-body::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.edictos-modal-body::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ========================================
   FOOTER MODAL
   ======================================== */
.edictos-modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    padding: 16px 24px 24px;
    border-top: 1px solid var(--edictos-modal-border-color);
    background: #f9fafb;
    flex-shrink: 0;
}

.edictos-modal-footer.center {
    justify-content: center;
}

.edictos-modal-footer.start {
    justify-content: flex-start;
}

.edictos-modal-footer.between {
    justify-content: space-between;
}

/* ========================================
   OVERLAYS ESPECIALIZADOS
   ======================================== */

/* Loading Overlay */
.edictos-modal-overlay.loading {
    --edictos-modal-overlay-bg: rgba(0, 0, 0, 0.8);
    z-index: var(--edictos-modal-loading);
}

.edictos-modal-overlay.loading .edictos-modal-container {
    background: transparent;
    box-shadow: none;
    max-width: 300px;
    text-align: center;
}

/* Confirmation Overlay */
.edictos-modal-overlay.confirmation .edictos-modal-container {
    max-width: 450px;
}

/* Alert Overlay */
.edictos-modal-overlay.alert .edictos-modal-container {
    max-width: 400px;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 768px) {
    :root {
        --edictos-modal-padding: 16px;
        --edictos-modal-max-width: 95vw;
        --edictos-modal-max-height: 85vh;
    }
    
    .edictos-modal-header {
        padding: 20px 20px 0;
    }
    
    .edictos-modal-body {
        padding: 16px 20px;
    }
    
    .edictos-modal-footer {
        padding: 12px 20px 20px;
        gap: 8px;
    }
    
    .edictos-modal-title {
        font-size: 1.125rem;
    }
    
    /* Stack footer buttons on mobile */
    .edictos-modal-footer {
        flex-direction: column-reverse;
    }
    
    .edictos-modal-footer.keep-row {
        flex-direction: row;
    }
}

@media (max-width: 480px) {
    :root {
        --edictos-modal-padding: 12px;
        --edictos-modal-max-width: 100vw;
        --edictos-modal-max-height: 100vh;
        --edictos-modal-radius: 0;
    }
    
    .edictos-modal-container {
        border-radius: 0;
        height: 100vh;
        max-height: 100vh;
    }
}

/* ========================================
   ANIMACIONES Y TRANSICIONES AVANZADAS
   ======================================== */

/* Entrada desde arriba */
.edictos-modal-overlay.slide-down .edictos-modal-container {
    transform: translateY(-50px) scale(0.95);
}

.edictos-modal-overlay.slide-down.active .edictos-modal-container {
    transform: translateY(0) scale(1);
}

/* Entrada desde abajo */
.edictos-modal-overlay.slide-up .edictos-modal-container {
    transform: translateY(50px) scale(0.95);
}

.edictos-modal-overlay.slide-up.active .edictos-modal-container {
    transform: translateY(0) scale(1);
}

/* Entrada con zoom */
.edictos-modal-overlay.zoom .edictos-modal-container {
    transform: scale(0.5);
}

.edictos-modal-overlay.zoom.active .edictos-modal-container {
    transform: scale(1);
}

/* Fade simple */
.edictos-modal-overlay.fade .edictos-modal-container {
    transform: none;
    opacity: 0;
}

.edictos-modal-overlay.fade.active .edictos-modal-container {
    opacity: 1;
}

/* ========================================
   UTILIDADES Y HELPERS
   ======================================== */

/* Ocultar scrollbar del overlay cuando está fijo */
.edictos-modal-overlay {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.edictos-modal-overlay::-webkit-scrollbar {
    display: none;
}

/* Prevenir selección de texto en elementos de UI */
.edictos-modal-header,
.edictos-modal-footer,
.edictos-modal-close {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Clase helper para contenido centrado */
.edictos-modal-content-center {
    text-align: center;
}

/* Clase helper para espaciado adicional */
.edictos-modal-body.spacious {
    padding: 32px 24px;
}

/* Clase helper para footer sin borde */
.edictos-modal-footer.no-border {
    border-top: none;
    background: transparent;
}

/* ========================================
   ESTILOS ESPECÍFICOS PARA DICTADO POR VOZ
   ======================================== */

/* Contenedor principal del dictado */
.voice-dictation-container {
    text-align: center;
    padding: 20px;
    max-width: 500px;
    margin: 0 auto;
}

/* Introducción del dictado */
.voice-intro {
    margin-bottom: 24px;
}

.voice-intro .voice-icon-large {
    font-size: 48px;
    margin-bottom: 12px;
    display: block;
}

.voice-intro h4 {
    margin: 0 0 8px 0;
    font-size: 20px;
    color: var(--color-encabezados, #1E293B);
    font-weight: 600;
}

.voice-intro .voice-description {
    margin: 0;
    color: var(--color-texto, #67768E);
    font-size: 14px;
    line-height: 1.5;
}

.voice-intro .voice-description.error {
    color: #dc2626;
    font-weight: 500;
}

/* Estado de grabación */
.voice-status {
    margin-bottom: 20px;
    padding: 14px 20px;
    border-radius: 8px;
    font-weight: 500;
    transition: var(--edictos-modal-transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 50px;
}

.voice-status.idle {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    color: var(--color-texto, #67768E);
}

.voice-status.requesting {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    animation: voiceRequestPulse 1.5s infinite;
}

.voice-status.listening {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    animation: voicePulse 2s infinite;
}

.voice-status.processing {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    animation: voiceProcessing 1s infinite;
}

.voice-status.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

/* Indicador de estado visual */
.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.8;
    flex-shrink: 0;
}

.voice-status.listening .status-indicator {
    animation: statusBlink 1s infinite alternate;
}

.voice-status.requesting .status-indicator,
.voice-status.processing .status-indicator {
    animation: statusSpin 1s linear infinite;
}

/* Animaciones del sistema de dictado */
@keyframes voicePulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    50% { 
        transform: scale(1.02);
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
    }
}

@keyframes voiceRequestPulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6);
    }
    50% { 
        transform: scale(1.02);
        box-shadow: 0 0 0 8px rgba(245, 158, 11, 0);
    }
}

@keyframes voiceProcessing {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes statusBlink {
    0% { opacity: 0.8; }
    100% { opacity: 0.3; }
}

@keyframes statusSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Área de transcripción */
.voice-transcript {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    margin: 20px 0;
    min-height: 80px;
    max-height: 110px;
    overflow-y: auto;
    transition: var(--edictos-modal-transition-fast);
    text-align: left;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.voice-transcript:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Placeholder de transcripción */
.transcript-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #9ca3af;
    font-style: italic;
    height: 100%;
    min-height: 68px;
}

.transcript-placeholder .transcript-icon {
    font-size: 24px;
    opacity: 0.7;
}

/* Texto final de la transcripción */
.final-transcript {
    color: #1f2937;
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 8px;
    animation: fadeInUp 0.3s ease-out;
}

/* Texto temporal/provisional */
.interim-transcript {
    color: #6b7280;
    font-style: italic;
    font-size: 15px;
    line-height: 1.5;
    animation: fadeIn 0.2s ease-out;
    border-left: 3px solid #d1d5db;
    padding-left: 12px;
    margin-left: 4px;
}

/* Animaciones para transcript */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Botones de control de voz */
.voice-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
    flex-wrap: wrap;
}

.voice-controls .btn {
    min-width: 140px;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    border: none;
}

/* Botón de iniciar grabación */
.btn-voice-start {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    transform: scale(1);
}

.btn-voice-start:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    background: linear-gradient(135deg, #059669, #047857);
}

.btn-voice-start:active {
    transform: scale(0.98);
}

/* Botón de detener grabación */
.btn-voice-stop {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    transform: scale(1);
    animation: stopButtonPulse 2s infinite;
}

.btn-voice-stop:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    animation: none;
}

.btn-voice-stop:active {
    transform: scale(0.98);
}

@keyframes stopButtonPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1); }
}

/* Iconos de botones */
.btn-icon {
    font-size: 16px;
    line-height: 1;
}

/* Navegadores no compatibles */
.voice-unsupported {
    text-align: left;
    margin: 20px 0;
    padding: 20px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
}

.voice-unsupported h5 {
    margin: 0 0 12px 0;
    color: #991b1b;
    font-size: 16px;
    font-weight: 600;
}

.voice-unsupported ul {
    margin: 0 0 16px 0;
    padding-left: 20px;
}

.voice-unsupported li {
    margin-bottom: 6px;
    color: #7f1d1d;
}

.voice-unsupported p {
    margin: 16px 0 0 0;
    color: #7f1d1d;
    font-size: 14px;
}

/* Mensaje de ayuda */
.voice-help {
    margin-top: 16px;
    padding: 12px 16px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 6px;
    color: #0c4a6e;
    font-size: 13px;
    line-height: 1.4;
}

/* Estados responsivos para dictado por voz */
@media (max-width: 768px) {
    .voice-dictation-container {
        padding: 16px 12px;
    }
    
    .voice-intro .voice-icon-large {
        font-size: 40px;
        margin-bottom: 8px;
    }
    
    .voice-intro h4 {
        font-size: 18px;
    }
    
    .voice-intro .voice-description {
        font-size: 13px;
    }
    
    .voice-status {
        padding: 12px 16px;
        margin-bottom: 16px;
        font-size: 14px;
    }
    
    .voice-transcript {
        padding: 12px;
        margin: 16px 0;
        min-height: 80px;
        max-height: 120px;
        font-size: 15px;
    }
    
    .voice-controls {
        flex-direction: column;
        align-items: center;
        gap: 10px;
        margin-top: 20px;
    }
    
    .voice-controls .btn {
        width: 100%;
        max-width: 280px;
        min-width: auto;
        padding: 14px 20px;
        font-size: 16px;
    }
    
    .voice-help {
        font-size: 12px;
        padding: 10px 12px;
        margin-top: 12px;
    }
    
    .voice-unsupported {
        padding: 16px;
        margin: 16px 0;
    }
    
    .voice-unsupported h5 {
        font-size: 15px;
    }
    
    .voice-unsupported li {
        font-size: 14px;
        margin-bottom: 4px;
    }
    
    .voice-unsupported p {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .voice-dictation-container {
        padding: 12px 8px;
    }
    
    .voice-intro .voice-icon-large {
        font-size: 36px;
    }
    
    .voice-intro h4 {
        font-size: 16px;
        margin-bottom: 6px;
    }
    
    .voice-status {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .status-text {
        font-size: 13px;
    }
    
    .voice-transcript {
        min-height: 70px;
        max-height: 100px;
        font-size: 14px;
    }
    
    .final-transcript {
        font-size: 14px;
        line-height: 1.5;
    }
    
    .interim-transcript {
        font-size: 13px;
    }
    
    .voice-controls .btn {
        padding: 12px 16px;
        font-size: 15px;
    }
    
    .btn-icon {
        font-size: 14px;
    }
}

/* Estilos para pantallas táctiles */
@media (hover: none) and (pointer: coarse) {
    .voice-controls .btn {
        min-height: 48px; /* Tamaño mínimo para touch */
    }
    
    .btn-voice-start:active,
    .btn-voice-stop:active {
        transform: scale(0.96);
        transition: transform 0.1s ease;
    }
}

/* ========================================
   ESTILOS PARA CHECKBOXES Y FORMULARIOS
   ======================================== */

/* Contenedor de checkbox personalizado - GENERAL */
.checkbox-container {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 16px 0;
    cursor: pointer;
    user-select: none;
}

/* Ocultar checkbox nativo - GENERAL */
.checkbox-container input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    /* Posicionar sobre el checkmark visual */
    left: 0;
    top: 2px; /* Alinear con margin-top del checkmark */
    width: 20px; /* Mismo tamaño que checkmark */
    height: 20px; /* Mismo tamaño que checkmark */
    margin: 0;
    z-index: 2;
}

/* Checkbox personalizado - GENERAL */
.checkbox-container .checkmark {
    position: relative;
    height: 20px;
    width: 20px;
    background-color: #ffffff;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    transition: var(--edictos-modal-transition-fast);
    flex-shrink: 0;
    margin-top: 2px;
}

/* Hover effect - GENERAL */
.checkbox-container:hover .checkmark {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Checkbox marcado - GENERAL */
.checkbox-container input[type="checkbox"]:checked ~ .checkmark {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

/* Checkmark (tick) - GENERAL */
.checkbox-container .checkmark::after {
    content: "";
    position: absolute;
    display: none;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Mostrar checkmark cuando está marcado - GENERAL */
.checkbox-container input[type="checkbox"]:checked ~ .checkmark::after {
    display: block;
}

/* Label del checkbox - GENERAL */
.checkbox-container .checkbox-label {
    flex: 1;
    line-height: 1.5;
    color: #374151;
    font-size: 14px;
    cursor: pointer;
    /* Permitir que los clics en el label también activen el checkbox */
    pointer-events: auto;
}

/* Focus state para accesibilidad - GENERAL */
.checkbox-container input[type="checkbox"]:focus ~ .checkmark {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Checkbox disabled - GENERAL */
.checkbox-container input[type="checkbox"]:disabled ~ .checkmark {
    background-color: #f3f4f6;
    border-color: #d1d5db;
    cursor: not-allowed;
}

.checkbox-container input[type="checkbox"]:disabled ~ .checkbox-label {
    color: #9ca3af;
    cursor: not-allowed;
}

/* Variante small - GENERAL */
.checkbox-container.small .checkmark {
    height: 16px;
    width: 16px;
}

.checkbox-container.small .checkmark::after {
    left: 5px;
    top: 1px;
    width: 4px;
    height: 8px;
}

.checkbox-container.small .checkbox-label {
    font-size: 13px;
}

/* Responsivo para móviles */
@media (max-width: 768px) {
    .checkbox-container {
        gap: 10px;
        margin: 12px 0;
    }
    
    .checkbox-container .checkmark {
        height: 18px;
        width: 18px;
    }
    
    .checkbox-container .checkmark::after {
        left: 5px;
        top: 1px;
        width: 5px;
        height: 9px;
    }
}
