/* ===========================================================
   COLOR ICONOS MENU
   =========================================================== */
.yellow-icon::before {
    color: #f4d03f;
}

.red-icon::before {
    color: #e53935;
}

.green-icon::before {
    color: #43a047;
}

.blue-icon::before {
    color: #1e88e5;
}

.purple-icon::before {
    color: #8e24aa;
}

/* ===========================================================
   CONTENEDORES BASE
   =========================================================== */
.page-root {
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.grid-wrap {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    height: 100%;
    display: flex;
    overflow: auto;
    max-width: 100vw;
}

.desktop-grid {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    height: 100%;
    display: flex;
    max-width: 100vw;
}

    .grid-wrap .e-grid {
        height: 100%;
        width: 100%;
    }

.desktop-only {
    display: block;
}

.mobile-only {
    display: none !important;
}

@media (max-width: 992px) {
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: block !important;
    }

    .page-root {
        height: 100vh;
        min-height: 100vh;
        padding: 0px;
        background: #f7f8fa;
        overflow: hidden;
    }
}

/* ===========================================================
   MOBILE PANEL
   =========================================================== */
@media (max-width: 992px) {
    .mobile-study-panel {
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
        padding: 0px;
        box-sizing: border-box;
        overflow-x: hidden;
        height: 100vh;
        display: flex;
        flex-direction: column;
    }

    .mobile-panel-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
        gap: 16px;
        margin-bottom: 12px;
    }

    .mobile-panel-header h2 {
        margin: 0;
        font-size: 1.5rem;
    }

    .mobile-panel-header .subtitle {
        margin: 4px 0 0;
        color: #6b7280;
        font-size: 0.95rem;
    }

    .mobile-count {
        font-weight: 600;
        color: #1976d2;
    }

    .mobile-filters {
        background: #fff;
        border: 1px solid #e0e0e0;
        border-radius: 12px;
        box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
        margin-bottom: 0;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        height: 100%;
    }

    .mobile-filters .e-accordion {
        width: 100%;
        max-width: 100%;
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .mobile-filters .e-accordion .e-acrdn-item:not(:last-child) .e-acrdn-content {
        padding-bottom: 60px !important;
        overflow-y: visible !important;
        min-height: auto !important;
    }

    .mobile-filters .e-accordion .e-acrdn-item:last-child .e-acrdn-content {
        padding: 0 !important;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        height: calc(100vh - 250px);
        max-height: calc(100vh - 250px);
    }

    .listview-container {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        height: 100%;
    }

    .mobile-filters .e-acrdn-header {
        padding: 12px 16px;
        font-size: 0.95rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-filters .e-acrdn-content {
        padding: 12px 16px 60px 16px;
        overflow-x: hidden;
        overflow-y: visible;
    }

    .mobile-filters .e-acrdn-panel {
        width: 100%;
        max-width: 100%;
    }

    .mobile-filters .e-accordion .e-acrdn-item:not(:last-child) .e-acrdn-panel {
        overflow: visible !important;
    }

    .mobile-filters .e-acrdn-content > * {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .mobile-filters .e-combobox,
    .mobile-filters .e-combobox .e-input-group {
        width: 100%;
        max-width: 100%;
    }

    .mobile-filters .e-listview {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        flex: 1 1 auto;
        min-height: 0;
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    .mobile-filters .e-listview .e-list-container {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        flex: 1 1 auto;
        min-height: 0;
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    .mobile-filters .e-listview .e-list-wrapper {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .mobile-filters .e-listview .e-list-item {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .filters-toggle {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 20px;
        border: none;
        background: transparent;
        font-size: 1rem;
        font-weight: 600;
        cursor: pointer;
    }

    .filters-toggle .toggle-indicator {
        color: #1976d2;
        font-size: 0.95rem;
    }

    .mobile-filters-body {        
        padding: 18px 20px 60px;
        display: grid;
        gap: 16px;
    }

    .mobile-filters-body.is-collapsed {
        display: none;
    }

    .filter-field {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .filter-field label {
        font-size: 0.85rem;
        font-weight: 600;
        color: #394150;
    }

    .filter-input {
        width: 100%;
    }

    .filter-input .e-input,
    .filter-input .e-input-group,
    .filter-input .e-control-wrapper,
    .filter-input .e-ddl,
    .filter-input input {
        width: 100%;
        border-radius: 8px;
        border: 1px solid #cbd5f5;
        font-size: 0.95rem;
        background-color: #fff;
    }

    .filter-input .e-input,
    .filter-input input {
        padding: 10px 12px;
    }

    .date-range {
        display: flex;
        gap: 12px;
        flex-wrap: nowrap;
        align-items: center;
    }

    .mobile-filter-date {
        flex: 1;
        min-width: 0;
    }

    .mobile-filter-date .e-input-group {
        width: 100%;
    }

    .filter-actions {
        display: flex;
        justify-content: flex-end;
        gap: 12px;
        flex-wrap: wrap;
        margin-top: 4px;
    }

    .mobile-study-panel .btn {
        border: none;
        border-radius: 8px;
        padding: 10px 18px;
        font-weight: 600;
        cursor: pointer;
        transition: transform 0.15s ease, box-shadow 0.15s ease;
    }

    .mobile-study-panel .btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
        box-shadow: none;
    }

    .mobile-study-panel .btn-primary {
        background-color: #1976d2;
        color: #fff;
        box-shadow: 0 6px 18px rgba(25, 118, 210, 0.35);
    }

    .mobile-study-panel .btn-ghost {
        background: transparent;
        border: 1px solid #cfd8dc;
        color: #374151;
    }

    .mobile-studies {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .mobile-studies-state {
        background: #fff;
        border: 1px dashed #cbd5f5;
        border-radius: 12px;
        padding: 32px 16px;
        text-align: center;
        color: #60738a;
    }

    .mobile-studies-state.error {
        border-color: #f87171;
        color: #b91c1c;
    }

    .mobile-studies-list {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    .mobile-studies-list .e-list-container {
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .mobile-studies-list .e-list-parent {
        list-style: none;
        padding: 0;
        margin: 0;
        overflow-y: auto;
        overflow-x: hidden;
        display: block;
        width: 100%;
        box-sizing: border-box;
        height: 100%;
        max-height: 100%;
    }

    .mobile-studies-list .e-list-item {
        border: none;
        padding: 0;
        margin-bottom: 14px;
        background: transparent;
    }

    .mobile-studies-list .e-list-item:last-child {
        margin-bottom: 0;
    }

    .mobile-studies-list .e-avatar {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 4px;
    }

    .mobile-studies-list .avatar-btn {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
        padding: 0 !important;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        font-size: 1.2rem !important;
        margin:15px;
    }

    .mobile-study-card {
        background: #fff;
        border-radius: 14px;
        padding: 16px;
        box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .mobile-study-card .card-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
    }

    .card-header-main {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .card-header-tags {
        display: flex;
        gap: 6px;
        align-items: center;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .mobile-study-card .study-id {
        font-weight: 600;
        color: #111827;
    }

    .card-header-main .study-name {
        font-size: 0.95rem;
        color: #374151;
    }

    .study-modality {
        background: #e3f2fd;
        color: #1565c0;
        font-weight: 600;
        padding: 2px 10px;
        border-radius: 999px;
        font-size: 0.8rem;
    }

    .study-meta-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 12px;
    }

    .meta-item {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .meta-label {
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: #9ca3af;
    }

    .meta-value {
        font-size: 0.9rem;
        color: #111827;
    }

    .meta-value span {
        color: #6b7280;
    }

    .ellipsis {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .mobile-study-card .card-actions {
        display: flex;
        justify-content: flex-end;
    }

    .mobile-study-card .btn.view {
        align-self: flex-end;
    }
}

@media (max-width: 576px) {
    .mobile-study-panel {
        padding: 0px;
    }

    .mobile-panel-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .mobile-filters {
        margin-bottom: 0px;
        border-radius: 8px;
    }

    .mobile-filters .e-acrdn-header {
        padding: 0px 1px;
        font-size: 0.9rem;
    }

    .mobile-filters .e-acrdn-content {
        padding: 8px 8px 52px 8px;
    }

    .mobile-filters-body {
        padding: 12px 12px 56px;
        gap: 12px;
    }

    .mobile-filters .e-accordion .e-acrdn-item:not(:last-child) .e-acrdn-content {
        padding-bottom: 52px !important;
        overflow-y: visible !important;
        min-height: auto !important;
    }

    .mobile-filters .e-accordion .e-acrdn-item:last-child .e-acrdn-content {
        height: calc(100vh - 200px);
        max-height: calc(100vh - 200px);
    }

    .mobile-studies-list .e-list-parent {
        height: 100%;
    }
}

/* ===========================================================
   MENU DE ACCIONES EN EL GRID
   =========================================================== */
.grid-wrap .e-grid td.e-rowcell:first-child,
.grid-wrap .e-grid th.e-headercell:first-child {
    overflow: visible !important;
    position: relative;
}

.grid-wrap .e-grid td.e-rowcell:first-child .e-menu-wrapper {
    position: relative;
    z-index: 5;
}

.grid-wrap .e-grid td.e-rowcell:first-child .e-menu-parent {
    z-index: 10;
}

/* ===========================================================
   CELDAS Y BADGES
   =========================================================== */
.study-name-cell {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.4;
}

.badge-ai {
    background-color: #1e88e5;
    border: 1px solid #1565c0;
    color: #fff;
    text-transform: uppercase;
}

.badge-ai-abnormal {
    background-color: #c62828;
    border-color: #8e0000;
}

/* ===========================================================
   MOBILE (<=768px)
   =========================================================== */
@media (max-width: 768px) {

    .page-root {
        height: 100dvh;
        overflow: hidden;
    }

    .grid-wrap {
        overflow-x: auto;
    }

        /* Toolbar adaptable */
        .grid-wrap .e-toolbar {
            flex-wrap: wrap;
            padding: 8px;
        }

            .grid-wrap .e-toolbar .e-toolbar-item {
                width: 100%;
                margin-bottom: 8px;
            }

        /* ComboBox ancho completo */
        .grid-wrap .e-combobox {
            width: 100%;
        }

        /* Grid más compacto */
        .grid-wrap .e-grid {
            font-size: 0.85rem;
        }

            /* Ajuste de columnas */
            .grid-wrap .e-grid .e-headercel:not(:nth-child(-n+4)) {
                min-width: 80px;
            }

            /* Celdas móviles */
            .grid-wrap .e-grid .e-rowcell {
                padding: 8px 4px;
                font-size: 0.8rem;
            }

        /* Menú táctil */
        .grid-wrap .e-menu-wrapper {
            min-width: 200px;
        }

            .grid-wrap .e-menu-wrapper .e-menu-item {
                padding: 12px 16px;
                font-size: 0.9rem;
            }

    /* Badges más pequeños */
    .badge {
        font-size: 0.65rem;
        padding: 0 5px;
    }

    .study-name-cell {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    /* Paginación */
    .grid-wrap .e-pager {
        padding: 8px;
    }

        .grid-wrap .e-pager .e-pagercontainer {
            flex-wrap: wrap;
            justify-content: center;
        }

        .grid-wrap .e-pager .e-numericitem,
        .grid-wrap .e-pager .e-prevpage,
        .grid-wrap .e-pager .e-nextpage {
            min-width: 40px;
            min-height: 40px;
            padding: 8px;
        }
}

/* ===========================================================
   MOBILE PEQUEÑO (<=480px)
   =========================================================== */
@media (max-width: 480px) {

    .grid-wrap .e-grid {
        font-size: 0.75rem;
    }

        .grid-wrap .e-grid .e-rowcell {
            padding: 6px 3px;
            font-size: 0.75rem;
        }

        /* Header compacto */
        .grid-wrap .e-grid .e-headercel {
            padding: 8px 4px;
            font-size: 0.75rem;
        }

            /* Ocultar columnas poco importantes */
            .grid-wrap .e-grid .e-headercel:nth-child(6),
            .grid-wrap .e-grid .e-headercel:nth-child(7),
            .grid-wrap .e-grid .e-rowcell:nth-child(6),
            .grid-wrap .e-grid .e-rowcell:nth-child(7) {
                display: none;
            }

    /* Menú táctil más grande */
    .grid-wrap .e-menu-wrapper .e-menu-item {
        padding: 14px 18px;
        min-height: 44px;
    }

    /* Badges mini */
    .badge {
        font-size: 0.6rem;
        padding: 0 4px;
    }

    /* Accordion ajustado para pantallas pequeñas */
    /*.mobile-filters .e-acrdn-header {
        padding: 8px 10px;
        font-size: 0.85rem;
    }

    .mobile-filters .e-acrdn-content {
        padding: 8px 10px;
    }

    .mobile-studies-list .e-list-parent {
        height: 100%;
    }*/
}

/* ===========================================================
   LANDSCAPE MOBILE
   =========================================================== */
@media (max-width: 768px) and (orientation: landscape) {
    .grid-wrap .e-grid {
        font-size: 0.8rem;
    }
}

#BasicCard, #NewIconCard {
    height: 180px;
    margin: 16px;
}

.listview-template.e-listview .bookmark::before {
    content: "\e700";
    margin-right: 12px;
    font-size: 16px;
}

.listview-template.e-listview .share::before {
    content: "\e701";
    margin-right: 3px;
    font-size: 13px;
}

.listview-template.e-listview .comments::before {
    content: "\e703";
    margin-right: 12px;
    font-size: 15px;
}

.e-listview.e-rtl.e-list-template .e-list-wrapper.e-list-avatar:not(.e-list-badge) {
    padding-left: 1.0666em;
    padding-right: 122px;
}

.e-listview.e-list-template .e-list-wrapper.e-list-avatar:not(.e-list-badge),
.tailwind.e-bigger .e-listview.e-list-template .e-list-wrapper.e-list-avatar,
.tailwind-dark.e-bigger .e-listview.e-list-template .e-list-wrapper.e-list-avatar {
    padding-left: 122px;
    padding-right: 1.0666em;
}

.listview-template.e-listview.e-list-template .e-list-wrapper.e-list-multi-line.e-list-avatar .e-avatar {
    background: transparent;
    width: 90px;
    height: 90px;
    top: 50%;
    transform: translateY(-50%);
}
