/* ==========================================================
   RESPONSIVE.CSS — адаптивність КП "Криворізька міська лікарня №1"
   Підключено після основних стилів, тому цей файл має пріоритет.
   ========================================================== */

:root {
    --header-bg: rgba(255,255,255,.98);
    --header-shadow: 0 6px 24px rgba(0,0,0,.08);
}

/* Базова безпека для адаптиву */
html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
    padding-top: 0 !important;
}

img, video, iframe {
    max-width: 100%;
}

img {
    height: auto;
}

table {
    width: 100%;
}

.container {
    max-width: 1180px;
}

/* Шапка */
.main-header {
    position: sticky !important;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    background: var(--header-bg) !important;
    box-shadow: var(--header-shadow);
    backdrop-filter: blur(12px);
}

.top-line {
    min-height: 66px;
    height: auto !important;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(0,0,0,.08);
}

.menu-line {
    min-height: 56px;
    height: auto !important;
    background: #fff !important;
}

.hospital-name {
    display: block;
    color: var(--accent) !important;
    line-height: 1.15;
    letter-spacing: -.02em;
    white-space: nowrap;
}

.phone-top {
    color: var(--accent) !important;
    border: 1px solid rgba(0,163,168,.28) !important;
    border-radius: 999px !important;
    background: rgba(0,163,168,.06) !important;
    font-weight: 800 !important;
    white-space: nowrap;
}

.phone-top:hover,
.phone-top:focus {
    color: #fff !important;
    background: var(--accent) !important;
}

.phone-dropdown-menu {
    width: min(380px, calc(100vw - 24px)) !important;
    max-height: min(70vh, 620px);
    overflow-y: auto;
    border: 0;
    border-radius: 16px;
    box-shadow: 0 16px 44px rgba(0,0,0,.18);
}

.social-link {
    color: var(--accent);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    background: rgba(0,163,168,.08);
}

.social-link:hover {
    color: #fff;
    background: var(--accent);
}

/* Навігація */
.navbar {
    min-height: 56px;
}

.navbar-toggler {
    border: 1px solid rgba(0,0,0,.18);
    border-radius: 12px;
    padding: .45rem .65rem;
}

.main-nav-list {
    gap: 16px;
}

.nav-link {
    border-radius: 12px;
    line-height: 1.25;
}

.dropdown-menu {
    border: 0 !important;
    border-radius: 16px !important;
    box-shadow: 0 16px 44px rgba(0,0,0,.16) !important;
}

.dropdown-item {
    white-space: normal;
    line-height: 1.25;
}

/* Головний екран */
.hero {
    min-height: clamp(560px, 72vh, 820px) !important;
    height: auto !important;
    margin-top: 0 !important;
    padding: clamp(70px, 9vw, 120px) 0 !important;
    background-position: center center !important;
}

.hero h1 {
    font-size: clamp(2.1rem, 5vw, 4.8rem);
    line-height: 1.05;
    font-weight: 800;
    text-wrap: balance;
}

.hero .lead {
    font-size: clamp(1.08rem, 2.2vw, 1.9rem) !important;
    line-height: 1.35;
}

.hero .btn {
    min-height: 58px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: normal;
    line-height: 1.2;
}

/* Секції та картки */
section {
    scroll-margin-top: 130px;
}

.services-section,
.more-services-btn {
    padding-top: clamp(48px, 7vw, 90px) !important;
    padding-bottom: clamp(48px, 7vw, 90px) !important;
}

.section-title {
    font-size: clamp(1.9rem, 4vw, 2.8rem) !important;
    line-height: 1.15;
    margin-bottom: clamp(1.8rem, 4vw, 3rem) !important;
    text-wrap: balance;
}

.service-card,
.schedule-card,
.news-card,
.event-card,
.department-card,
.structure-card {
    height: 100%;
    border-radius: 18px;
}

.service-card {
    display: flex;
    flex-direction: column;
}

.service-card img {
    height: clamp(180px, 23vw, 230px) !important;
    object-fit: cover;
}

.service-card-body {
    padding: clamp(18px, 3vw, 28px) !important;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.service-card-title {
    font-size: clamp(1.15rem, 2.2vw, 1.5rem) !important;
    line-height: 1.2;
}

.service-card-link {
    margin-top: auto;
}

/* Контентные страницы */
main {
    padding-top: clamp(32px, 6vw, 56px) !important;
    padding-bottom: clamp(32px, 6vw, 56px) !important;
}

main h1,
.page-title,
.content-title {
    font-size: clamp(1.75rem, 4vw, 3rem) !important;
    line-height: 1.15;
    overflow-wrap: anywhere;
    text-wrap: balance;
}

main h2 {
    font-size: clamp(1.45rem, 3vw, 2.2rem);
    line-height: 1.2;
}

main p,
main li {
    overflow-wrap: anywhere;
}

.card,
.list-group,
.alert {
    border-radius: 16px;
}

/* Таблицы не должны ломать экран */
.table-responsive {
    border-radius: 14px;
}

table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
}

/* Футер */
footer {
    padding: clamp(44px, 7vw, 80px) 0 32px !important;
}

.footer-menu {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px 20px;
}

.footer-menu a {
    margin: 0 !important;
    display: inline-flex;
    min-height: 34px;
    align-items: center;
}

/* 1200–1399 */
@media (max-width: 1399.98px) {
    .main-nav-list {
        gap: 8px;
    }

    .nav-link {
        font-size: .82rem !important;
        padding: .48rem .45rem !important;
        letter-spacing: .02em;
    }

    .hospital-name {
        font-size: 1.35rem !important;
    }

    .phone-top {
        font-size: .92rem !important;
        padding: .42rem .7rem !important;
    }
}

/* 992–1199 */
@media (max-width: 1199.98px) and (min-width: 992px) {
    .main-nav-list {
        gap: 3px;
    }

    .nav-link {
        font-size: .74rem !important;
        padding: .45rem .32rem !important;
    }

    .dropdown-toggle::after {
        margin-left: .15rem;
    }
}

/* Планшеты и телефоны */
@media (max-width: 991.98px) {
    .top-line {
        min-height: 58px;
        padding: 6px 0;
    }

    .menu-line {
        min-height: 52px;
    }

    .hospital-name {
        font-size: 1.2rem !important;
        white-space: normal;
    }

    .phone-top {
        font-size: 0 !important;
        width: 42px;
        height: 42px;
        padding: 0 !important;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .phone-top i {
        font-size: 1.05rem;
        margin: 0 !important;
    }

    .phone-top::after {
        display: none;
    }

    .social-icons {
        gap: 8px !important;
    }

    .social-link {
        width: 38px;
        height: 38px;
    }

    .navbar {
        padding: 6px 0 !important;
    }

    .navbar-collapse {
        margin-top: 8px;
        padding: 10px;
        max-height: calc(100vh - 124px);
        overflow-y: auto;
        background: #fff;
        border-radius: 16px;
        box-shadow: 0 16px 44px rgba(0,0,0,.14);
    }

    .main-nav-list {
        align-items: stretch !important;
        gap: 4px;
    }

    .nav-link {
        font-size: .96rem !important;
        padding: .8rem .95rem !important;
        text-align: left;
    }

    .dropdown:hover .dropdown-menu {
        display: none;
    }

    .dropdown-menu.show {
        display: block !important;
        position: static !important;
        transform: none !important;
        max-height: none !important;
        overflow: visible !important;
        margin: 2px 0 8px !important;
        box-shadow: none !important;
        border: 1px solid rgba(0,0,0,.08) !important;
        background: #f8f9fa !important;
    }

    .dropdown-item {
        padding: .72rem 1rem !important;
        font-size: .9rem !important;
    }

    section {
        scroll-margin-top: 118px;
    }

    .hero {
        min-height: calc(100svh - 110px) !important;
        padding: 54px 0 60px !important;
    }

    .hero .btn {
        width: 100%;
        max-width: 520px;
        font-size: 1.05rem !important;
        padding: .95rem 1rem !important;
    }

    .service-card:hover {
        transform: none !important;
    }

    .schedule-card {
        flex-direction: column;
        align-items: stretch !important;
    }
}

/* Телефоны */
@media (max-width: 575.98px) {
    .container {
        padding-left: 16px;
        padding-right: 16px;
    }

    .top-line .row {
        gap: 6px;
    }

    .hospital-name {
        max-width: 146px;
        font-size: 1.05rem !important;
    }

    .phone-dropdown-menu {
        position: fixed !important;
        top: 62px !important;
        left: 12px !important;
        right: 12px !important;
        width: auto !important;
        max-height: calc(100svh - 90px);
        transform: none !important;
    }

    .hero {
        min-height: calc(100svh - 104px) !important;
        padding: 42px 0 50px !important;
    }

    .hero h1 {
        font-size: clamp(1.85rem, 10vw, 2.65rem);
    }

    .hero .lead {
        margin-top: 1rem !important;
    }

    .section-title {
        letter-spacing: 0;
    }

    .row.g-5 {
        --bs-gutter-y: 1.5rem;
    }

    .service-card img {
        height: 190px !important;
    }

    main .container,
    section .container {
        max-width: 100%;
    }

    main h1 {
        margin-bottom: 1.6rem !important;
    }

    .btn-lg {
        font-size: 1rem !important;
        padding: .85rem 1rem !important;
    }

    .footer-menu {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }

    .footer-menu a {
        width: 100%;
        justify-content: center;
        padding: 7px 0;
    }
}

/* Очень узкие экраны */
@media (max-width: 380px) {
    .hospital-name {
        max-width: 118px;
        font-size: .96rem !important;
    }

    .social-icons {
        display: none !important;
    }

    .navbar-collapse {
        max-height: calc(100vh - 112px);
    }

    .hero h1 {
        font-size: 1.75rem;
    }
}

/* Печать */
@media print {
    .main-header,
    footer,
    .btn,
    .navbar {
        display: none !important;
    }

    body {
        overflow: visible;
    }

    main {
        padding: 0 !important;
    }
}
