/* ============================================
   RESPONSIVE CSS - Mobile-First Approach
   Atyrau University 2025
   ============================================ */

/* CSS Variables */
:root {
    --color-primary: #05612A;
    --color-primary-light: rgba(5, 97, 42, 0.1);
    --color-secondary: #303F9F;
    --spacing-xs: clamp(0.25rem, 1vw, 0.5rem);
    --spacing-sm: clamp(0.5rem, 2vw, 1rem);
    --spacing-md: clamp(1rem, 3vw, 1.5rem);
    --spacing-lg: clamp(1.5rem, 4vw, 2.5rem);
    --spacing-xl: clamp(2rem, 5vw, 4rem);
    --container-padding: clamp(16px, 4vw, 120px);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    --transition-base: 0.3s ease;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* Base Reset */
*, *::before, *::after { box-sizing: border-box; }

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    line-height: 1.6;
}

html, body { max-width: 100vw; overflow-x: hidden; }

a, button, input, select, textarea { 
    touch-action: manipulation; 
    -webkit-tap-highlight-color: transparent; 
}

img, iframe { max-width: 100%; height: auto; display: block; }
/* Note: video styles are in home.css - don't override here */

/* Typography */
h1 { font-size: clamp(1.75rem, 5vw, 3rem); }
h2 { font-size: clamp(1.5rem, 4vw, 2.5rem); }
h3 { font-size: clamp(1.25rem, 3vw, 2rem); }
h4 { font-size: clamp(1.1rem, 2.5vw, 1.5rem); }
p { font-size: clamp(0.9rem, 2vw, 1rem); }

/* Container */
.container, .container-fluid {
    width: 100%;
    padding-left: var(--container-padding);
    padding-right: var(--container-padding);
    margin: 0 auto;
}
.container { max-width: min(100% - 2rem, 1400px); }

/* Navbar */
.navbar-brand img {
    max-height: clamp(50px, 10vw, 123px);
    max-width: clamp(60px, 12vw, 135px);
    transition: var(--transition-base);
}

.navbar-toggler {
    display: flex;
    padding: 8px 12px;
    border: 2px solid var(--color-primary);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    z-index: 1001;
}

.navbar-toggler:focus { outline: none; box-shadow: 0 0 0 3px var(--color-primary-light); }

/* Intro blocks */
.intro__blocks {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    justify-content: center;
}

.intro__block {
    flex: 1 1 auto;
    min-width: 140px;
    max-width: 350px;
    padding: var(--spacing-md);
    transition: var(--transition-base);
}

/* News grid */
.newstar {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: var(--spacing-md);
}

.custom-card { width: 100%; max-width: 100%; height: auto; min-height: 380px; }
.custom-card-img { width: 100%; height: clamp(180px, 30vw, 250px); object-fit: cover; }

/* Info page */
.info-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin: var(--spacing-lg) auto;
    padding: var(--spacing-md);
    gap: var(--spacing-md);
}

.sidebar { width: 100%; padding: var(--spacing-md); border-bottom: 1px solid var(--color-primary); }
.content { width: 100%; flex: 1; padding: var(--spacing-md); }

/* Footer */
footer { height: auto; padding: var(--spacing-xl) var(--spacing-md); }
footer .row { flex-direction: column; gap: var(--spacing-lg); }
.footer-col { width: 100%; text-align: center; }

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    padding: 8px 0;
    padding-bottom: calc(8px + var(--safe-area-bottom));
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-decoration: none;
    color: #666;
    font-size: 10px;
    padding: 4px;
    transition: color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    cursor: pointer;
}

.mobile-nav-item i { font-size: 20px; margin-bottom: 2px; }
.mobile-nav-item:hover, .mobile-nav-item:active { color: var(--color-primary); }

/* ============================================
   MEDIA QUERIES
   ============================================ */

/* Large Smartphones (481px+) */
@media screen and (min-width: 481px) {
    .intro__block { min-width: 180px; }
    .newstar { grid-template-columns: repeat(2, 1fr); }
    footer .row { flex-direction: row; flex-wrap: wrap; }
    .footer-col { flex: 1 1 45%; max-width: 45%; }
}

/* Tablets (768px+) */
@media screen and (min-width: 768px) {
    .intro__blocks { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .intro__block { flex: 0 0 auto; min-width: 200px; }
    .newstar { grid-template-columns: repeat(3, 1fr); }
    .info-container { flex-direction: row; gap: var(--spacing-lg); }
    .sidebar { width: 280px; min-width: 280px; border-right: 1px solid var(--color-primary); border-bottom: none; }
    .content { flex: 1; }
    footer .row { flex-wrap: nowrap; }
    .footer-col { flex: 1; max-width: none; text-align: left; }
}

/* Laptops (1024px+) */
@media screen and (min-width: 1024px) {
    .navbar-toggler { display: none; }
    .navbar-collapse { display: flex !important; position: static; background: transparent; box-shadow: none; }
    .navbar-nav { flex-direction: row; align-items: center; }
    .navbar-nav .nav-link { padding: clamp(20px, 3vw, 35px) 0; margin-right: clamp(8px, 1.5vw, 15px); font-size: clamp(12px, 1.2vw, 15px); }
    .navbar-nav .nav-link::before { display: block; }
    .d-flex.justify-content-end.gap-2 { display: flex !important; }
    .newstar { grid-template-columns: repeat(4, 1fr); }
    .sidebar { width: 320px; min-width: 320px; }
    .mobile-bottom-nav { display: none !important; }
}

/* Desktop (1440px+) - Original design */
@media screen and (min-width: 1440px) {
    :root { --container-padding: 80px; }
    .container { max-width: 1400px; }
    .navbar-brand img { max-height: 123px; max-width: 135px; }
    .navbar-nav .nav-link { padding: 35px 0; margin-right: 15px; font-size: 15px; }
    .intro__block { min-width: 350px; padding: 30px 35px; }
    .newstar { grid-template-columns: repeat(5, 1fr); column-gap: 22px; row-gap: 25px; }
    .custom-card { width: 333px; height: 460px; }
    .custom-card-img { height: 250px; }
    .info-container { max-width: 1880px; margin: 90px auto; padding: 20px; gap: 50px; }
    .sidebar { width: 370px; min-width: 370px; }
    .content { width: 900px; }
    footer .footer-col { max-width: 370px; width: 300px; }
}

/* 4K (1920px+) */
@media screen and (min-width: 1920px) {
    :root { --container-padding: 120px; }
    .container { max-width: 1600px; }
}

/* Mobile Navigation (<1024px) */
@media screen and (max-width: 1023.98px) {
    .navbar-toggler { display: flex; }
    .navbar-collapse { position: absolute; top: 100%; left: 0; right: 0; background: #fff; box-shadow: var(--shadow-lg); z-index: 1050; max-height: calc(100vh - 150px); overflow-y: auto; }
    .navbar-collapse:not(.show):not(.collapsing) { display: none; } /* Не скрываем .collapsing для анимации */
    .navbar-nav { flex-direction: column; padding: var(--spacing-sm) 0; width: 100%; }
    .navbar-nav .nav-link { padding: var(--spacing-md) var(--spacing-lg); margin-right: 0; display: block; border-bottom: 1px solid rgba(0,0,0,0.05); }
    .navbar-nav .nav-link::before { display: none; }
    .d-flex.justify-content-end.gap-2 { display: none !important; }
    .mobile-bottom-nav { display: flex; }
    body { padding-bottom: calc(70px + var(--safe-area-bottom)); }
    footer { margin-bottom: 60px; }
}

/* Small Mobile (≤480px) */
@media screen and (max-width: 480px) {
    .navbar-brand img { max-height: 50px; max-width: 60px; }
    .intro__block { min-width: 100%; }
    .newstar { grid-template-columns: 1fr; }
    .footer-col { flex: 1 1 100%; max-width: 100%; }
}

/* Landscape Mobile */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .navbar-collapse { max-height: 60vh; }
}

/* Print */
@media print {
    .navbar-toggler, .mobile-bottom-nav { display: none !important; }
    .navbar-collapse { display: block !important; position: static; }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ============================================
   FIX 1: INTRO BLOCKS (Бакалавриат, Магистратура...)
   ============================================ */

/* Base mobile styles */
.intro__blocks {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    padding: 20px 15px;
}

.intro__blocks > a {
    flex: 1 1 calc(50% - 15px);
    max-width: 180px;
    min-width: 130px;
}

.intro__blocks .intro__block {
    width: 100%;
    padding: 15px 10px;
}

.intro__blocks .intro__block span {
    font-size: clamp(11px, 2.5vw, 14px);
    text-align: center;
}

.intro__blocks .card-img {
    width: clamp(25px, 6vw, 35px);
}

/* Tablet */
@media screen and (min-width: 768px) {
    .intro__blocks {
        flex-wrap: nowrap;
        gap: 20px;
    }
    
    .intro__blocks > a {
        flex: 0 0 auto;
        max-width: none;
        min-width: auto;
    }
    
    .intro__blocks .intro__block {
        min-width: 180px;
        padding: 20px 25px;
    }
    
    .intro__blocks .intro__block span {
        font-size: 14px;
    }
}

/* Desktop */
@media screen and (min-width: 1440px) {
    .intro__blocks .intro__block {
        min-width: 350px;
        padding: 30px 35px;
    }
    
    .intro__blocks .intro__block span {
        font-size: 16px;
    }
    
    .intro__blocks .card-img {
        width: 35px;
    }
}

/* ============================================
   FIX 2: NEWS SECTION (Жаңалықтар)
   ============================================ */
.ads.ms-5 {
    margin-left: 0 !important;
    padding: 20px 15px;
}

.news {
    margin-top: 30px !important;
}

.news h3 {
    font-size: clamp(1.25rem, 4vw, 1.75rem);
    margin-bottom: 20px;
}

/* News category buttons */
.news .d-flex.justify-content-center.gap-3 {
    flex-wrap: wrap;
    gap: 10px !important;
    padding: 0 10px;
}

.news .btn-outline-success {
    font-size: clamp(12px, 2.5vw, 14px);
    padding: 8px 15px;
    margin: 0 !important;
    white-space: nowrap;
}

/* News cards grid */
.newstar {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 0 10px;
}

.newstar .col {
    width: 100%;
    padding: 0;
}

.newstar .card {
    max-width: 100% !important;
    width: 100%;
    margin: 0 !important;
}

@media screen and (min-width: 576px) {
    .newstar {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media screen and (min-width: 992px) {
    .newstar {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .ads.ms-5 {
        margin-left: 3rem !important;
    }
}

@media screen and (min-width: 1200px) {
    .newstar {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media screen and (min-width: 1440px) {
    .newstar {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .news {
        margin-top: 150px !important;
    }
}

/* ============================================
   FIX 3: OUR UNIVERSITY SECTION (Біздің университет)
   ============================================ */
.our-university {
    min-height: auto !important;
    padding: 60px 15px 80px;
}

.our-university .container.position-relative {
    top: 0 !important;
    position: relative;
}

.our-university .row.justify-content-center {
    justify-content: center !important;
}

.our-university .card {
    height: 100%;
}

.our-university .card-title {
    font-size: clamp(2rem, 8vw, 3.5rem);
}

.our-university .card-text {
    font-size: clamp(14px, 3vw, 18px);
}

@media screen and (min-width: 768px) {
    .our-university {
        min-height: 500px !important;
        padding: 80px 30px 100px;
    }
}

@media screen and (min-width: 1440px) {
    .our-university {
        min-height: 900px !important;
    }
    
    .our-university .container.position-relative {
        top: 265px !important;
    }
}

/* ============================================
   FIX 4: UNIVERSITY PROJECTS (Университет жобалары)
   ============================================ */
.col-12.col-md-6.text-center h3 {
    margin-top: 80px;
}

@media screen and (max-width: 767px) {
    .col-12.col-md-6.text-center h3 {
        margin-top: 40px;
    }
}

/* FIX 5: Moved to bottom - see "FIX: ADDITIONAL SECTION - 2x2 grid" */

/* ============================================
   FIX 6: YOUTH POLICY CARDS (Жастар саясаты)
   ============================================ */
.custom-cards-wrapper {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
}

.custom-cards-wrapper > .col-12,
.custom-cards-wrapper > [class*="col-"] {
    flex: 0 0 calc(50% - 15px);
    max-width: calc(50% - 15px);
    width: auto;
    padding: 0;
}

.custom-cards-wrapper .custom-card {
    width: 100%;
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: 1 / 1.2;
    display: flex;
    flex-direction: column;
}

.custom-cards-wrapper .custom-card-img {
    height: 60% !important;
    object-fit: cover;
}

.custom-cards-wrapper .card-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.custom-cards-wrapper .card-body h5 {
    font-size: clamp(12px, 3vw, 16px);
    margin: 0;
    padding: 5px !important;
}

@media screen and (min-width: 576px) {
    .custom-cards-wrapper > .col-12,
    .custom-cards-wrapper > [class*="col-"] {
        flex: 0 0 calc(33.333% - 15px);
        max-width: calc(33.333% - 15px);
    }
}

@media screen and (min-width: 992px) {
    .custom-cards-wrapper > .col-12,
    .custom-cards-wrapper > [class*="col-"] {
        flex: 0 0 calc(25% - 15px);
        max-width: calc(25% - 15px);
    }
}

@media screen and (min-width: 1440px) {
    .custom-cards-wrapper .custom-card {
        height: 460px !important;
        aspect-ratio: auto;
    }
    
    .custom-cards-wrapper .custom-card-img {
        height: 250px !important;
    }
}

/* FIX 7: Moved to bottom - see "FIX: FOOTER - Remove white space completely" */

/* ============================================
   FIX: VIDEO & INTRO BLOCKS - Proper positioning
   Video always visible below header on all devices
   Desktop: unchanged visual appearance
   ============================================ */

/* Video container - fullscreen on all devices */
#main.position-relative {
    position: relative;
    width: 100%;
    overflow: visible;
}

#main .video-container {
    width: 100%;
    position: relative;
}

#main .video-container video {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

/* ===== MOBILE (≤767px) ===== */
@media screen and (max-width: 767px) {
    /* Video takes full viewport height minus header */
    #main .video-container {
        min-height: calc(100vh - 120px); /* 120px = approximate header height */
        max-height: calc(100vh - 80px);
    }
    
    #main .video-container video {
        width: 100%;
        height: 100%;
        min-height: inherit;
        object-fit: cover;
        object-position: center;
    }
    
    /* Intro blocks BELOW video on mobile */
    #main .intro__blocks.position-absolute {
        position: relative !important;
        transform: none !important;
        top: auto !important;
        left: auto !important;
        margin-top: 15px;
        z-index: 10;
        width: 100%;
    }
}

/* ===== MOBILE L (≤425px) ===== */
@media screen and (max-width: 426px) {
    #main .video-container {
        min-height: calc(75vh - 120px);
    }
    
    #main .video-container video {
        margin-top: 105px;
    }
}

/* ===== MOBILE M (≤375px) ===== */
@media screen and (max-width: 376px) {
    #main .video-container {
        min-height: calc(67vh - 120px);
    }
    
    #main .video-container video {
        margin-top: 105px;
    }
}

/* ===== MOBILE S (≤320px) ===== */
@media screen and (max-width: 321px) {
    #main .video-container {
        min-height: calc(60vh - 120px);
    }
    
    #main .video-container video {
        margin-top: 105px;
    }
}

/* ===== TABLET (768px - 1023px) ===== */
@media screen and (min-width: 768px) and (max-width: 1023px) {
    #main.position-relative {
        margin-bottom: 80px;
    }
    
    #main .video-container {
        min-height: 50vh;
    }
    
    #main .video-container video {
        min-height: 50vh;
    }
}

/* ===== MEDIUM SCREENS (992px - 1400px) - Navbar on two lines ===== */
@media screen and (min-width: 992px) and (max-width: 1400px) {
    /* Видео адаптируется под двухстрочный навбар */
    #main .video-container {
        margin-top: 0;
    }
    
    #main .video-container video {
        margin-top: 110px; /* Компенсация для двухстрочного навбара */
    }
}

/* ===== DESKTOP (≥1024px) - Original design, no changes ===== */
@media screen and (min-width: 1024px) {
    #main.position-relative {
        margin-bottom: 100px;
    }
    
    /* Video stays as original - no height restrictions */
    #main .video-container,
    #main .video-container video {
        min-height: auto;
        max-height: none;
    }
}

/* ===== LARGE DESKTOP (>1400px) - Single line navbar ===== */
@media screen and (min-width: 1401px) {
    #main .video-container video {
        margin-top: 0; /* Однострочный навбар - без дополнительного отступа */
    }
}

/* ===== LARGE DESKTOP (≥1440px) ===== */
@media screen and (min-width: 1440px) {
    #main.position-relative {
        margin-bottom: 120px;
    }
}

/* ============================================
   FIX: INTRO BLOCKS for 320px (Mobile S)
   ============================================ */
@media screen and (max-width: 380px) {
    .intro__blocks.position-absolute {
        gap: 8px;
        padding: 10px 8px;
        margin-top: -30px;
    }
    
    .intro__blocks.position-absolute > a {
        flex: 1 1 calc(50% - 8px);
        max-width: calc(50% - 8px);
        min-width: 0;
    }
    
    .intro__blocks .intro__block {
        padding: 10px 5px;
        min-width: 0 !important;
    }
    
    .intro__blocks .intro__block span {
        font-size: 10px;
        line-height: 1.2;
    }
    
    .intro__blocks .card-img {
        width: 22px;
    }
}

/* ============================================
   FIX: ADDITIONAL SECTION (Қосымша) - Perfect 2x2 grid
   ============================================ */
section.mb-5.pb-5 > .container > .row.text-center.fs-5 {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px 20px;
    padding: 0 15px;
    max-width: 600px;
    margin: 0 auto;
}

section.mb-5.pb-5 > .container > .row.text-center.fs-5 > * {
    width: 100% !important;
    max-width: 100% !important;
    flex: none !important;
    padding: 0;
}

/* Hide ALL empty columns */
section.mb-5.pb-5 > .container > .row.text-center.fs-5 > .col-6,
section.mb-5.pb-5 > .container > .row.text-center.fs-5 > .col-3:empty,
section.mb-5.pb-5 > .container > .row.text-center.fs-5 > div:not(:has(a)) {
    display: none !important;
}

section.mb-5.pb-5 .d-grid {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    min-height: 120px;
    justify-content: center;
}

section.mb-5.pb-5 .d-grid img {
    width: clamp(45px, 12vw, 65px);
    height: auto;
}

section.mb-5.pb-5 .d-grid span {
    font-size: clamp(12px, 3vw, 15px);
    line-height: 1.3;
    margin-top: 10px !important;
}

@media screen and (min-width: 768px) {
    section.mb-5.pb-5 > .container > .row.text-center.fs-5 {
        grid-template-columns: repeat(4, 1fr);
        gap: 30px;
        max-width: 900px;
    }
    
    section.mb-5.pb-5 .d-grid {
        min-height: 150px;
    }
}

/* ============================================
   FIX: FOOTER - Remove white space completely
   ============================================ */
footer {
    margin: 0 !important;
    padding: 30px 15px 15px !important;
}

footer .container-fluid {
    padding: 0;
    margin: 0;
}

footer .container {
    padding: 0;
    margin: 0 auto;
}

footer .row.my-5 {
    margin: 15px 0 0 0 !important;
    padding: 15px 0 !important;
}

footer .mt-5 {
    margin-top: 0 !important;
}

/* Footer logo fix */
footer .footer-col img[style*="margin-top: -80px"] {
    margin-top: 0 !important;
}

/* Footer visitor stats fix */
footer .footer-col ul[style*="margin-left: -120px"] {
    margin-left: 0 !important;
}

/* Mobile footer */
@media screen and (max-width: 767px) {
    footer {
        padding: 20px 10px 80px !important;
        overflow-x: hidden;
    }
    
    footer.px-5 {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    
    footer .row.justify-content-center {
        gap: 25px;
        margin: 0 !important;
    }
    
    footer .footer-col {
        text-align: center;
        width: 100%;
        flex: 1 1 100%;
        max-width: 100%;
        padding: 0 10px;
    }
    
    footer .footer-col ul {
        text-align: center;
        padding: 0;
        margin: 0;
    }
    
    footer .footer-col .text-start {
        text-align: center !important;
    }
    
    footer .footer-col img[style*="width:300px"] {
        width: 200px !important;
        height: auto !important;
    }
    
    footer .footer-col a.fs-4 {
        font-size: 1.1rem !important;
        word-wrap: break-word;
    }
}

/* Tablet footer */
@media screen and (min-width: 768px) and (max-width: 1023px) {
    footer {
        padding: 30px 15px 80px !important;
        overflow-x: hidden;
    }
    
    footer.px-5 {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    footer .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    footer .row.justify-content-center {
        margin: 0 !important;
        gap: 20px;
    }
    
    footer .footer-col {
        flex: 1 1 45%;
        max-width: 48%;
        padding: 0 5px;
        text-align: left;
    }
    
    footer .footer-col ul {
        padding: 0;
        margin: 0;
    }
    
    footer .footer-col a.fs-4 {
        font-size: 1rem !important;
        word-wrap: break-word;
    }
    
    footer .footer-col li a {
        font-size: 0.9rem;
        word-wrap: break-word;
    }
}

/* Laptop footer */
@media screen and (min-width: 1024px) and (max-width: 1439px) {
    footer {
        padding: 40px 20px 20px !important;
        overflow-x: hidden;
    }
    
    footer.px-5 {
        padding-left: 20px !important;
        padding-right: 20px !important;
    }
    
    footer .row.justify-content-center {
        margin: 0 !important;
        gap: 15px;
    }
    
    footer .footer-col {
        flex: 1;
        max-width: 200px;
        padding: 0 5px;
    }
    
    footer .footer-col a.fs-4 {
        font-size: 1rem !important;
    }
    
    footer .footer-col li a {
        font-size: 0.85rem;
    }
}

/* Desktop footer */
@media screen and (min-width: 1440px) {
    footer {
        padding: 40px 30px 20px !important;
    }
    
    footer .footer-col {
        max-width: 300px;
    }
}

/* ============================================
   TOP-NAVBAR - Perfect responsive design
   Works from 320px to 4K
   ============================================ */

/* iOS Safe Area */
@supports (padding-top: env(safe-area-inset-top)) {
    #header-container {
        padding-top: env(safe-area-inset-top);
    }
}

/* ===== BASE STYLES - ALL SCREENS ===== */
.top-navbar {
    width: 100%;
    padding: 8px 20px;
}

.top-navbar > .container {
    max-width: 100%;
    padding: 0;
}

.top-navbar .row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    margin: 0;
}

/* Left side: Accessibility + Social icons */
.top-navbar .col-10.d-flex {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    flex-wrap: nowrap;
}

/* Accessibility button */
.top-navbar #accessibility-mode-button {
    font-size: 13px;
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
}

.top-navbar #accessibility-mode-button:hover {
    text-decoration: underline;
}

/* Social icons */
.top-navbar .icons {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.top-navbar .icons img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Right side: Language switcher */
.top-navbar .col {
    flex: 0 0 auto;
    width: auto;
    padding: 0;
}

.top-navbar .list-group-horizontal {
    display: flex;
    flex-wrap: nowrap;
    gap: 0;
}

.top-navbar .list-group-item {
    padding: 4px 12px;
    font-size: 13px;
    background: transparent;
    border: none;
}

/* ===== TABLET (768px - 1199px) ===== */
@media screen and (max-width: 1199.98px) {
    .top-navbar {
        padding: 6px 15px;
    }
    
    .top-navbar .col-10.d-flex {
        gap: 10px;
    }
    
    .top-navbar #accessibility-mode-button {
        font-size: 11px;
    }
    
    .top-navbar .icons {
        width: 20px;
        height: 20px;
    }
    
    .top-navbar .list-group-item {
        padding: 3px 10px;
        font-size: 12px;
    }
}

/* ===== MOBILE (< 768px) ===== */
@media screen and (max-width: 767.98px) {
    .top-navbar {
        padding: 8px 10px;
    }
    
    .top-navbar .row {
        flex-direction: column;
        gap: 6px;
    }
    
    /* Top row: Accessibility + Languages */
    .top-navbar .col-10.d-flex {
        width: 100%;
        order: 1;
        justify-content: space-between;
        flex-wrap: wrap;
    }
    
    .top-navbar #accessibility-mode-button {
        font-size: 10px;
        padding: 4px 10px;
        background: rgba(255,255,255,0.1);
        border-radius: 4px;
        flex: 1;
        text-align: center;
        max-width: calc(100% - 100px);
    }
    
    /* Languages next to accessibility */
    .top-navbar .col {
        order: 1;
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
    }
    
    .top-navbar > .container > .row {
        position: relative;
    }
    
    /* Social icons - bottom row */
    .top-navbar .icons {
        width: 22px;
        height: 22px;
        order: 2;
    }
    
    .top-navbar .list-group-item {
        padding: 2px 8px;
        font-size: 11px;
    }
}

/* ===== SMALL MOBILE (< 576px) ===== */
@media screen and (max-width: 575.98px) {
    .top-navbar {
        padding: 6px 8px;
    }
    
    .top-navbar .row {
        flex-direction: column;
        gap: 5px;
    }
    
    /* Row 1: Languages centered */
    .top-navbar .col {
        position: static;
        transform: none;
        width: 100%;
        display: flex;
        justify-content: center;
        order: 1;
    }
    
    /* Row 2: Accessibility button full width */
    .top-navbar #accessibility-mode-button {
        order: 2;
        width: 100%;
        max-width: 100%;
        font-size: 9px;
        padding: 3px 8px;
        margin: 0;
    }
    
    /* Row 3: Social icons centered */
    .top-navbar .col-10.d-flex {
        order: 3;
        justify-content: center;
        gap: 10px;
        flex-wrap: nowrap;
    }
    
    .top-navbar .icons {
        width: 20px;
        height: 20px;
    }
}

/* ===== EXTRA SMALL (≤ 375px) ===== */
@media screen and (max-width: 375px) {
    .top-navbar {
        padding: 5px 6px;
    }
    
    .top-navbar #accessibility-mode-button {
        font-size: 8px;
        padding: 2px 6px;
    }
    
    .top-navbar .icons {
        width: 18px;
        height: 18px;
    }
    
    .top-navbar .col-10.d-flex {
        gap: 8px;
    }
    
    .top-navbar .list-group-item {
        padding: 2px 6px;
        font-size: 10px;
    }
}

/* ===== MINIMUM (≤ 320px) ===== */
@media screen and (max-width: 320px) {
    .top-navbar {
        padding: 4px 4px;
    }
    
    /* Hide accessibility on very small screens */
    .top-navbar #accessibility-mode-button {
        display: none;
    }
    
    .top-navbar .col-10.d-flex {
        gap: 6px;
    }
    
    .top-navbar .icons {
        width: 16px;
        height: 16px;
    }
    
    .top-navbar .list-group-item {
        padding: 2px 5px;
        font-size: 10px;
    }
}

/* ============================================
   FIX: MAIN NAVBAR - Mobile responsive
   ============================================ */

/* ===== MAIN NAVBAR - TABLET (992px - 1024px) ===== */
/* Переопределяем Bootstrap navbar-expand-lg для диапазона 992-1024px */
@media screen and (min-width: 992px) and (max-width: 1023.98px) {
    /* Navbar как на мобильных */
    .navbar.navbar-expand-lg {
        padding: 10px 15px;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    
    /* Показываем гамбургер-кнопку справа */
    .navbar.navbar-expand-lg .navbar-toggler {
        display: flex !important;
        padding: 6px 10px;
        border: 2px solid var(--color-primary, #05612A);
        order: 3; /* После поиска и кнопок */
    }
    
    /* Скрываем меню по умолчанию */
    .navbar.navbar-expand-lg .navbar-collapse {
        display: none !important;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        width: 100%;
        flex-basis: 100%;
        background: #fff;
        box-shadow: 0 8px 20px rgba(0,0,0,0.15);
        z-index: 1050;
        border-radius: 0 0 10px 10px;
        /* Анимация */
        transition: height 0.35s ease, opacity 0.35s ease;
    }
    
    /* Показываем меню когда открыто */
    .navbar.navbar-expand-lg .navbar-collapse.show,
    .navbar.navbar-expand-lg .navbar-collapse.collapsing {
        display: block !important;
    }
    
    /* Анимация при открытии/закрытии */
    .navbar.navbar-expand-lg .navbar-collapse.collapsing {
        height: 0;
        overflow: hidden;
        transition: height 0.35s ease;
    }
    
    .navbar-nav {
        flex-direction: column !important;
        padding: 10px 0;
        width: 100%;
    }
    
    .navbar-nav .nav-item {
        width: 100%;
        border-bottom: 1px solid rgba(0,0,0,0.05);
    }
    
    .navbar-nav .nav-link {
        padding: 12px 20px !important;
        font-size: 15px;
        display: block;
    }
    
    /* Кнопки поиска и т.д. */
    .d-flex.justify-content-end.gap-2 {
        order: 2;
    }
    
    #platonusBtn {
        display: none !important;
    }
}

/* ===== MAIN NAVBAR - MOBILE (< 992px) ===== */
@media screen and (max-width: 991.98px) {
    .navbar.navbar-expand-lg {
        padding: 10px 15px;
        flex-wrap: wrap;
    }
    
    .navbar-toggler {
        order: 3;
    }
    
    .d-flex.justify-content-end.gap-2 {
        order: 2;
    }
    
    .navbar-brand img {
        max-height: 60px;
        width: auto;
    }
    
    .navbar-collapse {
        width: 100%;
        flex-basis: 100%;
        background: #fff;
        box-shadow: 0 8px 20px rgba(0,0,0,0.15);
        max-height: calc(100vh - 150px);
        max-height: calc(100dvh - 150px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        z-index: 1050;
        border-radius: 0 0 10px 10px;
    }
    
    .navbar-nav {
        padding: 10px 0;
        width: 100%;
        flex-direction: column !important;
    }
    
    .navbar-nav .nav-item {
        width: 100%;
        border-bottom: 1px solid rgba(0,0,0,0.05);
    }
    
    .navbar-nav .nav-link {
        padding: 12px 20px !important;
        font-size: 15px;
        display: block;
    }
    
    #platonusBtn {
        display: none !important; /* Скрываем - есть дубль в нижней навигации */
    }
    
    #searchButton {
        padding: 5px;
    }
    
    .search-img {
        width: 20px;
        height: 20px;
    }
}

/* ===== MAIN NAVBAR - SMALL MOBILE (< 576px) ===== */
@media screen and (max-width: 575.98px) {
    .navbar.navbar-expand-lg {
        padding: 8px 10px;
    }
    
    .navbar-brand img {
        max-height: 50px;
    }
    
    .shopwindow .Search_blok {
        padding: 20px 15px;
    }
    
    .search-form {
        flex-direction: column;
        gap: 10px;
    }
    
    .search-input,
    .search-btn {
        width: 100%;
        max-width: 100%;
    }
}

/* ===== MAIN NAVBAR - EXTRA SMALL (≤ 380px) ===== */
@media screen and (max-width: 380px) {
    .navbar-brand img {
        max-height: 45px;
    }
    
    .navbar-toggler {
        padding: 4px 8px;
    }
}

/* ===== MAIN NAVBAR - DESKTOP (≥ 1024px) ===== */
@media screen and (min-width: 1024px) {
    /* Скрываем гамбургер на десктопе */
    .navbar.navbar-expand-lg .navbar-toggler {
        display: none !important;
    }
    
    /* Показываем меню горизонтально */
    .navbar.navbar-expand-lg .navbar-collapse {
        display: flex !important;
        flex-basis: auto;
    }
    
    .navbar-collapse {
        position: static;
        max-height: none;
        overflow: visible;
        box-shadow: none;
        background: transparent;
    }
    
    .navbar-nav {
        flex-direction: row !important;
    }
    
    #platonusBtn {
        display: inline-block;
    }
}

/* ===== iOS Safe Area for navbar-collapse ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media screen and (max-width: 1023.98px) {
        .navbar-collapse {
            max-height: calc(100dvh - 150px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
            padding-bottom: env(safe-area-inset-bottom);
        }
    }
}

/* ============================================
   FIX: INFO PAGE - Proper spacing after navbar
   ============================================ */

/* Kaif wrapper - базовый отступ для однострочного меню (большие экраны) */
.kaif {
    padding-top: 100px !important;
}

/* Средние экраны: меню на двух строках - большой отступ */
@media screen and (min-width: 992px) and (max-width: 1412px) {
    .kaif {
        padding-top: 190px !important;
    }
}

/* Info container */
.info-container {
    margin-top: 20px !important;
}

.info-container .content,
main.content {
    width: 100%;
    flex: 1;
    min-width: 0;
}

/* Content title visibility - ensure it's not cut off */
.content-title {
    margin-top: 0;
    padding-top: 15px;
}

/* Chapter meta info */
.chapter-meta {
    margin-top: 10px;
}

/* Sidebar proper display */
.sidebar {
    margin-top: 0;
}

/* Mobile: меньший отступ так как навбар сворачивается в гамбургер */
@media screen and (max-width: 991.98px) {
    .kaif {
        padding-top: 80px !important;
    }
    
    .info-container {
        margin-top: 15px !important;
    }
}

@media screen and (min-width: 1024px) {
    .info-container {
        display: flex;
        gap: 30px;
    }
    
    .info-container .sidebar {
        flex: 0 0 320px;
        width: 320px;
        min-width: 320px;
    }
    
    .info-container .content,
    .info-container main.content {
        flex: 1;
        width: auto;
        max-width: none;
    }
}

@media screen and (min-width: 1440px) {
    .info-container .sidebar {
        flex: 0 0 370px;
        width: 370px;
        min-width: 370px;
    }
    
    .info-container .content {
        flex: 1;
    }
}

/* ============================================
   MEDIA RESOURCES PAGES - Responsive Styles
   Applies ONLY to screens < 992px
   Desktop (≥992px) remains 100% unchanged
   ============================================ */

/* === BASE MOBILE STYLES FOR MEDIA RESOURCES === */
@media screen and (max-width: 991.98px) {
    /* Container spacing fix */
    .media-resources-page {
        margin-top: 100px !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    /* Table-based layout → CSS Grid conversion */
    .media-resources-page > table.table {
        display: block !important;
        width: 100% !important;
        border: none !important;
    }
    
    .media-resources-page > table.table > tbody {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        width: 100% !important;
    }
    
    .media-resources-page > table.table > tbody > tr {
        display: contents !important;
    }
    
    .media-resources-page > table.table > tbody > tr > td {
        display: block !important;
        width: 100% !important;
        padding: 0 !important;
        border: none !important;
    }
    
    .media-resources-page > table.table > tbody > tr > td:empty,
    .media-resources-page > table.table > tbody > tr > td:not(:has(.news-card)) {
        display: none !important;
    }
    
    /* News cards - fixed height with proper overflow */
    .media-resources-page .news-card {
        height: auto !important;
        min-height: 320px;
        max-height: 380px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    .media-resources-page .news-card .card-img-top {
        width: 100% !important;
        height: 140px !important;
        object-fit: cover !important;
        flex-shrink: 0;
    }
    
    .media-resources-page .news-card .card-body {
        flex: 1;
        display: flex;
        flex-direction: column;
        padding: 12px !important;
        overflow: hidden;
    }
    
    .media-resources-page .news-card .card-title {
        font-size: 0.9rem !important;
        line-height: 1.3 !important;
        margin-bottom: 8px !important;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        min-height: auto !important;
        max-height: 3.9em;
    }
    
    .media-resources-page .news-card .date,
    .media-resources-page .news-card .category {
        font-size: 0.75rem !important;
        margin-bottom: 4px !important;
    }
    
    /* Pagination - mobile optimized */
    .media-resources-page .custom-pagination {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 8px !important;
        padding: 0 10px !important;
    }
    
    .media-resources-page .custom-pagination .custom-page-item {
        margin: 0 !important;
    }
    
    .media-resources-page .custom-pagination .custom-page-link {
        min-width: 44px !important;
        min-height: 44px !important;
        padding: 10px 12px !important;
        font-size: 14px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 8px !important;
    }
    
    /* Bootstrap pagination */
    .media-resources-page .pagination {
        flex-wrap: wrap !important;
        gap: 5px !important;
    }
    
    .media-resources-page .pagination .page-link {
        min-width: 44px !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 8px 12px !important;
        font-size: 14px !important;
        border-radius: 8px !important;
    }
    
    /* CategoryView cards grid */
    .media-resources-page > .row > [class*="col-lg-3"],
    .media-resources-page > .row > [class*="col-md-4"],
    .media-resources-page > .row > [class*="col-sm-6"] {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        padding: 8px !important;
    }
    
    /* CategoryView card styling */
    .media-resources-page .card.news-card.h-100 {
        height: auto !important;
        min-height: 300px;
    }
    
    .media-resources-page .card.news-card.h-100 .card-img-top {
        height: 120px !important;
    }
    
    .media-resources-page .card.news-card.h-100 .card-title {
        font-size: 0.85rem !important;
        min-height: auto !important;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }
    
    .media-resources-page .card.news-card.h-100 .card-text {
        font-size: 0.75rem !important;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .media-resources-page .card.news-card.h-100 .btn-sm {
        padding: 6px 10px !important;
        font-size: 0.75rem !important;
        min-height: 44px;
    }
    
    /* Details page */
    .media-details-page > .card {
        margin: 0 !important;
        border-radius: 10px;
    }
    
    .media-details-page > .card .card-img-top {
        border-radius: 10px 10px 0 0;
        max-height: 250px;
        object-fit: cover;
    }
    
    .media-details-page > .card .card-body {
        padding: 15px !important;
    }
    
    .media-details-page > .card .card-title {
        font-size: 1.25rem !important;
        line-height: 1.3 !important;
    }
    
    .media-details-page .chapter-meta {
        flex-wrap: wrap;
        gap: 10px;
        display: flex;
    }
    
    .media-details-page .chapter-meta span {
        margin-right: 0 !important;
    }
    
    /* File viewer in details */
    #file-viewer {
        padding: 10px !important;
    }
    
    .media-details-page iframe {
        height: 400px !important;
        border-radius: 8px !important;
    }
    
    /* Page title in CategoryView */
    .media-resources-page .display-4 {
        font-size: 1.5rem !important;
    }
}

/* === SMALL MOBILE (≤575px) === */
@media screen and (max-width: 575.98px) {
    .media-resources-page {
        margin-top: 90px !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    
    /* Single column on very small screens */
    .media-resources-page > table.table > tbody {
        grid-template-columns: 1fr !important;
    }
    
    .media-resources-page > .row > [class*="col-lg-3"],
    .media-resources-page > .row > [class*="col-md-4"],
    .media-resources-page > .row > [class*="col-sm-6"] {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        padding: 10px 5px !important;
    }
    
    .media-resources-page .news-card {
        min-height: 280px;
        max-height: none;
    }
    
    .media-resources-page .news-card .card-img-top {
        height: 180px !important;
    }
    
    .media-resources-page .news-card .card-title {
        font-size: 1rem !important;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }
    
    .media-resources-page .news-card .card-body {
        padding: 15px !important;
    }
    
    /* CategoryView single column */
    .media-resources-page .card.news-card.h-100 {
        min-height: 320px;
    }
    
    .media-resources-page .card.news-card.h-100 .card-img-top {
        height: 180px !important;
    }
    
    .media-resources-page .card.news-card.h-100 .card-title {
        font-size: 1rem !important;
        -webkit-line-clamp: 3;
        line-clamp: 3;
    }
    
    .media-resources-page .card.news-card.h-100 .card-text {
        font-size: 0.85rem !important;
        -webkit-line-clamp: 3;
        line-clamp: 3;
    }
    
    /* Pagination compact */
    .media-resources-page .custom-pagination .custom-page-link,
    .media-resources-page .pagination .page-link {
        min-width: 40px !important;
        min-height: 40px !important;
        padding: 8px 10px !important;
        font-size: 13px !important;
    }
    
    /* Details page */
    .media-details-page > .card .card-img-top {
        max-height: 200px;
    }
    
    .media-details-page > .card .card-title {
        font-size: 1.1rem !important;
    }
    
    .media-details-page iframe {
        height: 350px !important;
    }
    
    .media-resources-page .display-4 {
        font-size: 1.25rem !important;
    }
}

/* === EXTRA SMALL (≤375px) === */
@media screen and (max-width: 375px) {
    .media-resources-page {
        margin-top: 85px !important;
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
    
    .media-resources-page .news-card .card-img-top {
        height: 160px !important;
    }
    
    .media-resources-page .news-card .card-title {
        font-size: 0.95rem !important;
    }
    
    .media-resources-page .news-card .date,
    .media-resources-page .news-card .category {
        font-size: 0.7rem !important;
    }
    
    .media-resources-page .card.news-card.h-100 .card-img-top {
        height: 160px !important;
    }
    
    .media-details-page iframe {
        height: 300px !important;
    }
}

/* === MINIMUM (≤320px) === */
@media screen and (max-width: 320px) {
    .media-resources-page {
        margin-top: 80px !important;
        padding-left: 5px !important;
        padding-right: 5px !important;
    }
    
    .media-resources-page .news-card .card-img-top {
        height: 140px !important;
    }
    
    .media-resources-page .news-card .card-title {
        font-size: 0.9rem !important;
    }
    
    .media-resources-page .card.news-card.h-100 .card-img-top {
        height: 140px !important;
    }
    
    .media-resources-page .custom-pagination .custom-page-link,
    .media-resources-page .pagination .page-link {
        min-width: 36px !important;
        min-height: 36px !important;
        padding: 6px 8px !important;
        font-size: 12px !important;
    }
    
    .media-details-page iframe {
        height: 250px !important;
    }
    
    .media-resources-page .display-4 {
        font-size: 1.1rem !important;
    }
}

/* === TABLET (576px - 991px) - 3 columns grid === */
@media screen and (min-width: 576px) and (max-width: 991.98px) {
    .media-resources-page {
        margin-top: 120px !important;
    }
    
    /* Table conversion to grid - target all levels */
    .media-resources-page > table.table {
        display: block !important;
        width: 100% !important;
    }
    
    .media-resources-page > table.table > tbody {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 12px !important;
        width: 100% !important;
    }
    
    .media-resources-page > table.table > tbody > tr {
        display: contents !important;
    }
    
    .media-resources-page > table.table > tbody > tr > td {
        display: block !important;
        width: 100% !important;
        padding: 0 !important;
        border: none !important;
    }
    
    .media-resources-page > table.table > tbody > tr > td:empty,
    .media-resources-page > table.table > tbody > tr > td:not(:has(.news-card)) {
        display: none !important;
    }
    
    .media-resources-page > .row > [class*="col-lg-3"],
    .media-resources-page > .row > [class*="col-md-4"],
    .media-resources-page > .row > [class*="col-sm-6"] {
        flex: 0 0 33.333% !important;
        max-width: 33.333% !important;
    }
    
    .media-resources-page .news-card {
        min-height: 280px;
        max-height: 340px;
    }
    
    .media-resources-page .news-card .card-img-top {
        height: 120px !important;
    }
    
    .media-resources-page .news-card .card-title {
        font-size: 0.8rem !important;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }
    
    .media-resources-page .news-card .date,
    .media-resources-page .news-card .category {
        font-size: 0.7rem !important;
    }
    
    .media-resources-page .card.news-card.h-100 .card-img-top {
        height: 120px !important;
    }
    
    .media-details-page > .card .card-img-top {
        max-height: 350px;
    }
    
    .media-details-page iframe {
        height: 500px !important;
    }
}

/* === iOS SAFE AREA SUPPORT === */
@supports (padding: env(safe-area-inset-bottom)) {
    @media screen and (max-width: 991.98px) {
        .media-resources-page {
            padding-bottom: calc(20px + env(safe-area-inset-bottom)) !important;
        }
        
        .media-resources-page .custom-pagination,
        .media-resources-page .pagination {
            padding-bottom: env(safe-area-inset-bottom) !important;
        }
    }
}

/* === LANDSCAPE MOBILE === */
@media screen and (max-height: 500px) and (orientation: landscape) and (max-width: 991.98px) {
    .media-resources-page {
        margin-top: 70px !important;
    }
    
    .media-resources-page .news-card {
        min-height: 250px;
        max-height: 300px;
    }
    
    .media-resources-page .news-card .card-img-top {
        height: 100px !important;
    }
    
    .media-details-page > .card .card-img-top {
        max-height: 150px;
    }
    
    .media-details-page iframe {
        height: 250px !important;
    }
}

/* === GALAXY FOLD SUPPORT (280px-320px folded) === */
@media screen and (max-width: 290px) {
    .media-resources-page {
        margin-top: 75px !important;
        padding-left: 4px !important;
        padding-right: 4px !important;
    }
    
    .media-resources-page .news-card .card-img-top {
        height: 120px !important;
    }
    
    .media-resources-page .news-card .card-title {
        font-size: 0.85rem !important;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }
    
    .media-resources-page .news-card .date,
    .media-resources-page .news-card .category {
        font-size: 0.65rem !important;
    }
    
    .media-resources-page .custom-pagination .custom-page-link,
    .media-resources-page .pagination .page-link {
        min-width: 32px !important;
        min-height: 32px !important;
        padding: 4px 6px !important;
        font-size: 11px !important;
    }
}

/* === PREVENT HORIZONTAL SCROLL === */
@media screen and (max-width: 991.98px) {
    .media-resources-page,
    .media-resources-page > table.table,
    .media-resources-page > .row {
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
    
    .media-resources-page img,
    .media-resources-page iframe {
        max-width: 100% !important;
    }
    
    /* Filter buttons - ensure visibility below navbar */
    .media-resources-page .filter-buttons,
    .media-details-page .filter-buttons {
        position: relative;
        z-index: 1;
        margin-top: 10px;
    }
}

/* === LAPTOP (1024px) - Fix filter buttons visibility under navbar === */
@media screen and (min-width: 992px) and (max-width: 1199.98px) {
    .media-resources-page {
        margin-top: 220px !important;
    }
    
    .media-details-page {
        margin-top: 220px !important;
        padding-top: 20px !important;
    }
}

/* === LAPTOP LARGE (1200px - 1399px) - navbar may wrap === */
@media screen and (min-width: 1200px) and (max-width: 1399.98px) {
    .media-resources-page {
        margin-top: 160px !important;
    }
    
    .media-details-page {
        margin-top: 160px !important;
    }
}

/* === DETAILS PAGE - Base margin-top for all screens === */
.media-details-page {
    margin-top: 8%;
}

@media screen and (max-width: 991.98px) {
    .media-details-page {
        margin-top: 100px !important;
    }
}

/* === SMALL MOBILE (320px) - Add top margin to filter buttons === */
@media screen and (max-width: 320px) {
    .media-resources-page .filter-buttons,
    .media-details-page .filter-buttons {
        margin-top: 15px !important;
        padding-top: 10px !important;
    }
}

/* ============================================
   SEARCH MODAL - Mobile Responsive Styles
   ============================================ */

/* Base mobile styles for search modal */
@media screen and (max-width: 991.98px) {
    .shopwindow {
        background: rgba(255, 255, 255, 0.98) !important;
        padding: 0 !important;
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
    }
    
    /* Close button - larger touch target */
    #modalnoye_okno {
        width: 44px !important;
        height: 44px !important;
        line-height: 40px !important;
        font-size: 32px !important;
        right: 10px !important;
        top: 10px !important;
        margin: 0 !important;
        border-width: 3px !important;
    }
    
    /* Search block container */
    .shopwindow .Search_blok {
        padding: 80px 20px 30px 20px !important;
    }
    
    /* Search form - vertical layout */
    .shopwindow .search-form {
        flex-direction: column !important;
        gap: 15px !important;
        max-width: 100% !important;
        padding: 0 10px;
    }
    
    /* Search input - full width, larger */
    .shopwindow .search-input {
        width: 100% !important;
        max-width: 100% !important;
        height: 54px !important;
        font-size: 16px !important;
        padding: 12px 16px !important;
        border-radius: 12px !important;
        border: 2px solid #05612A !important;
    }
    
    .shopwindow .search-input:focus {
        border-color: #05612A !important;
        box-shadow: 0 0 0 3px rgba(5, 97, 42, 0.2) !important;
    }
    
    /* Search button - full width, prominent */
    .shopwindow .search-btn {
        width: 100% !important;
        max-width: 100% !important;
        height: 54px !important;
        font-size: 16px !important;
        font-weight: 600 !important;
        border-radius: 12px !important;
        background-color: #05612A !important;
        border-color: #05612A !important;
        color: white !important;
    }
    
    .shopwindow .search-btn:hover,
    .shopwindow .search-btn:active {
        background-color: #044d22 !important;
        border-color: #044d22 !important;
    }
    
    /* Quick links container */
    .shopwindow .link-container {
        padding: 20px 15px !important;
        gap: 12px !important;
    }
    
    /* Quick link items */
    .shopwindow .link-container .text {
        width: calc(50% - 6px) !important;
        max-width: none !important;
        margin: 0 !important;
    }
    
    .shopwindow .link-container .text h4 {
        font-size: 14px !important;
        margin: 0 !important;
    }
    
    .shopwindow .link-container .text h4 a {
        display: block;
        padding: 14px 12px !important;
        background: #f8f9fa !important;
        border-radius: 10px !important;
        color: #333 !important;
        text-decoration: none !important;
        transition: all 0.2s ease !important;
        border: 1px solid #e9ecef !important;
    }
    
    .shopwindow .link-container .text h4 a:hover,
    .shopwindow .link-container .text h4 a:active {
        background: #05612A !important;
        color: white !important;
        border-color: #05612A !important;
    }
}

/* Small mobile - single column links */
@media screen and (max-width: 575.98px) {
    .shopwindow .Search_blok {
        padding: 70px 15px 25px 15px !important;
    }
    
    .shopwindow .search-input,
    .shopwindow .search-btn {
        height: 50px !important;
    }
    
    .shopwindow .link-container {
        padding: 15px 10px !important;
        gap: 10px !important;
    }
    
    .shopwindow .link-container .text {
        width: 100% !important;
    }
    
    .shopwindow .link-container .text h4 {
        font-size: 15px !important;
    }
    
    .shopwindow .link-container .text h4 a {
        padding: 16px 15px !important;
        text-align: left !important;
    }
}

/* Extra small mobile */
@media screen and (max-width: 375px) {
    #modalnoye_okno {
        width: 40px !important;
        height: 40px !important;
        line-height: 36px !important;
        font-size: 28px !important;
        right: 8px !important;
        top: 8px !important;
    }
    
    .shopwindow .Search_blok {
        padding: 60px 10px 20px 10px !important;
    }
    
    .shopwindow .search-input,
    .shopwindow .search-btn {
        height: 48px !important;
        font-size: 15px !important;
        border-radius: 10px !important;
    }
    
    .shopwindow .link-container .text h4 {
        font-size: 14px !important;
    }
    
    .shopwindow .link-container .text h4 a {
        padding: 14px 12px !important;
    }
}

/* Minimum width (320px) */
@media screen and (max-width: 320px) {
    .shopwindow .Search_blok {
        padding: 55px 8px 15px 8px !important;
    }
    
    .shopwindow .search-form {
        gap: 12px !important;
        padding: 0 5px;
    }
    
    .shopwindow .search-input,
    .shopwindow .search-btn {
        height: 46px !important;
        font-size: 14px !important;
    }
    
    .shopwindow .link-container {
        gap: 8px !important;
        padding: 10px 5px !important;
    }
    
    .shopwindow .link-container .text h4 a {
        padding: 12px 10px !important;
        font-size: 13px !important;
    }
}

/* iOS Safe Area Support for search modal */
@supports (padding: env(safe-area-inset-bottom)) {
    @media screen and (max-width: 991.98px) {
        .shopwindow {
            padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
        }
    }
}

/* ============================================
   INTERNAL PAGES: Bachelor, Master, Doctoral, JobOpening
   Professional responsive layout
   Desktop (≥992px) - UNTOUCHED
   ============================================ */

/* === BASE STYLES FOR INTERNAL PAGES === */
.custom-container {
    width: 100%;
    max-width: 100%;
}

.custom-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

/* === MOBILE (<768px) === */
@media screen and (max-width: 767.98px) {
    /* Container padding fix */
    .custom-container.p-5 {
        padding: 15px !important;
        padding-top: 100px !important;
    }
    
    /* Hero image section */
    .custom-container .img-container {
        margin-bottom: 15px;
    }
    
    .custom-container .img-container img {
        height: 150px;
        object-fit: cover;
    }
    
    .custom-container .text-over-image,
    .custom-container .text-over-images {
        font-size: 1.25rem !important;
        padding: 10px;
    }
    
    /* Sidebar - full width on mobile */
    .custom-row .sidebar {
        width: 100% !important;
        flex: 1 1 100%;
        order: 1;
        padding: 15px !important;
        margin-bottom: 15px;
        border-radius: 10px;
    }
    
    .custom-row .sidebar .form-label {
        font-size: 14px;
    }
    
    .custom-row .sidebar .form-check-label {
        font-size: 13px;
    }
    
    .custom-row .sidebar .btn {
        min-height: 44px;
        padding: 10px 20px;
    }
    
    /* Content area - full width */
    .custom-row .content {
        width: 100% !important;
        flex: 1 1 100%;
        order: 2;
        padding: 0 !important;
    }
    
    /* Cards grid - 1 column on mobile */
    .custom-row .content .row.gy-3 {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 15px !important;
        margin: 0 !important;
    }
    
    /* Job cards - full width */
    .custom-row .content .job-card,
    .custom-row .content .col-3 {
        width: 100% !important;
        max-width: 100% !important;
        flex: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .custom-row .content .job-card .card,
    .custom-row .content .col-3 .card {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
    }
    
    /* Card image */
    .custom-row .content .card .image-container,
    .custom-row .content .card .card-img-top {
        height: 180px !important;
        overflow: hidden;
    }
    
    .custom-row .content .card .image-container img,
    .custom-row .content .card .card-img-top {
        width: 100%;
        height: 180px !important;
        object-fit: cover;
    }
    
    /* Card content */
    .custom-row .content .card .card-content {
        padding: 15px;
    }
    
    .custom-row .content .card .card-content h5 {
        font-size: 1rem;
        line-height: 1.3;
        margin-bottom: 8px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .custom-row .content .card .card-content h6 {
        font-size: 0.85rem;
        margin-bottom: 10px;
    }
    
    .custom-row .content .card .card-content .btn {
        min-height: 44px;
        padding: 10px 20px;
        font-size: 14px;
    }
    
    /* JobOpening specific - job cards container */
    .job-cards-container {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    .job-cards-container .job-card {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
    }
    
    .job-cards-container .job-card .card-content {
        padding: 15px;
    }
    
    .job-cards-container .job-card .card-content h5 {
        font-size: 1rem;
    }
    
    .job-cards-container .job-card .card-content h3 {
        font-size: 1.25rem;
        color: #05612A;
    }
    
    .job-cards-container .job-card .detail-btn {
        min-height: 44px;
        padding: 10px 20px;
        width: 100%;
    }
    
    /* Pagination */
    .custom-container .pagination-container,
    .custom-row .content nav {
        margin-top: 20px;
    }
    
    .custom-container .pagination,
    .custom-row .content .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 5px;
    }
    
    .custom-container .pagination .page-link,
    .custom-row .content .pagination .page-link {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 8px 12px;
        font-size: 14px;
    }
}

/* === TABLET (768px - 991px) === */
@media screen and (min-width: 768px) and (max-width: 991.98px) {
    .custom-container.p-5 {
        padding: 20px !important;
        padding-top: 110px !important;
    }
    
    .custom-container .img-container img {
        height: 200px;
        object-fit: cover;
    }
    
    /* Sidebar - collapsible or side */
    .custom-row .sidebar {
        width: 100% !important;
        flex: 1 1 100%;
        padding: 20px !important;
        margin-bottom: 20px;
    }
    
    .custom-row .content {
        width: 100% !important;
        flex: 1 1 100%;
    }
    
    /* Cards grid - 2 columns */
    .custom-row .content .row.gy-3 {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px !important;
        margin: 0 !important;
    }
    
    .custom-row .content .job-card,
    .custom-row .content .col-3 {
        width: 100% !important;
        max-width: 100% !important;
        flex: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .custom-row .content .card .image-container img,
    .custom-row .content .card .card-img-top {
        height: 160px !important;
        object-fit: cover;
    }
    
    /* JobOpening - 2 columns */
    .job-cards-container {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px !important;
    }
    
    .job-cards-container .job-card {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
    }
}

/* === SMALL LAPTOP (992px - 1199px) - Two-line navbar === */
@media screen and (min-width: 992px) and (max-width: 1199.98px) {
    .custom-container.p-5 {
        padding: 25px !important;
        padding-top: 200px !important; /* Compensate for two-line navbar */
    }
    
    /* Cards grid - 3 columns */
    .custom-row .content .row.gy-3 {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 20px !important;
    }
    
    .custom-row .content .job-card,
    .custom-row .content .col-3 {
        width: 100% !important;
        max-width: 100% !important;
        flex: none !important;
        margin: 0 !important;
    }
    
    /* JobOpening - 2 columns with sidebar */
    .job-cards-container {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px !important;
    }
}

/* === MEDIUM LAPTOP (1200px - 1400px) - Two-line navbar === */
@media screen and (min-width: 1200px) and (max-width: 1400px) {
    .custom-container.p-5 {
        padding-top: 180px !important; /* Compensate for two-line navbar */
    }
}

/* === LARGE DESKTOP (>1400px) - Single line navbar === */
@media screen and (min-width: 1401px) {
    .custom-container.p-5 {
        padding-top: 120px !important; /* Single line navbar */
    }
}

/* === iOS SAFE AREA FOR INTERNAL PAGES === */
@supports (padding: env(safe-area-inset-bottom)) {
    @media screen and (max-width: 991.98px) {
        .custom-container {
            padding-bottom: calc(20px + env(safe-area-inset-bottom)) !important;
        }
    }
}

/* === TOUCH TARGETS === */
@media screen and (max-width: 991.98px) {
    .custom-row .sidebar .form-check {
        padding: 8px 0;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .custom-row .sidebar .form-check-input {
        width: 20px;
        height: 20px;
        margin-right: 10px;
    }
    
    .custom-row .sidebar .form-check-label {
        padding: 5px 0;
        cursor: pointer;
    }
    
    .custom-row .content .card .btn,
    .job-cards-container .detail-btn {
        min-height: 48px;
        touch-action: manipulation;
    }
}

/* === CARD EQUAL HEIGHT === */
.custom-row .content .job-card .card,
.custom-row .content .col-3 .card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.custom-row .content .card .card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* === PREVENT HORIZONTAL SCROLL === */
@media screen and (max-width: 991.98px) {
    .custom-container,
    .custom-row,
    .custom-row .content,
    .custom-row .content .row {
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
}
