:root {
  --primary: #0b5ed7;
  --primary-dark: #0a53be;
  --secondary: #e7f1ff;
  --accent: #fd7e14;
  --text: #1d2a2d;
  --muted: #6c757d;
  --surface: #ffffff;
  --surface-alt: #f8f9fa;
  --border: #dee2e6;
  --danger: #dc3545;
  --success: #198754;
  --shadow: 0 10px 30px rgba(11, 94, 215, 0.08);
  --radius: 16px;
  --max-width: 1180px;
}

* { box-sizing: border-box; }

/* CHỐNG TRÀN VIỀN NGANG VÀ KHOẢNG TRẮNG */
html, body {
  overflow-x: hidden; 
  width: 100%;
  margin: 0;
  padding: 0;
  color: var(--text);
  background: var(--surface);
  font-family: "Segoe UI", system-ui, Arial, sans-serif;
  line-height: 1.6;
  scroll-behavior: smooth;
}

body.chat-open { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

/* ==========================================
   CẤU HÌNH HEADER (CHỐNG LỖI HIỂN THỊ)
========================================== */

/* 1. Header chuẩn cho mọi thiết bị (Cố định) */
.site-header {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  z-index: 9999 !important;
  background: #ffffff !important;
  border-bottom: 1px solid var(--border);
  transition: box-shadow 0.3s ease;
}

.nav-wrap {
  width: min(calc(100% - 32px), var(--max-width)); 
  margin: 0 auto; 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  gap: 24px;
}

/* Ẩn các thành phần mobile theo mặc định */
.mobile-topbar, .mobile-quick-actions, .mobile-bottom-nav, .mobile-contact-sheet { 
  display: none; 
}

/* 2. TỐI ƯU RIÊNG CHO MÁY TÍNH (> 760px) */
@media (min-width: 761px) {
  .nav-wrap { min-height: 76px; }
  body { padding-top: 76px !important; }
  .site-header { display: block !important; }
  .mobile-topbar { display: none !important; }
}

/* ========================================== */

.skip-link { position: fixed; top: -80px; left: 12px; z-index: 2000; padding: 10px 14px; color: #fff; background: var(--primary-dark); border-radius: 8px; }
.skip-link:focus { top: 12px; }

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; color: #fff; background: var(--primary); border-radius: 50%; font-weight: 800; }
.brand strong, .brand small { display: block; line-height: 1.25; }
.brand strong { font-size: 0.98rem; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 0.78rem; }

.main-nav { display: flex; align-items: center; gap: 6px; }
.main-nav a { padding: 9px 13px; border-radius: 999px; font-size: 0.93rem; font-weight: 650; }
.main-nav a:hover { color: var(--primary); background: var(--secondary); }
.main-nav .nav-cta { color: #fff; background: var(--primary); }
.main-nav .nav-cta:hover { color: #fff; background: var(--primary-dark); }
.menu-toggle { display: none; }

.hero { width: min(calc(100% - 32px), var(--max-width)); margin: 0 auto; padding: 40px 0; display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 30px; align-items: center; }
.eyebrow { margin: 0 0 10px; color: var(--primary); font-size: 0.8rem; font-weight: 800; letter-spacing: 1.4px; }
.hero h1 { margin: 0; font-size: clamp(2rem, 3.25vw, 3.2rem); line-height: 1.1; letter-spacing: -1px; }
.hero-subtitle { margin: 15px 0 0; color: var(--accent); font-size: 1.2rem; font-weight: 750; }
.hero-description { margin: 15px 0 0; color: var(--muted); font-size: 1.05rem; }
.hero-actions { margin-top: 25px; display: flex; flex-wrap: wrap; gap: 12px; }

.btn { min-height: 48px; padding: 12px 22px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 12px; cursor: pointer; font-weight: 700; transition: transform 0.2s, background 0.2s; }
.btn:hover { transform: translateY(-2px); }
.btn-primary { color: #fff; background: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { color: var(--primary); background: var(--secondary); border: 1px solid #b6d4fe; }

.hero-trust { margin-top: 25px; display: flex; flex-wrap: wrap; gap: 10px 18px; color: #43575a; font-size: 0.92rem; }
.doctor-card { padding: 30px; background: #fff; border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow); }
.doctor-avatar { width: 140px; height: 140px; margin: 0 auto 20px; border-radius: 50%; border: 6px solid var(--secondary); overflow: hidden; }
.doctor-card h2, .doctor-card p { text-align: center; }
.doctor-card h2 { margin: 0; font-size: 1.3rem; }
.doctor-card p { margin: 6px 0; color: var(--muted); }
.doctor-card-line { height: 1px; margin: 20px 0; background: var(--border); }
.doctor-card ul { margin: 0; padding: 0; display: grid; gap: 10px; list-style: none; }
.doctor-card li { padding-left: 25px; position: relative; font-size: 0.95rem;}
.doctor-card li::before { content: "✓"; position: absolute; left: 0; color: var(--primary); font-weight: 800; }

.section { padding: 40px max(15px, calc((100% - var(--max-width)) / 2)); }
.section-alt { background: var(--surface-alt); }
.section-heading { max-width: 750px; margin-bottom: 30px; }
.section-heading h2 { margin: 0; font-size: clamp(1.6rem, 3vw, 2.4rem); line-height: 1.2; }
.section-heading > p:last-child { color: var(--muted); margin-top: 10px;}

.feature-grid, .specialty-grid, .article-grid { display: grid; gap: 15px; }
.feature-grid { grid-template-columns: repeat(4, 1fr); }
.feature-card, .specialty-card, .article-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); transition: transform 0.2s, box-shadow 0.2s; }
.feature-card:hover, .specialty-card:hover, .article-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.feature-card { padding: 20px; }
.feature-card .icon { font-size: 1.8rem; }
.feature-card h3, .specialty-card h3, .article-card h3 { margin: 12px 0 6px; font-size: 1.1rem; }
.feature-card p, .specialty-card p, .article-card p { margin: 0; color: var(--muted); font-size: 0.9rem;}

.specialty-grid { grid-template-columns: repeat(4, 1fr); }
.specialty-card { padding: 20px; border-top: 4px solid var(--primary); }
.specialty-card h3 { margin-top: 0; }

.service-list { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.service-list article { padding: 20px; display: flex; align-items: flex-start; gap: 15px; border: 1px solid var(--border); border-radius: var(--radius); }
.service-list article > span { width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center; color: var(--primary); background: var(--secondary); border-radius: 10px; font-weight: 800; }
.service-list h3 { margin: 0 0 5px; font-size: 1.05rem;}
.service-list p { margin: 0; color: var(--muted); font-size: 0.9rem; }

.article-grid { grid-template-columns: repeat(4, 1fr); }
.article-card { padding: 20px; }
.article-tag { display: inline-block; padding: 4px 10px; color: var(--primary); background: var(--secondary); border-radius: 999px; font-size: 0.75rem; font-weight: 700; }

.booking-section { display: grid; grid-template-columns: 0.8fr 1.2fr; gap: 40px; align-items: start; background: #e7f1ff; }
.emergency-box { margin-top: 20px; padding: 15px; background: #fff3cd; border: 1px solid #ffeeba; border-radius: 12px; }
.emergency-box strong { color: #856404; }
.emergency-box p { margin: 5px 0 0; color: #856404; font-size: 0.9rem;}
.emergency-box a { color: var(--danger); font-weight: 800; }

.form-card { padding: 25px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.field { margin-bottom: 15px; }
.field label { display: block; margin-bottom: 5px; font-weight: 600; font-size: 0.9rem;}
.field label span { color: var(--danger); }
input, select, textarea { width: 100%; color: var(--text); background: #fff; border: 1px solid #ced4da; border-radius: 8px; outline: none; }
input, select { min-height: 44px; padding: 0 12px; font-size: 15px;}
textarea { padding: 12px; resize: vertical; font-size: 15px;}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(11, 94, 215, 0.15); }
.field-error { display: block; min-height: 16px; margin-top: 4px; color: var(--danger); font-size: 0.8rem;}
.consent { margin: 4px 0; display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 0.85rem;}
.consent input { width: 16px; min-height: 16px; margin-top: 2px; flex: 0 0 16px; }
.honeypot { position: absolute !important; left: -9999px !important; opacity: 0 !important; }
.submit-btn { width: 100%; margin-top: 15px; }

.form-status { display: none; margin-top: 15px; padding: 12px; border-radius: 8px; font-size: 0.9rem; font-weight: 600;}
.form-status.show { display: block; }
.form-status.success { color: var(--success); background: #d1e7dd; border: 1px solid #badbcc; }
.form-status.error { color: var(--danger); background: #f8d7da; border: 1px solid #f5c6cb; }

.compact-form-grid { display: grid; grid-template-columns: 1fr 0.6fr; gap: 0 15px; }
.field-wide { grid-column: 1 / -1; }
.choice-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice-cards label { margin: 0; cursor: pointer; position: relative; }
.choice-cards input { position: absolute; opacity: 0; pointer-events: none; }
.choice-cards span { min-height: 44px; display: flex; align-items: center; justify-content: center; color: var(--muted); border: 1px solid var(--border); border-radius: 8px; font-size: 0.85rem; font-weight: 700; transition: 0.2s; }
.choice-cards input:checked + span { color: var(--primary); background: var(--secondary); border-color: var(--primary); }
.relative-fields { padding: 15px; margin-bottom: 15px; background: #f8f9fa; border: 1px dashed var(--border); border-radius: 12px; }

.site-footer { padding: 40px max(15px, calc((100% - var(--max-width)) / 2)) 20px; color: #e7f1ff; background: #0f172a; }
.footer-main { display: grid; grid-template-columns: 1.5fr 0.8fr 0.9fr; gap: 30px; margin-bottom: 30px;}
.footer-doctor { display: flex; align-items: center; gap: 15px; }
.footer-doctor div { display: flex; flex-direction: column; }
.footer-doctor strong { color: #fff; font-size: 1rem; }
.footer-doctor span, .footer-doctor small { color: #cbd5e1; font-size: 0.85rem; }
.footer-description { margin-top: 15px; color: #94a3b8; font-size: 0.85rem; }
.footer-column h3 { margin: 0 0 10px; color: #fff; font-size: 1rem; }
.footer-column a, .footer-column span { display: block; color: #cbd5e1; font-size: 0.85rem; margin-bottom: 8px;}
.footer-column a:hover { color: #fff; }
.footer-bottom { display: flex; justify-content: space-between; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 20px; font-size: 0.8rem; color: #64748b; }

.floating-actions { position: fixed; right: 20px; bottom: 20px; z-index: 1100; display: flex; flex-direction: column; gap: 10px; }
.floating-actions a, .floating-actions button { width: 45px; height: 45px; display: grid; place-items: center; color: #fff; background: var(--primary); border: 0; border-radius: 50%; box-shadow: 0 5px 15px rgba(0,0,0,0.2); cursor: pointer; font-weight: bold;}
.floating-actions a:nth-child(2) { background: #0068ff; }
.floating-actions a:nth-child(3) { background: #229ed9; }
.floating-actions button { background: var(--accent); }

.chat-widget { position: fixed; right: 80px; bottom: 20px; z-index: 1200; width: 340px; background: #fff; border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); transform: translateY(20px); opacity: 0; visibility: hidden; transition: 0.2s ease; overflow: hidden;}
.chat-widget.open { transform: translateY(0); opacity: 1; visibility: visible; }
.chat-header { padding: 12px 15px; display: flex; justify-content: space-between; align-items: center; background: var(--primary); color: #fff; }
.chat-header button { background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; }
.chat-body { height: 250px; padding: 15px; overflow-y: auto; background: #f8f9fa; }
.chat-message { max-width: 85%; padding: 10px; border-radius: 10px; font-size: 0.85rem; margin-bottom: 10px; }
.chat-message.assistant { background: #e9ecef; color: var(--text); border: 1px solid var(--border); }
.chat-message.user { background: var(--primary); color: #fff; margin-left: auto; }
.chat-input { display: flex; padding: 10px; gap: 5px; border-top: 1px solid var(--border);}
.chat-input input { min-height: 38px; border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; flex: 1; }
.chat-input button { background: var(--primary); color: #fff; border: none; border-radius: 8px; padding: 0 15px; cursor: pointer;}
.quick-questions { padding: 10px; display: flex; gap: 5px; overflow-x: auto; border-top: 1px solid var(--border);}
.quick-questions button { padding: 5px 10px; background: var(--secondary); border: 1px solid #b6d4fe; border-radius: 15px; color: var(--primary); font-size: 0.75rem; white-space: nowrap; cursor: pointer;}

/* ==========================================
   TỐI ƯU HÓA HOÀN TOÀN CHO MOBILE 
========================================== */
@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; gap: 30px; text-align: center; }
  .hero-actions { justify-content: center; }
  .doctor-card { max-width: 500px; margin: 0 auto; }
  .feature-grid, .specialty-grid, .article-grid { grid-template-columns: repeat(2, 1fr); }
  .booking-section { grid-template-columns: 1fr; gap: 30px;}
  .footer-main { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  /* 1. Xử lý khoảng trống (padding) cho Mobile */
  body { 
    padding-top: 60px !important;    /* Khoảng trống cho Topbar */
    padding-bottom: 70px !important; /* Khoảng trống cho Bottom Nav */
    background: #f8f9fa; 
  }
  
  /* 2. Ẩn menu của máy tính */
  .site-header { display: none !important; }
  
  /* 3. Hiện và cố định Topbar của Mobile */
  .mobile-topbar { 
    display: flex !important; 
    position: fixed !important; 
    top: 0 !important; 
    left: 0 !important;
    width: 100% !important;
    height: 60px;
    z-index: 1050 !important; 
    align-items: center; 
    justify-content: space-between; 
    padding: 0 12px; 
    background: #fff; 
    border-bottom: 1px solid var(--border); 
    box-sizing: border-box;
  }
  
  .mobile-doctor { 
    display: flex; align-items: center; gap: 8px; 
    overflow: hidden; 
  }
  .mobile-doctor img, .mobile-doctor div { flex-shrink: 0; }
  .mobile-doctor span { 
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; 
    font-size: 0.85rem; line-height: 1.2;
  }
  .mobile-doctor strong { display: block; font-size: 0.9rem; }
  .mobile-doctor small { font-size: 0.75rem; color: var(--muted); }
  .mobile-call { 
    width: 38px; height: 38px; background: var(--success); color: #fff; 
    display: grid; place-items: center; border-radius: 50%; font-size: 1.1rem;
    flex-shrink: 0; 
  }
  
  .hero { padding: 20px 15px; background: linear-gradient(180deg, #e7f1ff, #f8f9fa); }
  .hero h1 { font-size: 1.8rem; }
  .hero-subtitle { font-size: 1rem; }
  
  .mobile-quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 15px; background: #fff; }
  .mobile-quick-actions a { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px 5px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 12px; font-size: 0.75rem; font-weight: 600;}
  .mobile-quick-actions span { width: 34px; height: 34px; background: var(--primary); color: #fff; display: grid; place-items: center; border-radius: 50%; font-size: 1rem; }
  
  .section { padding: 25px 15px !important; margin: 10px 10px 0; background: #fff; border-radius: 16px; border: 1px solid var(--border); }
  .section-heading h2 { font-size: 1.4rem; }
  
  .feature-grid, .specialty-grid, .article-grid { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 10px; gap: 10px;}
  .feature-card, .specialty-card, .article-card { min-width: 85%; scroll-snap-align: start; }
  .service-list { grid-template-columns: 1fr; }
  
  .compact-form-grid { grid-template-columns: 1fr; gap: 0; }
  .form-card { padding: 0; border: none; box-shadow: none; background: transparent; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  input, select { min-height: 48px; } 
  .choice-cards span { min-height: 48px; }
  
  .footer-main { grid-template-columns: 1fr; gap: 25px; }
  .footer-bottom { flex-direction: column; text-align: center; padding-bottom: 30px;}
  
  .floating-actions { display: none; }
  
  .mobile-bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(5, 1fr); background: #fff; border-top: 1px solid var(--border); z-index: 1300; height: 65px; box-shadow: 0 -5px 15px rgba(0,0,0,0.05);}
  .mobile-bottom-nav a, .mobile-bottom-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; background: none; border: none; color: var(--muted); font-size: 0.7rem; gap: 3px; cursor: pointer;}
  .mobile-bottom-nav span { font-size: 1.3rem; }
  .mobile-bottom-nav .active { color: var(--primary); }
  .mobile-nav-primary { width: 56px !important; height: 56px !important; background: var(--primary) !important; color: #fff !important; border-radius: 50%; margin: -20px auto 0; border: 4px solid #fff; box-shadow: 0 4px 10px rgba(11,94,215,0.3); justify-content: center !important;}
  .mobile-nav-primary small { display: none; }

  .mobile-contact-sheet { position: fixed; inset: 0; z-index: 1500; display: block; pointer-events: none; visibility: hidden; }
  .mobile-contact-sheet.open { pointer-events: auto; visibility: visible; }
  .mobile-contact-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5); opacity: 0; transition: 0.3s; }
  .mobile-contact-panel { position: absolute; bottom: 0; left: 0; right: 0; background: #fff; padding: 20px; border-radius: 20px 20px 0 0; transform: translateY(100%); transition: 0.3s; }
  .mobile-contact-sheet.open .mobile-contact-backdrop { opacity: 1; }
  .mobile-contact-sheet.open .mobile-contact-panel { transform: translateY(0); }
  .mobile-contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 15px;}
  .mobile-contact-grid a { display: flex; align-items: center; gap: 10px; padding: 12px; background: #f8f9fa; border: 1px solid var(--border); border-radius: 12px; }
  .mobile-contact-grid span { width: 36px; height: 36px; background: var(--primary); color: #fff; display: grid; place-items: center; border-radius: 50%; font-size: 1.1rem; }

  .chat-widget { width: auto; left: 10px; right: 10px; bottom: 80px; max-height: 70vh; }
}
/* ==========================================
   VÁ LỖI GIAO DIỆN ĐIỆN THOẠI 
========================================== */

/* 1. Sửa lỗi thẻ Dịch vụ bị tràn viền phải */
.service-list article {
  width: 100%;
  box-sizing: border-box;
}
.service-list article > div {
  flex: 1;
  min-width: 0; /* Quan trọng: Ép nội dung tự co giãn, không đẩy khung */
  word-wrap: break-word;
}
.service-list h3, .service-list p {
  white-space: normal;
}

/* 2. Sửa lỗi Khung Chat bị thanh menu dưới đè lên */
.chat-widget {
  z-index: 1500 !important; /* Đẩy lớp hiển thị lên cao nhất */
}
@media (max-width: 760px) {
  .chat-widget {
    bottom: 85px !important; /* Nâng khung chat lên trên thanh menu bottom */
    max-height: 65vh; /* Thu gọn chiều cao một chút để không che hết màn hình */
  }

  /* 3. Sửa lỗi bảng Liên hệ nhanh bị vỡ chữ (Telegram/Email) */
  .mobile-contact-grid {
    grid-template-columns: 1fr !important; /* Chuyển thành 1 cột dọc xếp chồng */
    gap: 12px;
  }
  .mobile-contact-grid a {
    padding: 14px 20px !important; /* Tạo nút bấm to, rộng rãi hơn */
  }
  .mobile-contact-grid strong {
    font-size: 1.05rem; /* Phóng to tên liên hệ */
  }
}