/* Page shell compaction for Thesis Titles to bring table into initial viewport */
.page-content-section:has(.thesis-titles-page) .container--page,
.page-content-section--items:has(.thesis-titles-page) .container--page,
body:has(.thesis-titles-page) .container--page {
    width: 96% !important;
    max-width: 1560px !important;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
}

body:has(.thesis-titles-page) .page-content-section--items {
    padding-top: 0.35rem !important;
    padding-bottom: 1.5rem !important;
}

body:has(.thesis-titles-page) .page-breadcrumb {
    margin-bottom: 0.25rem !important;
    padding: 0 !important;
}

body:has(.thesis-titles-page) .page-breadcrumb__list {
    margin-bottom: 0 !important;
}

body:has(.thesis-titles-page) .page-inner-hero {
    padding: 0.25rem 0 0.35rem !important;
    margin-bottom: 0.25rem !important;
}

body:has(.thesis-titles-page) .page-inner-hero__kicker {
    display: inline-block !important;
    font-size: 0.75rem !important;
    padding: 1px 8px !important;
    margin-bottom: 2px !important;
}

body:has(.thesis-titles-page) .page-inner-hero__title {
    font-size: 1.25rem !important;
    margin: 0 0 0.15rem !important;
    display: inline-block !important;
}

body:has(.thesis-titles-page) .page-inner-hero__line {
    display: none !important;
}

body:has(.thesis-titles-page) .cms-fancy-box {
    padding: 0.5rem 0.85rem 0.65rem !important;
    border-radius: 12px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04) !important;
    border: 1px solid rgba(133, 0, 62, 0.08) !important;
}

body:has(.thesis-titles-page) .cms-fancy-box__accent {
    height: 3px !important;
}

.thesis-titles-page > p:first-child {
    margin: 0 0 0.35rem !important;
    font-size: 0.84rem !important;
    color: #64748b !important;
    line-height: 1.5 !important;
}

.thesis-titles-count {
    display: inline-flex !important;
    align-items: center !important;
    margin: 0 0 0.45rem !important;
    padding: 0.2rem 0.75rem !important;
    border-radius: 8px !important;
    background: rgba(133, 0, 62, 0.07) !important;
    color: #85003e !important;
    font-size: 0.82rem !important;
    font-weight: 700 !important;
}

/* Optimized table sizing to avoid horizontal scrollbar */
.thesis-titles-scroll.aryan-table-scroll,
.thesis-titles-scroll {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border: 1px solid rgba(133, 0, 62, 0.12) !important;
    border-radius: 12px !important;
    background: #fff !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
    max-height: calc(100vh - 200px) !important;
    min-height: 400px !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

@media (min-width: 992px) {
    .thesis-titles-table {
        width: 100% !important;
        min-width: 100% !important;
        table-layout: auto !important;
    }
    .thesis-titles-table th,
    .thesis-titles-table td {
        padding: 0.5rem 0.45rem !important;
        font-size: 0.82rem !important;
    }
    .thesis-titles-table th:first-child,
    .thesis-titles-table td:first-child {
        width: 52px !important;
        text-align: center !important;
    }
    .thesis-titles-table th:nth-child(2),
    .thesis-titles-table td:nth-child(2) {
        min-width: 180px !important;
        max-width: 380px !important;
        text-align: right !important;
    }
    .thesis-titles-table th:nth-child(3),
    .thesis-titles-table td:nth-child(3),
    .thesis-titles-table th:nth-child(4),
    .thesis-titles-table td:nth-child(4),
    .thesis-titles-table th:nth-child(5),
    .thesis-titles-table td:nth-child(5),
    .thesis-titles-table th:nth-child(6),
    .thesis-titles-table td:nth-child(6) {
        white-space: nowrap !important;
    }
    .thesis-titles-table th:nth-child(7),
    .thesis-titles-table td:nth-child(7),
    .thesis-titles-table th:nth-child(8),
    .thesis-titles-table td:nth-child(8) {
        white-space: nowrap !important;
        text-align: center !important;
    }
}


/* Thesis titles — full legacy table, scrollable on all viewports */

.thesis-titles-page {
    max-width: 100%;
    min-width: 0;
}

.thesis-titles-count {
    margin: 0 0 1rem;
    padding: 0.55rem 0.85rem;
    border-radius: 10px;
    background: rgba(133, 0, 62, 0.07);
    color: #5c4f56;
    font-size: 0.92rem;
    font-weight: 700;
}

/* Beat aryan-v3 mobile overflow:visible + body overflow-x:hidden clipping */
.cms-item__inner:has(.thesis-titles-scroll),
.cms-fancy-box:has(.thesis-titles-scroll),
.cms-prose-block:has(.thesis-titles-scroll),
.cms-fancy-box-text:has(.thesis-titles-scroll),
.aryan-legacy-content:has(.thesis-titles-scroll) {
    overflow: visible !important;
    max-width: 100%;
    min-width: 0;
}

.thesis-titles-scroll.aryan-table-scroll,
.thesis-titles-scroll {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 0 1.25rem;
    border: 1px solid rgba(133, 0, 62, 0.12) !important;
    border-radius: 12px;
    background: #fff !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
    max-height: min(70vh, 42rem);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.thesis-titles-table {
    width: 100%;
    min-width: 920px;
    border-collapse: collapse;
    font-size: 0.88rem;
    line-height: 1.65;
    margin: 0 !important;
}

.thesis-titles-table thead th,
.cms-page-items .thesis-titles-table thead th,
.aryan-legacy-content .thesis-titles-table thead th,
.cms-page-items .thesis-titles-table tr:first-child th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #85003e !important;
    color: #fff !important;
    font-weight: 700;
    padding: 0.7rem 0.65rem;
    text-align: center;
    white-space: nowrap;
    border-bottom: 0 !important;
}

.thesis-titles-table tbody td,
.cms-page-items .thesis-titles-table tbody td,
.aryan-legacy-content .thesis-titles-table tbody td {
    padding: 0.65rem 0.6rem;
    border-bottom: 1px solid rgba(133, 0, 62, 0.08);
    text-align: center;
    vertical-align: top;
    color: #1a1216 !important;
    background: transparent;
}

.thesis-titles-table tbody td:nth-child(2) {
    text-align: right;
    font-weight: 600;
    min-width: 16rem;
}

.thesis-titles-table tbody tr:nth-child(even) td {
    background: #fbf7f9;
}

.thesis-titles-table tbody tr:hover td {
    background: rgba(133, 0, 62, 0.06);
}

.thesis-titles-note {
    margin: 0;
    color: #5c4f56;
    font-size: 0.92rem;
    line-height: 1.75;
}

@media (max-width: 767.98px) {
    .thesis-titles-scroll.aryan-table-scroll:has(.aryan-table--stack),
    .thesis-titles-scroll:has(.aryan-table--stack),
    .aryan-table-scroll:has(.thesis-titles-table.aryan-table--stack) {
        overflow: visible !important;
        border: 0 !important;
        background: transparent !important;
        max-height: none !important;
        margin: 0.35rem 0 1rem !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }

    .thesis-titles-table.aryan-table--stack,
    table.thesis-titles-table.aryan-table--stack {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        border: 0 !important;
        background: transparent !important;
    }

    .thesis-titles-table.aryan-table--stack thead,
    .thesis-titles-table.aryan-table--stack tr.aryan-table__head-row {
        display: none !important;
    }

    .thesis-titles-table.aryan-table--stack tbody {
        display: block !important;
        width: 100% !important;
    }

    .thesis-titles-table.aryan-table--stack tbody tr {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box;
        margin: 0 0 0.85rem;
        padding: 0.9rem 1rem 0.8rem;
        border: 1px solid rgba(133, 0, 62, 0.14);
        border-radius: 14px;
        background: #fff !important;
        box-shadow: 0 4px 14px rgba(26, 18, 22, 0.05);
    }

    .thesis-titles-table.aryan-table--stack tbody tr:nth-child(even) td,
    .thesis-titles-table.aryan-table--stack tbody tr:hover td,
    .thesis-titles-table.aryan-table--stack tbody td {
        background: transparent !important;
        color: #1a1216 !important;
    }

    .thesis-titles-table.aryan-table--stack tbody td {
        display: grid !important;
        grid-template-columns: minmax(5.5rem, 34%) minmax(0, 1fr);
        align-items: start;
        column-gap: 0.7rem;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        padding: 0.5rem 0 !important;
        border: 0 !important;
        border-bottom: 1px dashed rgba(133, 0, 62, 0.12) !important;
        text-align: right !important;
        white-space: normal !important;
        word-break: break-word !important;
        overflow-wrap: anywhere !important;
        font-size: 0.88rem !important;
        line-height: 1.65 !important;
        direction: rtl;
    }

    .thesis-titles-table.aryan-table--stack tbody td:nth-child(2) {
        text-align: right !important;
        min-width: 0 !important;
    }

    .thesis-titles-table.aryan-table--stack tbody td:last-child {
        border-bottom: 0 !important;
    }

    .thesis-titles-table.aryan-table--stack tbody td::before {
        content: attr(data-label);
        color: #5c002b;
        font-weight: 800;
        font-size: 0.76rem;
        line-height: 1.5;
        text-align: right;
    }

    .thesis-titles-table.aryan-table--stack tbody td:not([data-label])::before,
    .thesis-titles-table.aryan-table--stack tbody td[data-label=""]::before {
        display: none;
    }

    .thesis-titles-table.aryan-table--stack tbody td:not([data-label]),
    .thesis-titles-table.aryan-table--stack tbody td[data-label=""] {
        grid-template-columns: 1fr;
    }

    @media (max-width: 419.98px) {
        .thesis-titles-table.aryan-table--stack tbody td {
            grid-template-columns: 1fr;
        }
    }
}


/* --- Thesis Article Badges & Interactive Modal --- */
.thesis-article-actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    justify-content: flex-start;
}

.thesis-art-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: none !important;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
    line-height: 1.4;
    font-family: inherit;
}

.thesis-art-btn--pdf {
    background: #eff6ff;
    color: #1d4ed8 !important;
    border-color: #bfdbfe;
}
.thesis-art-btn--pdf:hover {
    background: #1d4ed8;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(29, 78, 216, 0.25);
}

.thesis-art-btn--txt {
    background: #fdf2f8;
    color: #9d174d !important;
    border-color: #fbcfe8;
}
.thesis-art-btn--txt:hover {
    background: #9d174d;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(157, 23, 77, 0.25);
}

.thesis-article-empty {
    color: #94a3b8;
    font-size: 0.85rem;
}

/* Modal styles */
.thesis-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10500;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: thesisFadeIn 0.2s ease;
}

@keyframes thesisFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.thesis-modal-box {
    background: #ffffff;
    border-radius: 16px;
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(133, 0, 62, 0.15);
    overflow: hidden;
    direction: rtl;
    text-align: right;
    animation: thesisSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes thesisSlideUp {
    from { transform: translateY(20px) scale(0.97); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.thesis-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: #fafafa;
    border-bottom: 1px solid #e2e8f0;
}

.thesis-modal-close {
    background: #f1f5f9;
    border: none;
    font-size: 1.1rem;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}
.thesis-modal-close:hover {
    background: #fee2e2;
    color: #dc2626;
}

.thesis-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    font-size: 0.92rem;
    line-height: 1.8;
    color: #334155;
}

.thesis-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 1.25rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1.25rem;
}

@media (max-width: 576px) {
    .thesis-meta-grid {
        grid-template-columns: 1fr;
    }
}

.thesis-meta-item {
    font-size: 0.88rem;
}
.thesis-meta-label {
    color: #64748b;
    font-size: 0.82rem;
    margin-inline-end: 4px;
}
.thesis-meta-val {
    color: #1e293b;
}

.thesis-article-text-container {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.25rem;
}

.thesis-article-text-header {
    font-weight: 800;
    color: #85003e;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
}

.thesis-article-text-body {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.9rem;
    line-height: 1.85;
    color: #1e293b;
    max-height: 300px;
    overflow-y: auto;
    padding-inline-end: 4px;
}

.thesis-modal-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #0284c7;
    color: #ffffff !important;
    padding: 8px 18px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.88rem;
    text-decoration: none !important;
    box-shadow: 0 3px 10px rgba(2, 132, 199, 0.25);
    transition: all 0.2s ease;
    font-family: inherit;
}
.thesis-modal-download-btn:hover {
    background: #0369a1;
}
