/* responsive.css */

/* Mobile & Tablet */
@media (max-width: 768px) {
  .top-header {
    height: 52px;
    padding: 0 12px;
    gap: 10px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    z-index: 1005;
    flex-shrink: 0;
  }

  .header-logo-link {
    flex-shrink: 0;
    display: flex;
    align-items: center;
  }

  .header-logo-img {
    height: 34px;
    width: auto;
  }

  /* Tiêu đề tự động co chữ để vừa đẹp 2 dòng tương đương chiều cao logo */
  .header-title-text {
    font-size: clamp(0.68rem, 2.7vw, 0.8rem);
    line-height: 1.25;
    font-weight: 800;
    letter-spacing: 0.1px;
    flex: 1;
    white-space: normal;
    word-break: normal;
  }

  .sidebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 85%;
    max-width: 320px;
    transform: translateX(-100%);
    box-shadow: 4px 0 15px rgba(0,0,0,0.5);
    z-index: 1045;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-expand-btn {
    display: flex;
    top: 12px;
    left: 12px;
    padding: 8px 12px;
    font-size: 0.85rem;
    z-index: 1035;
  }

  .sidebar-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    display: none;
  }

  .sidebar-overlay.visible {
    display: block;
  }

  /* Modal / Panel trên mobile: dạng Bottom Sheet có thể cuộn trượt mượt mà */
  .commune-modal {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100vw;
    height: 75vh;
    max-height: 75vh;
    border-radius: 18px 18px 0 0;
    transform: translateY(105%);
    z-index: 1002;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.3);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .commune-modal.open {
    transform: translateY(0);
  }

  .modal-header {
    flex-shrink: 0;
    padding: 14px 18px;
    border-radius: 18px 18px 0 0;
  }

  .modal-title {
    font-size: 1.15rem;
  }

  /* Cho phép nội dung bên trong modal-body cuộn mượt bằng ngón tay */
  .modal-body {
    flex: 1 1 auto;
    height: calc(75vh - 60px);
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 16px 16px 36px 16px;
  }

  .news-btn-wrapper {
    margin-top: 12px;
    padding-bottom: 24px;
  }

  /* Ẩn hoàn toàn tin tức liên quan trên giao diện Mobile */
  .news-preview-section {
    display: none !important;
  }

  .btn-news {
    padding: 14px;
    font-size: 0.95rem;
  }

  .map-toolbar {
    top: 12px;
    right: 12px;
    z-index: 10;
  }

  .tool-btn {
    width: 36px;
    height: 36px;
  }

  .weather-tool-btn {
    height: 36px;
    min-width: 48px;
    padding: 0 8px;
    font-size: 0.78rem;
  }

  .btn-w-icon {
    font-size: 1.15rem;
  }

  .btn-w-temp {
    font-size: 0.78rem;
  }

  .weather-toolbar-panel {
    position: fixed;
    top: 106px;
    left: 10px;
    right: 10px;
    width: auto;
    max-width: none;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    z-index: 1030;
  }

  /* Flyout thời tiết trên Mobile: nổi dạng Bottom Popover đè nhẹ lên góc trên bottom sheet */
  .commune-weather-flyout {
    position: fixed;
    top: auto;
    left: 12px;
    right: 12px;
    bottom: 85px;
    width: auto;
    max-width: none;
    max-height: 60vh;
    z-index: 1020;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.35);
  }

  .weather-error-toast {
    position: fixed;
    top: auto;
    left: 12px;
    right: 12px;
    bottom: 85px;
    width: auto;
    max-width: none;
    z-index: 1025;
  }
}

/* ==========================================================================
   DESKTOP MÀN HÌNH ĐỘ PHÂN GIẢI THẤP (Laptop 1366x768, 1280x720 hoặc cửa sổ thu nhỏ)
   ========================================================================== */
@media (min-width: 769px) and (max-height: 800px) {
  .commune-modal {
    top: 10px;
    max-height: calc(100% - 20px);
    width: 420px;
  }

  .commune-weather-flyout {
    top: 10px;
    max-height: calc(100% - 20px);
    right: 442px; /* 10px lề phải + 420px modal + 12px khoảng cách */
    width: 320px;
  }

  .modal-header {
    padding: 10px 16px;
  }

  .modal-title {
    font-size: 1.05rem;
  }

  .modal-body {
    padding: 10px 12px 14px;
    gap: 7px;
  }

  .stat-card {
    padding: 6px 10px;
  }

  .stat-card-val {
    font-size: 1.05rem;
  }

  .info-section {
    padding: 6px 10px;
  }

  .leader-item {
    padding: 4px 0;
  }

  .weather-trigger-section {
    padding: 6px 10px;
  }

  .news-preview-item {
    padding: 8px 10px;
    gap: 8px;
  }

  .news-preview-thumb,
  .news-preview-thumb-placeholder {
    width: 76px;
    height: 50px;
  }

  .news-preview-title {
    font-size: 0.8rem;
  }

  .weather-flyout-header {
    padding: 10px 14px;
  }

  .weather-flyout-body {
    padding: 10px 14px;
    gap: 10px;
  }
}

/* Desktop chiều rộng vừa phải (769px - 1100px) */
@media (min-width: 769px) and (max-width: 1100px) {
  .commune-modal {
    width: 390px;
    right: 10px;
  }

  .commune-weather-flyout {
    width: 300px;
    right: 410px; /* 10px + 390px + 10px */
  }
}
