/* ========================================
   SELECT EJERCICIOS DIALOG - RESPONSIVE MEJORADO
   ======================================== */

/* ========================================
   ESTILOS BASE DEL MODAL (RADZEN DIALOG)
   ======================================== */

/* Clases para el contenedor del diálogo */
.dialog-mobile .rz-dialog,
.dialog-desktop .rz-dialog {
    max-width: 100% !important;
    margin: 0 auto;
    display: flex !important;
    flex-direction: column !important;
}

/* Móvil: Diálogo ocupa casi toda la pantalla */
.dialog-mobile .rz-dialog {
    width: 95vw !important;
    height: 90vh !important;
    max-height: 90vh !important;
    border-radius: 12px 12px 0 0 !important;
}

/* Desktop: Diálogo con ancho máximo */
.dialog-desktop .rz-dialog {
    width: 90vw !important;
    max-width: 1200px !important;
    height: 85vh !important;
    max-height: 85vh !important;
    border-radius: 12px !important;
}

/* Contenido del diálogo debe usar altura completa */
.dialog-mobile .rz-dialog-content,
.dialog-desktop .rz-dialog-content {
    flex: 1 !important;
    min-height: 0 !important;
    overflow: hidden !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

/* ========================================
   CONTENEDOR PRINCIPAL DEL DIALOG
   ======================================== */

.dialog-container {
    display: flex;
    flex-direction: row;
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* ========================================
   BOTÓN TOGGLE FILTROS
   ======================================== */

.filter-toggle-btn {
    display: none;
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 1001;
    background: #0078d4;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 120, 212, 0.3);
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.filter-toggle-btn:hover {
    background: #005a9f;
    transform: translateY(-2px);
}

.filter-toggle-btn i {
    font-size: 16px;
}

/* ========================================
   PANEL DE FILTROS
   ======================================== */

.filters-panel {
    width: 260px;
    min-width: 260px;
    flex-shrink: 0;
    background: #f8f9fa;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.filters-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.filters-header {
    display: none;
    padding: 14px;
    background: linear-gradient(135deg, #0078d4 0%, #005a9f 100%);
    color: white;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.filters-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.close-filters-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-filters-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.filters-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
}

/* ========================================
   PANEL PRINCIPAL
   ======================================== */

.main-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: white;
}

/* Header con contadores */
.main-header {
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    flex-shrink: 0;
}

.results-counter,
.selected-counter {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #64748b;
}

.selected-counter {
    color: #0078d4;
}

/* Grid container con scroll */
.grid-container {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 12px 16px;
}

/* Barra de acciones sticky */
.action-bar {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-shrink: 0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

/* ========================================
   BADGES Y ELEMENTOS
   ======================================== */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 0.8em;
    font-weight: 500;
}

.badge-zone {
    background: #e3f2fd;
    color: #1976d2;
}

.badge-Principiante {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-Intermedio {
    background: #fff3e0;
    color: #f57c00;
}

.badge-Avanzado {
    background: #ffebee;
    color: #c62828;
}

.exercise-name {
    display: flex;
    align-items: center;
    font-weight: 500;
    white-space: normal;
    word-break: break-word;
}

.action-buttons {
    display: flex;
    gap: 6px;
}

.search-results-info {
    margin-bottom: 10px;
    padding: 10px;
    background: #e3f2fd;
    border-radius: 6px;
    font-size: 0.85em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-checkbox {
    padding: 6px 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s ease;
    border-radius: 4px;
}

.filter-checkbox:hover {
    background: rgba(0, 120, 212, 0.05);
}

.filter-actions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
}

/* ========================================
   ACCORDION COMPACTO
   ======================================== */

.accordion-button {
    padding: 10px 12px !important;
    font-size: 13px !important;
}

.accordion-body {
    padding: 10px 12px !important;
}

.accordion-item {
    margin-bottom: 6px !important;
}

/* ========================================
   EXTRA SMALL (XS) - MÓVIL (< 576px)
   ======================================== */
@media (max-width: 575.98px) {
    .dialog-mobile .rz-dialog {
        width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    .filter-toggle-btn {
        display: flex;
        font-size: 14px;
        padding: 10px 16px;
    }

    .filters-panel {
        position: fixed !important;
        left: 0;
        top: 0;
        height: 100vh !important;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.1);
        width: 85% !important;
        min-width: 0 !important;
        max-width: 280px !important;
    }

    .filters-panel.show {
        transform: translateX(0);
    }

    .filters-header {
        display: flex;
    }

    .filters-overlay {
        display: block;
    }

    .main-panel {
        width: 100% !important;
    }

    .main-header {
        padding: 10px 12px;
        flex-direction: column;
        align-items: flex-start;
    }

    .grid-container {
        padding: 10px 12px !important;
    }

    .action-bar {
        padding: 10px 12px !important;
        flex-direction: column-reverse !important;
    }

    .action-bar .rz-button {
        width: 100% !important;
    }

    .hide-on-mobile {
        display: none !important;
    }
}

/* ========================================
   SMALL (SM) - MÓVIL GRANDE (?576px y <768px)
   ======================================== */
@media (min-width: 576px) and (max-width: 767.98px) {
    .dialog-mobile .rz-dialog {
        width: 95vw !important;
        height: 92vh !important;
        max-height: 92vh !important;
    }

    .filter-toggle-btn {
        display: flex;
    }

    .filters-panel {
        position: fixed !important;
        width: 260px !important;
        transform: translateX(-100%);
    }

    .filters-panel.show {
        transform: translateX(0);
    }

    .filters-header {
        display: flex;
    }

    .filters-overlay {
        display: block;
    }

    .hide-on-mobile {
        display: none !important;
    }
}

/* ========================================
   MEDIUM (MD) - TABLET (?768px y <992px)
   CRÍTICO: iPad horizontal y vertical
   ======================================== */
@media (min-width: 768px) and (max-width: 991.98px) {
    .dialog-desktop .rz-dialog {
        width: 95vw !important;
        max-width: none !important;
        height: 88vh !important;
        max-height: 88vh !important;
    }

    /* Filtros más compactos en tablet */
    .filters-panel {
        width: 220px !important;
        min-width: 220px !important;
    }

    .filters-content {
        padding: 10px;
    }

    /* Botón toggle visible en tablet */
    .filter-toggle-btn {
        display: flex;
    }

    .filters-panel {
        position: fixed !important;
        transform: translateX(-100%);
        z-index: 1000;
    }

    .filters-panel.show {
        transform: translateX(0);
    }

    .filters-header {
        display: flex;
    }

    .filters-overlay {
        display: block;
    }

    /* Header más compacto */
    .main-header {
        padding: 10px 14px;
        gap: 8px;
    }

    /* Grid más compacto */
    .grid-container {
        padding: 10px 14px;
    }

    /* Botones más compactos */
    .action-bar {
        padding: 10px 14px;
        gap: 8px;
    }

    /* Ocultar columna Nivel en tablet */
    .hide-on-tablet {
        display: none !important;
    }

    /* Tabla más compacta */
    ::deep .rz-datatable-data td {
        padding: 8px 6px !important;
        font-size: 13px !important;
    }

    ::deep .rz-datatable-data th {
        padding: 10px 6px !important;
        font-size: 13px !important;
    }
}

/* ========================================
   TABLET HORIZONTAL (landscape)
   CRÍTICO: iPad en horizontal
   ======================================== */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .dialog-desktop .rz-dialog {
        width: 96vw !important;
        height: 90vh !important;
        max-height: 90vh !important;
    }

    /* Filtros aún más compactos en horizontal */
    .filters-panel {
        width: 200px !important;
        min-width: 200px !important;
    }

    /* Accordion más compacto */
    .accordion-button {
        padding: 8px 10px !important;
        font-size: 12px !important;
    }

    .accordion-body {
        padding: 8px 10px !important;
        font-size: 12px !important;
    }

    /* Grid súper compacto */
    .grid-container {
        padding: 8px 12px;
    }

    /* Header compacto */
    .main-header {
        padding: 8px 12px;
    }

    .results-counter,
    .selected-counter {
        font-size: 12px;
    }

    /* Botones más pequeños */
    .action-bar {
        padding: 8px 12px;
    }

    .action-bar .rz-button {
        padding: 8px 16px !important;
        font-size: 13px !important;
    }

    /* Tabla compacta */
    ::deep .rz-datatable-data td {
        padding: 6px 4px !important;
        font-size: 12px !important;
    }

    ::deep .rz-datatable-data th {
        padding: 8px 4px !important;
        font-size: 12px !important;
    }

    /* Botones de acciones más pequeños */
    .action-buttons .rz-button {
        padding: 4px 8px !important;
    }

    ::deep .rz-button-icon-only {
        width: 28px !important;
        height: 28px !important;
    }
}

/* ========================================
   TABLET VERTICAL (portrait)
   CRÍTICO: iPad en vertical
   ======================================== */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    .dialog-desktop .rz-dialog {
        width: 94vw !important;
        height: 86vh !important;
        max-height: 86vh !important;
    }

    /* Filtros en panel lateral en vertical */
    .filter-toggle-btn {
        display: flex;
    }

    .filters-panel {
        position: fixed !important;
        width: 240px !important;
        transform: translateX(-100%);
    }

    .filters-panel.show {
        transform: translateX(0);
    }

    .filters-header {
        display: flex;
    }

    .filters-overlay {
        display: block;
    }

    /* Grid y header normales */
    .grid-container {
        padding: 12px 14px;
    }

    .main-header {
        padding: 12px 14px;
    }

    .action-bar {
        padding: 12px 14px;
    }

    /* Tabla tamaño normal */
    ::deep .rz-datatable-data td {
        padding: 10px 8px !important;
        font-size: 13px !important;
    }

    ::deep .rz-datatable-data th {
        padding: 12px 8px !important;
        font-size: 13px !important;
    }
}

/* ========================================
   LARGE (LG) - DESKTOP (?992px y <1200px)
   ======================================== */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .dialog-desktop .rz-dialog {
        width: 90vw !important;
        max-width: 1000px !important;
        height: 85vh !important;
        max-height: 85vh !important;
    }

    .filter-toggle-btn {
        display: none !important;
    }

    .filters-panel {
        width: 260px !important;
    }
}

/* ========================================
   EXTRA LARGE (XL) - DESKTOP GRANDE (?1200px)
   ======================================== */
@media (min-width: 1200px) {
    .dialog-desktop .rz-dialog {
        width: 90vw !important;
        max-width: 1200px !important;
        height: 85vh !important;
        max-height: 85vh !important;
    }

    .filter-toggle-btn {
        display: none !important;
    }

    .filters-panel {
        width: 280px !important;
    }
}

/* ========================================
   SCROLL PERSONALIZADO
   ======================================== */

.filters-content::-webkit-scrollbar,
.grid-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.filters-content::-webkit-scrollbar-track,
.grid-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.filters-content::-webkit-scrollbar-thumb,
.grid-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.filters-content::-webkit-scrollbar-thumb:hover,
.grid-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ========================================
   FIX PARA RADZEN DIALOG BODY
   ======================================== */

::deep .rz-dialog-content {
    overflow: hidden !important;
}

::deep .rz-dialog {
    display: flex !important;
    flex-direction: column !important;
}
