/* ==================== BIẾN MÀU BỆNH VIỆN ==================== */
:root {
    --hospital-blue:    #005b99;
    --hospital-blue-lt: #0077c2;
    --hospital-teal:    #00a896;
    --hospital-red:     #d32f2f;
    --hospital-bg:      #f0f4f8;
    --hospital-white:   #ffffff;
    --text-dark:        #1a2533;
    --text-muted:       #5f6b7a;
    --border-color:     #c8d6e5;
    --shadow-sm:        0 2px 8px rgba(0,91,153,0.10);
    --shadow-md:        0 8px 30px rgba(0,91,153,0.14);
    --radius-sm:        8px;
    --radius-md:        14px;
    --radius-lg:        20px;
}

/* ==================== RESET ==================== */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Arial, sans-serif;
    background: var(--hospital-bg);
    overflow-y: auto;
}

/* ==================== OVERLAY ==================== */
.modal-overlay {
    background: linear-gradient(135deg, #dce9f5 0%, #e8f4f0 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    box-sizing: border-box;
    min-height: calc(var(--vh, 1vh) * 100);
    overflow-y: auto;
}

/* ==================== POPUP CHÍNH ==================== */
.appointment-popup {
    background: var(--hospital-white);
    border-radius: var(--radius-lg);
    max-width: 1180px;
    width: 96%;
    max-height: 93vh;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    margin: auto;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
}

/* ==================== CỘT FORM ==================== */
.form-section {
    flex: 1 1 58%;
    padding: 20px 24px 16px;
    min-width: 300px;
    box-sizing: border-box;
    overflow-y: auto;
    max-height: 93vh;
    -webkit-overflow-scrolling: touch;
}

/* ==================== HEADER BỆNH VIỆN ==================== */
.hospital-header {
    display: flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(120deg, var(--hospital-blue) 0%, var(--hospital-blue-lt) 100%);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin-bottom: 10px;
    color: #fff;
}

.hospital-logo {
    font-size: 42px;
    line-height: 1;
    flex-shrink: 0;
    color: #fff;
    background: rgba(255,255,255,0.18);
    border-radius: 50%;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hospital-name {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0.3px;
    color: #fff;
    text-transform: uppercase;
    line-height: 1.3;
}

.hospital-sub {
    font-size: 12px;
    color: rgba(255,255,255,0.85);
    margin-top: 2px;
}

.hospital-hotline {
    font-size: 13px;
    margin-top: 6px;
    color: #ffe066;
    display: flex;
    align-items: center;
    gap: 5px;
}

.hospital-hotline i {
    animation: pulse 1.6s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

/* ==================== DIVIDER ==================== */
.header-divider {
    height: 3px;
    background: linear-gradient(90deg, var(--hospital-blue), var(--hospital-teal), transparent);
    border-radius: 99px;
    margin-bottom: 14px;
}

.section-divider {
    height: 1px;
    background: linear-gradient(90deg, var(--border-color), transparent);
    margin: 8px 0 12px;
}

/* ==================== TIÊU ĐỀ SECTION ==================== */
.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.section-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--hospital-blue), var(--hospital-teal));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 15px;
    flex-shrink: 0;
}

.section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--hospital-blue);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin: 0;
    border-left: 3px solid var(--hospital-teal);
    padding-left: 8px;
}

/* ==================== LABEL ==================== */
label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: var(--hospital-blue);
    margin-bottom: 4px;
}

label i {
    color: var(--hospital-teal);
}

label.required::after {
    content: " *";
    color: var(--hospital-red);
    font-weight: 700;
}

/* ==================== INPUTS ==================== */
input, select, textarea, button {
    font-size: 15px !important;
    -webkit-text-size-adjust: 100%;
}

.form-control {
    display: block;
    width: 100%;
    padding: 7px 12px;
    font-size: 15px !important;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fafdff;
    color: var(--text-dark);
}

input.form-control:focus,
select.form-control:focus,
textarea.form-control:focus {
    border-color: var(--hospital-blue-lt);
    box-shadow: 0 0 0 3px rgba(0,119,194,0.15);
    outline: none;
    background: #fff;
}

textarea.form-control {
    resize: none;
}

input[type="date"], input[type="time"] {
    -webkit-appearance: none;
    appearance: none;
    height: 38px;
    box-sizing: border-box;
}

/* ==================== KHUNG GIỜ ==================== */
.time-select {
    display: flex;
    gap: 10px;
}

.time-option {
    flex: 1;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    text-align: center;
    padding: 6px 8px;
    font-weight: 600;
    font-size: 13px;
    background: #fafdff;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-dark);
    line-height: 1.4;
}

.time-option .time-icon {
    display: block;
    font-size: 18px;
    color: var(--hospital-teal);
    margin-bottom: 2px;
}

.time-option small {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 11px;
}

.time-option.active {
    background: linear-gradient(135deg, var(--hospital-blue), var(--hospital-blue-lt));
    color: #fff;
    border-color: var(--hospital-blue);
    box-shadow: 0 3px 10px rgba(0,91,153,0.25);
}

.time-option.active .time-icon {
    color: #ffe066;
}

.time-option.active small {
    color: rgba(255,255,255,0.85);
}

.time-option:hover:not(.active) {
    border-color: var(--hospital-blue-lt);
    background: #e8f2fa;
}

/* ==================== NÚT GỬI ==================== */
.btn-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    font-size: 16px !important;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--hospital-blue) 0%, var(--hospital-teal) 100%);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.2s;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    box-shadow: 0 4px 14px rgba(0,91,153,0.3);
}

.btn-submit:hover {
    background: linear-gradient(135deg, #004a7d 0%, #007d6e 100%);
    box-shadow: 0 6px 18px rgba(0,91,153,0.4);
    transform: translateY(-1px);
}

.btn-submit:active {
    transform: translateY(0);
}

/* ==================== GHI CHÚ DƯỚI FORM ==================== */
.form-note {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 10px;
    margin-bottom: 4px;
    line-height: 1.5;
}

.form-note i {
    color: var(--hospital-teal);
}

/* ==================== CỘT ẢNH ==================== */
.image-section {
    flex: 1 1 42%;
    background: url('../lib/image/anhbv.png') center center no-repeat;
    background-size: cover;
    min-height: 400px;
    border-top-right-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
    position: relative;
}

.image-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(160deg,
        rgba(0,40,80,0.72) 0%,
        rgba(0,91,153,0.55) 50%,
        rgba(0,168,150,0.45) 100%);
    border-top-right-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
    display: flex;
    align-items: flex-end;
    padding: 32px 28px;
}

.overlay-content {
    color: #fff;
}

.overlay-icon {
    font-size: 48px;
    color: #ffe066;
    margin-bottom: 12px;
    display: block;
}

.overlay-title {
    font-size: 22px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    line-height: 1.3;
}

.overlay-desc {
    font-size: 13px;
    color: rgba(255,255,255,0.88);
    line-height: 1.6;
    margin-bottom: 16px;
}

.overlay-badges {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.badge-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

.badge-item i {
    color: #66e0b0;
    font-size: 15px;
}

/* ==================== LỖI INLINE ==================== */
.form-group {
    position: relative;
}

.inline-note {
    position: absolute;
    bottom: -22px;
    left: 4px;
    width: calc(100% - 8px);
    background: #fff;
    border: 1px solid #ffbfbf;
    color: #b30000;
    font-size: 0.76rem;
    border-radius: 6px;
    padding: 4px 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    z-index: 2;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-3px);
    animation: fadeIn 0.25s ease-in-out forwards;
}

.is-invalid {
    border-color: #ff4d4d !important;
    box-shadow: 0 0 0 3px rgba(255,77,77,0.18) !important;
}

/* ==================== ANIMATION ==================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-3px); }
    to   { opacity: 1; transform: translateY(0); }
}

.inline-note.fade-out {
    animation: fadeOut 0.4s ease-in-out forwards;
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(-4px); }
}

/* ==================== RESPONSIVE TABLET (≤992px) ==================== */
@media (max-width: 992px) {
    .appointment-popup {
        flex-direction: column;
        max-height: none;
        border-radius: var(--radius-lg);
    }

    /* Banner nằm trên, form nằm dưới */
    .image-section {
        order: -1;
        flex: 0 0 auto;
        width: 100%;
        min-height: 240px;
        border-radius: 0;
        border-top-left-radius: var(--radius-lg);
        border-top-right-radius: var(--radius-lg);
        /* Dùng ảnh + fallback gradient */
        background:
            url('../lib/image/anhbv.png') center center / cover no-repeat,
            linear-gradient(135deg, #003d6b 0%, #005b99 50%, #007d6e 100%);
    }

    .image-overlay {
        border-radius: 0;
        border-top-left-radius: var(--radius-lg);
        border-top-right-radius: var(--radius-lg);
        /* Overlay đậm hơn khi hiển thị ngang */
        background: linear-gradient(160deg,
            rgba(0,30,65,0.78) 0%,
            rgba(0,70,130,0.62) 50%,
            rgba(0,120,100,0.50) 100%);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 22px 28px;
    }

    .overlay-content {
        text-align: center;
        width: 100%;
    }

    .overlay-icon  { font-size: 40px; margin-bottom: 8px; }
    .overlay-title { font-size: 18px; margin-bottom: 8px; }
    .overlay-desc  { font-size: 13px; margin-bottom: 12px; display: block; }

    .overlay-badges {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px 18px;
        margin-top: 4px;
    }

    .badge-item { font-size: 13px; }

    .form-section {
        padding: 16px 18px;
        max-height: none;
        overflow-y: visible;
    }
}

/* ==================== RESPONSIVE MOBILE (≤768px) ==================== */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 0;                   /* form chạm mép màn hình */
        align-items: flex-start;
    }

    .appointment-popup {
        width: 100%;
        border-radius: 0;
        box-shadow: none;
    }

    /* Banner mobile: thay ảnh bằng gradient + pattern CSS,
       đảm bảo luôn hiển thị đẹp dù ảnh không load */
    .image-section {
        min-height: 270px;
        border-radius: 0 !important;
        /* Layer 1: ảnh bệnh viện (nếu có)
           Layer 2: pattern chéo nhẹ
           Layer 3: gradient nền y tế */
        background:
            url('../lib/image/anhbv.png') center 30% / cover no-repeat,
            repeating-linear-gradient(
                -45deg,
                rgba(255,255,255,0.03) 0px,
                rgba(255,255,255,0.03) 1px,
                transparent 1px,
                transparent 12px
            ),
            linear-gradient(150deg,
                #002f5c 0%,
                #005b99 45%,
                #00836e 100%);
    }

    .image-overlay {
        border-radius: 0 !important;
        background: linear-gradient(180deg,
            rgba(0,20,50,0.60) 0%,
            rgba(0,50,110,0.50) 50%,
            rgba(0,100,80,0.40) 100%);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 28px 20px 24px;
    }

    .overlay-content {
        text-align: center;
        width: 100%;
    }

    /* Icon bệnh viện lớn, nổi bật */
    .overlay-icon {
        font-size: 52px;
        color: #ffe066;
        margin-bottom: 10px;
        display: block;
        text-shadow: 0 2px 12px rgba(0,0,0,0.4);
    }

    /* Tiêu đề đầy đủ */
    .overlay-title {
        font-size: 17px;
        font-weight: 800;
        letter-spacing: 0.4px;
        margin-bottom: 8px;
        line-height: 1.35;
        text-shadow: 0 1px 6px rgba(0,0,0,0.5);
    }

    /* Mô tả hiện đầy đủ */
    .overlay-desc {
        display: block !important;
        font-size: 12.5px;
        color: rgba(255,255,255,0.90);
        margin-bottom: 14px;
        line-height: 1.55;
    }

    /* Badge nằm ngang, 2 cột */
    .overlay-badges {
        display: flex !important;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px 14px;
    }

    .badge-item {
        font-size: 12px;
        background: rgba(255,255,255,0.15);
        border: 1px solid rgba(255,255,255,0.30);
        border-radius: 20px;
        padding: 4px 10px;
        backdrop-filter: blur(4px);
    }

    .badge-item i { color: #7fffd4; font-size: 13px; }

    .hospital-logo { width: 44px; height: 44px; font-size: 24px; }
    .hospital-name { font-size: 13px; }
    .hospital-hotline { font-size: 12px; }

    .form-section { padding: 14px 14px; }
}

/* ==================== MOBILE NHỎ (≤400px) ==================== */
@media (max-width: 400px) {
    .image-section   { min-height: 250px; }
    .overlay-icon    { font-size: 44px; }
    .overlay-title   { font-size: 15px; }
    .overlay-desc    { font-size: 12px; }
    .badge-item      { font-size: 11px; padding: 3px 8px; }
}

/* ==================== SAFARI FIX ==================== */
@supports (-webkit-touch-callout: none) {
    .modal-overlay {
        height: -webkit-fill-available;
        min-height: -webkit-fill-available;
    }
}

/* ==================== DESKTOP LỚN ==================== */
@media (min-width: 1200px) {
    .appointment-popup {
        height: calc(var(--vh, 1vh) * 93);
    }
    .form-section {
        padding: 20px 28px 16px;
    }
}

/* ==================== NGĂN ZOOM iOS CHO DATE ==================== */
@media (max-width: 768px) {
    input[type="date"].form-control {
        padding-right: 0.5rem !important;
        box-sizing: border-box;
    }
    input[type="date"]::-webkit-calendar-picker-indicator {
        width: 18px;
        height: 18px;
        margin-right: 4px;
    }
}
