/* ==========================================================================
   ZYNTRA ADVANCED FILTERS & STATUS TICKS
   Design System: Clean, Modern, Elegant Medical SaaS
   ========================================================================== */

/* Contenedor principal del filtro */
.zyntra-filter-container {
    position: relative;
    display: inline-block;
    vertical-align: middle;
}

/* Botón disparador del filtro */
.zyntra-filter-btn {
    height: 36px;
    min-height: 36px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    background: #ffffff;
    color: #334155;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    box-sizing: border-box;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.zyntra-filter-btn:hover {
    border-color: #94a3b8;
    background: #f8fafc;
    color: #0f172a;
}

.zyntra-filter-btn:focus,
.zyntra-filter-btn.is-focused {
    outline: none;
    border-color: #0f766e;
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

/* Estado activo: Filtro en modo Coincidir (IN) */
.zyntra-filter-btn.is-active {
    border-color: #0d9488;
    background: #f0fdfa;
    color: #0f766e;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(13, 148, 136, 0.1);
}

/* Estado activo: Filtro en modo Excluir (NOT IN) */
.zyntra-filter-btn.is-excluded {
    border-color: #f87171;
    background: #fef2f2;
    color: #b91c1c;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(239, 68, 68, 0.1);
}

.zyntra-filter-btn-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 170px;
    display: inline-block;
}

/* Badge con el contador de elementos seleccionados */
.zyntra-filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: #0d9488;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.zyntra-filter-btn.is-excluded .zyntra-filter-badge {
    background: #ef4444;
}

/* Botón limpiar filtro (x) */
.zyntra-filter-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 13px;
    line-height: 1;
    color: #94a3b8;
    border-radius: 50%;
    margin-left: 1px;
    transition: all 0.15s ease;
}

.zyntra-filter-clear:hover {
    color: #dc2626;
    background: #fee2e2;
}

/* Caret / Flecha desplegable */
.zyntra-filter-caret {
    font-size: 10px;
    color: #64748b;
    margin-left: auto;
    transition: transform 0.2s ease;
}

.zyntra-filter-btn.is-focused .zyntra-filter-caret {
    transform: rotate(180deg);
    color: #0f766e;
}

/* Ventana desplegable flotante (Popover) */
.zyntra-filter-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 290px;
    max-width: 340px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 14px 35px -4px rgba(15, 23, 42, 0.15), 0 4px 10px -2px rgba(15, 23, 42, 0.05);
    z-index: 99999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    text-align: left;
    animation: zyntraPopoverIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes zyntraPopoverIn {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.zyntra-filter-dropdown.is-open {
    display: flex;
}

/* Segmented Control: Coincidir vs Excluir */
.zyntra-filter-mode-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    gap: 8px;
}

.zyntra-filter-mode-label {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.zyntra-filter-mode-toggle {
    display: inline-flex;
    background: #e2e8f0;
    border-radius: 7px;
    padding: 2px;
    gap: 2px;
}

.zyntra-mode-btn {
    border: none;
    background: transparent;
    padding: 4px 10px;
    font-size: 11.5px;
    font-weight: 600;
    border-radius: 5px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s ease;
}

.zyntra-mode-btn:hover {
    color: #0f172a;
}

.zyntra-mode-btn.is-active[data-mode="include"] {
    background: #ffffff;
    color: #0f766e;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.zyntra-mode-btn.is-active[data-mode="exclude"] {
    background: #ffffff;
    color: #dc2626;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Fila de búsqueda y acciones rápidas */
.zyntra-filter-search-row {
    padding: 10px 12px 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-bottom: 1px solid #f1f5f9;
}

.zyntra-filter-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.zyntra-search-icon {
    position: absolute;
    left: 9px;
    font-size: 12px;
    color: #94a3b8;
    pointer-events: none;
}

.zyntra-filter-search-input {
    width: 100%;
    height: 32px;
    min-height: 32px !important;
    padding: 4px 26px 4px 28px !important;
    font-size: 12.5px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px !important;
    box-sizing: border-box;
    background: #ffffff;
    color: #1e293b;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.zyntra-filter-search-input:focus {
    outline: none;
    border-color: #0d9488 !important;
    box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.15);
}

.zyntra-filter-search-clear {
    position: absolute;
    right: 7px;
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
}

.zyntra-filter-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.zyntra-action-btn {
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #475569;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.12s;
}

.zyntra-action-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* Lista de opciones con scroll suave */
.zyntra-filter-list {
    max-height: 230px;
    overflow-y: auto;
    padding: 6px 4px;
}

.zyntra-filter-list::-webkit-scrollbar {
    width: 5px;
}
.zyntra-filter-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.zyntra-filter-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 10px;
    margin: 1px 4px;
    border-radius: 6px;
    font-size: 12.5px;
    color: #1e293b;
    cursor: pointer;
    user-select: none;
    transition: background 0.1s ease;
}

.zyntra-filter-item:hover {
    background: #f1f5f9;
}

.zyntra-filter-item.is-selected {
    background: #f0fdfa;
    color: #0f766e;
    font-weight: 500;
}

.zyntra-filter-item input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    width: 15px;
    height: 15px;
    accent-color: #0d9488;
    border-radius: 4px;
}

.zyntra-item-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}

.zyntra-item-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.zyntra-item-count {
    font-size: 11.5px;
    font-weight: 600;
    color: #64748b;
    margin-left: auto;
    padding-left: 6px;
    flex-shrink: 0;
}

.zyntra-filter-item.is-selected .zyntra-item-count {
    color: #0d9488;
}

.zyntra-filter-empty {
    padding: 20px 12px;
    text-align: center;
    font-size: 12px;
    color: #94a3b8;
    font-style: italic;
}

/* Pie del desplegable */
.zyntra-filter-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    font-size: 11.5px;
    color: #64748b;
}

.zyntra-filter-close-btn {
    border: none;
    background: #0f766e;
    color: #ffffff;
    font-size: 11.5px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.15s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.zyntra-filter-close-btn:hover {
    background: #0d9488;
}

/* ==========================================================================
   QUICK STATUS TICKS (Tira compacta de estado rápido)
   ========================================================================== */
.quick-status-ticks-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    height: 36px;
    box-sizing: border-box;
    vertical-align: middle;
}

.status-tick-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 28px;
    padding: 0 10px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: #64748b;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    box-sizing: border-box;
    transition: all 0.15s ease;
    margin: 0;
}

.status-tick-pill:hover {
    background: rgba(255, 255, 255, 0.6);
    color: #1e293b;
}

.status-tick-input {
    display: none !important;
}

.status-tick-pill .tick-indicator {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #cbd5e1;
    display: inline-block;
    transition: all 0.15s ease;
}

/* Cerrados: Off por defecto (sutil / apagado). Al activarse: fondo blanco con borde gris neutro */
.status-tick-pill.tick-cerrados.is-checked {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #1e293b;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.status-tick-pill.tick-cerrados.is-checked .tick-indicator {
    background: #64748b;
    box-shadow: 0 0 0 2px rgba(100, 116, 139, 0.2);
}

/* Bloqueados: Off por defecto. Al estar activo: fondo blanco con acento rojo suave */
.status-tick-pill.tick-bloqueados.is-checked {
    background: #ffffff;
    border-color: #fecaca;
    color: #dc2626;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(220, 38, 38, 0.06);
}
.status-tick-pill.tick-bloqueados.is-checked .tick-indicator {
    background: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

/* Pausa: On por defecto. Al estar activo: fondo blanco con acento ámbar suave */
.status-tick-pill.tick-pausa.is-checked {
    background: #ffffff;
    border-color: #fde68a;
    color: #d97706;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(217, 119, 6, 0.06);
}
.status-tick-pill.tick-pausa.is-checked .tick-indicator {
    background: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

/* Separador visual entre grupos de filtros */
.filter-divider {
    display: inline-block;
    width: 1px;
    height: 22px;
    background: #e2e8f0;
    margin: 0 2px;
    vertical-align: middle;
}

/* ==========================================================================
   HEADER CASES COUNTER
   ========================================================================== */
.cases-header-counter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    font-size: 12.5px;
    font-weight: 600;
    color: #0f766e;
    background: #ccfbf1;
    border: 1px solid #99f6e4;
    border-radius: 16px;
    line-height: 1.2;
    vertical-align: middle;
}

/* ==========================================================================
   GROUPED CASES TABLE VIEW
   ========================================================================== */
.case-group-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.table-group-header-row {
    background: #f8fafc !important;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
    border-top: 2px solid #e2e8f0;
}

.table-group-header-row:hover {
    background: #f1f5f9 !important;
}

.table-group-header-cell {
    padding: 10px 16px !important;
    font-weight: 700;
    font-size: 13.5px;
    color: #1e293b;
    border-bottom: 1px solid #cbd5e1 !important;
}

.group-header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.group-header-left {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.group-toggle-caret {
    font-size: 11px;
    color: #64748b;
    transition: transform 0.2s ease;
    display: inline-block;
    width: 14px;
    text-align: center;
}

.table-group-header-row.is-collapsed .group-toggle-caret {
    transform: rotate(-90deg);
}

.group-count-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 12px;
    background: #e2e8f0;
    color: #475569;
    font-size: 11.5px;
    font-weight: 600;
}

.table-group-header-row:hover .group-count-badge {
    background: #cbd5e1;
    color: #1e293b;
}

.cases-table-container .table tr.case-row.is-hidden,
.cases-table-container .table tr.group-item-row.is-hidden,
.cases-table-container .table tr.is-hidden,
.table tr.case-row.is-hidden,
.table tr.group-item-row.is-hidden,
.table tr.is-hidden,
tr.case-row.is-hidden,
tr.group-item-row.is-hidden,
tr.is-hidden,
.group-item-row.is-hidden {
    display: none !important;
}

/* ==========================================================================
   SLIDER TOGGLE (TODOS CERRADOS / TODOS ABIERTOS)
   ========================================================================== */
.group-toggle-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-left: 2px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 3px 8px;
    border-radius: 6px;
    user-select: none;
    transition: all 0.15s ease;
    height: 36px;
    box-sizing: border-box;
}

.group-toggle-wrapper:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
}

.group-toggle-wrapper.is-hidden {
    display: none !important;
}

.group-switch-text {
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: color 0.15s ease, font-weight 0.15s ease;
}

.group-switch-text:hover {
    color: #0f172a;
}

.group-switch-text.is-active {
    color: #0f172a;
    font-weight: 700;
}

.group-switch-text-right.is-active {
    color: #0f766e;
}

.group-switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 18px;
    flex-shrink: 0;
    cursor: pointer;
    margin: 0 1px;
}

.group-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
    margin: 0;
}

.group-switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    border-radius: 18px;
    transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.group-switch-slider::before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background-color: #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.group-switch input:checked + .group-switch-slider {
    background-color: #0d9488;
}

.group-switch input:checked + .group-switch-slider::before {
    transform: translateX(16px);
}

.group-switch input:focus-visible + .group-switch-slider {
    box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.3);
}

/* Botón para restablecer todos los filtros */
.btn-reset-filters {
    height: 36px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    user-select: none;
    box-sizing: border-box;
}

.btn-reset-filters:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #94a3b8;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-reset-filters:active {
    background: #e2e8f0;
    transform: translateY(1px);
}

.btn-reset-filters .reset-icon {
    font-size: 14px;
    display: inline-block;
    transition: transform 0.25s ease;
}

.btn-reset-filters:hover .reset-icon {
    transform: rotate(-60deg);
}
