/* ═══════════════════════════════════════════════
   RESPONSIVE - Hà Nội Portal
   Breakpoints:
     - 1280px (Large desktop → Standard)
     - 1024px (Tablet landscape)
     - 768px  (Tablet portrait / Mobile)
     - 480px  (Small mobile)
   ═══════════════════════════════════════════════ */

/* ─── Large Desktop (≤ 1280px) ─── */
@media (max-width: 1280px) {
    .header-inner {
        max-width: 100%;
        padding: 0 24px;
    }

    /* Eco Gallery */
    .eco-gallery__item {
        max-width: none;
    }

    .eco-gallery__image-wrap {
        height: 420px;
    }

    .map-section {
        padding: 32px 0 60px;
    }

    .map-card {
        flex-direction: column;
    }

    .map-card-left {
        border-right: none;
        border-bottom: 1px solid #E2E8F0;
    }

    .map-card-right {
        padding: 32px;
    }

    .map-highlight-banner {
        height: 320px;
        border-radius: 30px;
    }

    .map-highlight-banner__image {
        height: 100%;
    }

    .map-highlight-banner__overlay {
        left: 44px;
    }

    .map-highlight-banner__year {
        font-size: 72px;
    }

    .map-highlight-banner__title,
    .map-highlight-banner__subtitle {
        font-size: 48px;
    }

    .transform-card {
        gap: 24px;
    }

    .transform-right {
        padding: 32px 24px 32px 16px;
    }

    .footer-top {
        gap: 48px;
        padding: 48px 24px;
    }
}

/* ─── Tablet Landscape (≤ 1024px) ─── */
@media (max-width: 1024px) {
    :root {
        --container-padding: 24px;
        --font-size-2xl-display: 48px;
        --font-size-md-display: 28px;
    }

    /* Header */
    .header-inner {
        gap: 24px;
        height: 72px;
    }

    .main-nav .nav-list {
        gap: 20px;
    }

    .nav-link {
        font-size: 14px;
    }

    .lang-switch {
        display: none;
    }

    /* Hero */
    .hero-section {
        min-height: 1100px;
    }

    .hero-bg {
        height: 1020px;
    }

    .hero-title {
        font-size: 56px;
    }

    .hero-subtitle {
        font-size: 28px;
    }

    .hero-content {
        max-width: 600px;
        padding-top: 48px;
    }

    /* Stats */
    .stats-grid {
        flex-wrap: wrap;
    }

    .stat-card {
        flex: 1 1 calc(50% - 12px);
        min-width: 180px;
        padding: 16px 12px;
    }

    .hero-stats {
        padding: 80px var(--container-padding) 16px;
    }

    /* Eco Gallery */
    .eco-gallery__grid {
        gap: 16px;
    }

    .eco-gallery__item {
        max-width: none;
    }

    .eco-gallery__image-wrap {
        width: 100%;
        height: 320px;
    }

    .eco-gallery__info-card {
        width: calc(100% - 12px);
        height: 65px;
        padding: 0 12px;
        gap: 8px;
    }

    .eco-gallery__icon {
        width: 36px;
        height: 36px;
    }

    .eco-gallery__icon svg {
        width: 18px;
        height: 18px;
    }

    .eco-gallery__number {
        font-size: 24px;
    }

    .eco-gallery__title {
        font-size: 13px;
    }

    .eco-gallery__desc {
        font-size: 11px;
    }

    /* Map Section */
    .map-section {
        padding: 24px 0 60px;
    }

    /* Services */
    .services-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .support-cta {
        flex-direction: column;
        text-align: center;
        gap: 24px;
        padding: 32px;
    }

    .support-cta-actions {
        justify-content: center;
    }

    /* Process */
    .process-steps {
        grid-template-columns: repeat(2, 1fr);
        gap: 32px 24px;
    }

    .process-step:not(:last-child)::after {
        display: none;
    }

    .process-stats {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Transform */
    .transform-section {
        height: auto;
        padding: 60px 0;
    }

    .transform-card {
        flex-direction: column;
    }

    .transform-left {
        flex: none;
    }

    .transform-image {
        height: 400px;
    }

    .transform-right {
        padding: 32px 0 0;
    }

    /* News */
    .news-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .news-featured-image {
        height: 280px;
    }

    .news-side-card {
        gap: 16px;
    }

    /* Directory */
    .directory-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .directory-filters {
        flex-wrap: wrap;
    }

    .directory-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .directory-table {
        min-width: 700px;
    }

    /* Partners */
    .partners-stats {
        grid-template-columns: repeat(2, 1fr);
        height: auto;
        padding: 32px 24px;
        gap: 24px;
    }

    .partner-logo {
        width: 280px;
        height: 100px;
        padding: 16px 24px;
    }

    /* Footer */
    .footer-top {
        flex-wrap: wrap;
        gap: 40px;
    }

    .footer-brand {
        flex: 1 1 100%;
    }

    .footer-links,
    .footer-contact {
        flex: 1 1 calc(50% - 20px);
    }

    /* AI Chat */
    .ai-float-popup {
        width: 340px;
    }
}

/* ─── Tablet Portrait / Mobile (≤ 768px) ─── */
@media (max-width: 768px) {
    :root {
        --container-padding: 16px;
        --header-height: 64px;
        --font-size-2xl-display: 36px;
        --font-size-xl-display: 32px;
        --font-size-md-display: 24px;
    }

    /* Header */
    .header-inner {
        justify-content: space-between;
        gap: 12px;
        padding: 0 16px;
        height: 64px;
    }

    .header-logo img {
        width: 60px;
        height: 60px;
    }

    .site-header {
        z-index: 9998;
        /* Remove backdrop-filter on mobile: it creates a containing block
           for position:fixed descendants, trapping .main-nav inside header */
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: #FFFFFF;
    }

    .main-nav {
        position: fixed;
        top: 64px;
        left: 0;
        right: 0;
        bottom: 0;
        background: #FFFFFF;
        padding: 24px;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 9997;
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
        overflow-y: auto;
    }

    .main-nav.is-open {
        transform: translateX(0);
    }

    .nav-list {
        flex-direction: column;
        gap: 4px;
    }

    .nav-link {
        width: 100%;
        display: block;
        padding: 14px 16px;
        font-size: 16px;
        border-radius: 12px;
        transition: background 0.2s ease;
    }

    .nav-link:hover,
    .nav-item.active .nav-link {
        background: #F1F5F9;
    }

    .header-right {
        display: none;
    }

    /* Show header-right inside drawer when nav is open */
    .main-nav.is-open~.header-right {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 20px 24px;
        background: #FFFFFF;
        border-top: 1px solid #E2E8F0;
        z-index: 9997;
        align-items: center;
        justify-content: center;
        gap: 16px;
    }

    .main-nav.is-open~.header-right .lang-switch {
        display: flex;
    }

    .main-nav.is-open~.header-right .btn-auth--primary {
        flex: 1;
        max-width: 200px;
        justify-content: center;
    }

    .menu-toggle {
        display: flex;
    }

    /* Hero */
    .hero-section {
        min-height: auto;
        padding-top: 64px;
    }

    .hero-bg {
        top: 64px;
        left: 12px;
        right: 12px;
        /* Cover entire hero section including stats */
        height: auto;
        bottom: 0;
        border-radius: 24px;
    }

    .hero-content {
        max-width: 100%;
        padding: 48px 20px 32px;
        gap: 20px;
    }

    .hero-title {
        font-size: 42px;
        white-space: normal;
        line-height: 1.15;
    }

    .hero-subtitle {
        font-size: 20px;
        white-space: normal;
        line-height: 1.3;
    }

    .hero-description {
        font-size: 14px;
        line-height: 1.6;
    }

    .hero-description br {
        display: none;
    }

    .btn-hero {
        width: auto;
        min-width: 170px;
        height: 36px;
        padding: 0 18px 0 14px;
        font-size: 13px;
    }

    /* Stats */
    .hero-stats {
        padding: 48px 16px 16px;
        gap: 20px;
    }

    .stats-header {
        gap: 8px;
    }

    .stats-title {
        font-size: 24px;
        text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    }

    .stats-subtitle {
        font-size: 14px;
        color: rgba(255, 255, 255, 0.9);
        text-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
    }

    .stats-grid {
        gap: 12px;
        flex-wrap: wrap;
    }

    .stat-card {
        flex: 1 1 calc(50% - 6px);
        padding: 20px 12px;
        min-width: 140px;
    }

    .stat-number {
        font-size: 36px;
    }

    .stat-label {
        font-size: 11px;
        line-height: 1.4;
        min-height: calc(1.4em * 4);
    }

    .stat-desc {
        font-size: 11px;
        line-height: 1.5;
        min-height: calc(1.5em * 3);
    }

    /* Eco Gallery - 2 column layout for tablet */
    .eco-gallery {
        margin-bottom: 32px;
    }

    .eco-gallery__grid {
        flex-wrap: wrap;
        justify-content: center;
        gap: 16px;
    }

    .eco-gallery__item {
        flex: 0 1 calc(50% - 8px);
        max-width: calc(50% - 8px);
    }

    .eco-gallery__image-wrap {
        width: 100%;
        height: 260px;
    }

    .eco-gallery__info-card {
        width: calc(100% - 16px);
        height: 64px;
        padding: 0 14px;
        gap: 10px;
        bottom: 8px;
        border-radius: 12px;
    }

    .eco-gallery__icon {
        width: 36px;
        height: 36px;
    }

    .eco-gallery__icon svg {
        width: 18px;
        height: 18px;
    }

    .eco-gallery__title {
        font-size: 14px;
    }

    .eco-gallery__desc {
        font-size: 12px;
    }

    .eco-gallery__number {
        font-size: 24px;
    }

    /* Map Section */
    .map-section {
        padding: 16px 0 40px;
    }

    .map-section-title {
        font-size: 22px;
        margin-top: 8px;
    }

    .map-section-subtitle {
        font-size: 13px;
    }

    .map-section-header {
        margin-bottom: 24px;
    }

    .map-card-left {
        padding: 20px;
    }

    .map-card-right {
        padding: 20px;
    }

    .map-highlight-banner {
        height: 240px;
        border-radius: 22px;
    }

    .map-highlight-banner__image {
        height: 100%;
    }

    .map-highlight-banner__overlay {
        left: 24px;
    }

    .map-highlight-banner__year {
        font-size: 52px;
        letter-spacing: -1px;
    }

    .map-highlight-banner__title,
    .map-highlight-banner__subtitle {
        font-size: 34px;
        letter-spacing: 0;
    }

    .map-container object {
        height: auto !important;
    }

    .province-rank-item {
        padding: 14px 16px;
        gap: 12px;
    }

    .rank-badge {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .rank-name {
        font-size: 13px;
    }

    .rank-number {
        font-size: 20px;
    }

    .rank-number-total {
        font-size: 13px;
    }

    .rank-label {
        font-size: 11px;
    }

    /* Services */
    .services-section {
        padding: 48px 0 60px;
    }

    .services-title {
        font-size: 24px;
    }

    .services-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .service-card {
        padding: 24px;
    }

    .support-cta {
        padding: 20px;
        border-radius: 16px;
    }

    .support-cta-title {
        font-size: 18px;
    }

    .support-cta-desc {
        font-size: 12px;
    }

    .support-cta-actions {
        flex-direction: row;
        width: 100%;
        gap: 10px;
    }

    .support-cta-btn {
        text-align: center;
        width: auto;
        flex: 1;
        padding: 10px 16px;
        font-size: 13px;
    }

    /* Map Note */
    .map-note {
        padding: 10px 12px;
        gap: 6px;
    }

    .map-note i {
        font-size: 13px;
    }

    .map-note span {
        font-size: 12px;
    }

    /* Process */
    .process-section {
        padding: 48px 0 60px;
    }

    .process-title {
        font-size: 24px;
    }

    .process-steps {
        grid-template-columns: 1fr;
        gap: 28px;
    }

    .process-step {
        padding: 32px 20px 24px;
    }

    /* Connecting line: horizontal → vertical on mobile */
    .process-step:not(:last-child)::after {
        display: block;
        top: 100%;
        bottom: auto;
        left: 50%;
        width: 3px;
        height: 28px;
        transform: translateX(-50%);
    }

    .process-stats {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .process-stat-item {
        padding: 20px;
    }

    .process-stat-value {
        font-size: 26px;
    }

    /* Directory */
    .directory-section {
        padding: 48px 0 60px;
    }

    .directory-title {
        font-size: 24px;
    }

    .directory-toolbar {
        flex-direction: column;
        gap: 12px;
    }

    .directory-search {
        width: 100%;
    }

    .directory-filters {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }

    .directory-filter-btn {
        font-size: 12px;
        height: 48px;
        padding: 0 12px;
        flex: 1;
        min-width: 0;
        justify-content: center;
    }

    /* Table → Card layout on mobile */
    .directory-table-wrap {
        overflow-x: visible;
        border: none;
        border-radius: 0;
    }

    .directory-table {
        min-width: 0;
    }

    .directory-table thead {
        display: none;
    }

    .directory-table tbody tr {
        display: block;
        background: #FFFFFF;
        border: 1px solid #E2E8F0;
        border-radius: 12px;
        padding: 16px;
        margin-bottom: 12px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    }

    .directory-table tbody tr:hover {
        background: #F8FAFC;
    }

    .directory-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0;
        border-bottom: 1px solid #F1F5F9;
        font-size: 14px;
    }

    .directory-table td:last-child {
        border-bottom: none;
    }

    /* Add labels from column headers via data-label */
    .directory-table td::before {
        content: attr(data-label);
        font-size: 12px;
        font-weight: 600;
        color: #64748B;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        flex-shrink: 0;
        margin-right: 12px;
    }

    .directory-table td.td-name {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .directory-table td.td-code {
        font-size: 15px;
    }

    .directory-pagination {
        flex-direction: column;
        gap: 16px;
        align-items: center;
    }

    /* Transform */
    .transform-section {
        height: auto;
        padding: 48px 0;
    }

    .transform-image {
        height: 280px;
    }

    .transform-title {
        font-size: 24px;
    }

    .transform-subtitle {
        font-size: 14px;
    }

    .transform-image-stats {
        padding: 14px 16px;
    }

    .transform-stat-value {
        font-size: 18px;
    }

    .transform-stat-label {
        font-size: 11px;
    }

    .transform-cta {
        padding: 10px 20px;
        font-size: 13px;
        box-shadow: none;
    }

    .transform-cta:hover {
        gap: 8px;
    }

    /* News */
    .news-section {
        padding: 48px 0 60px;
    }

    .news-main-title {
        font-size: 24px;
    }

    .news-title-row {
        flex-direction: row;
        align-items: center;
        gap: 12px;
    }

    .news-view-all {
        font-size: 12px;
        padding: 8px 14px;
        border-radius: 8px;
        white-space: nowrap;
    }

    .news-featured-image {
        height: 200px;
    }

    .news-featured-title {
        font-size: 18px;
    }

    .news-featured-desc {
        font-size: 13px;
    }

    .news-side-card {
        flex-direction: column;
        gap: 0;
    }

    .news-side-image {
        width: 100%;
        min-width: unset;
        height: 180px;
        border-radius: 12px 12px 0 0;
    }

    .news-side-body {
        padding: 16px;
    }

    .news-side-title {
        font-size: 15px;
    }

    /* Partners */
    .partners-section {
        min-height: auto;
        padding: 48px 0 40px;
    }

    .partners-title {
        font-size: 24px;
    }

    .partners-subtitle {
        font-size: 14px;
        padding: 0 16px;
    }

    .partners-stats {
        grid-template-columns: repeat(2, 1fr);
        height: auto;
        padding: 24px 16px;
        gap: 20px;
        margin: 0 16px;
    }

    .partners-stat-value {
        font-size: 28px;
    }

    .partners-stat-label {
        font-size: 12px;
    }

    .partner-logo {
        width: 220px;
        height: 80px;
        padding: 12px 20px;
    }

    .partner-logo img {
        width: 140px;
        height: 70px;
    }

    /* Footer */
    .footer-top {
        flex-direction: column;
        gap: 32px;
        padding: 40px 16px;
    }

    .footer-brand,
    .footer-links,
    .footer-contact {
        flex: none;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 12px;
        text-align: center;
        padding: 16px;
        margin-top: 24px;
    }

    .footer-policies {
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px;
    }

    /* AI Chat */
    .ai-float {
        bottom: 20px;
        right: 16px;
    }

    .ai-float-btn {
        width: 46px;
        height: 46px;
    }

    .ai-float-btn .bi-chat {
        font-size: 18px;
    }

    .ai-float-badge {
        width: 16px;
        height: 16px;
        top: 1px;
        right: 1px;
        font-size: 7px;
    }

    .ai-float-popup {
        width: calc(100vw - 32px);
        max-width: 380px;
    }

    /* General Sections */
    .section {
        padding: 48px 0;
    }
}

/* ─── Small Mobile (≤ 480px) ─── */
@media (max-width: 480px) {
    :root {
        --font-size-2xl-display: 28px;
        --font-size-xl-display: 24px;
        --font-size-md-display: 20px;
    }

    /* Hero */
    .hero-bg {
        left: 8px;
        right: 8px;
        border-radius: 20px;
    }

    .hero-content {
        padding: 36px 16px 20px;
        gap: 16px;
    }

    .hero-title {
        font-size: 30px;
    }

    .hero-subtitle {
        font-size: 16px;
    }

    .hero-heading-group {
        max-width: 100%;
        gap: 10px;
    }

    .hero-desc-group {
        max-width: 100%;
        gap: 16px;
    }

    .hero-description {
        font-size: 13px;
    }

    .btn-hero {
        width: 100%;
        justify-content: center;
    }

    /* Stats */
    .hero-stats {
        padding: 36px 12px 20px;
        gap: 16px;
    }

    .stats-title {
        font-size: 20px;
    }

    .stats-subtitle {
        font-size: 13px;
    }

    .stat-card {
        padding: 16px 10px;
        min-width: 120px;
    }

    .stat-number {
        font-size: 28px;
    }

    .stat-label {
        font-size: 10px;
        line-height: 1.4;
        min-height: calc(1.4em * 4);
    }

    .stat-desc {
        font-size: 10px;
        line-height: 1.5;
        min-height: calc(1.5em * 3);
    }

    /* Eco Gallery - single column for small mobile */
    .eco-gallery {
        margin-bottom: 24px;
    }

    .eco-gallery__grid {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .eco-gallery__item {
        width: 100%;
        max-width: none;
    }

    .eco-gallery__image-wrap {
        height: 220px;
    }

    .eco-gallery__info-card {
        width: calc(100% - 12px);
        height: 56px;
        padding: 0 12px;
        gap: 8px;
        bottom: 6px;
        border-radius: 10px;
    }

    .eco-gallery__icon {
        width: 30px;
        height: 30px;
    }

    .eco-gallery__icon svg {
        width: 15px;
        height: 15px;
    }

    .eco-gallery__title {
        font-size: 12px;
    }

    .eco-gallery__desc {
        font-size: 10px;
    }

    .eco-gallery__number {
        font-size: 20px;
    }

    /* Map */
    .map-section-title {
        font-size: 20px;
    }

    .map-card-left,
    .map-card-right {
        padding: 16px;
    }

    .map-right-title {
        font-size: 18px;
    }

    .map-highlight-banner {
        height: 190px;
        border-radius: 18px;
    }

    .map-highlight-banner__image {
        height: 100%;
    }

    .map-highlight-banner__overlay {
        left: 16px;
        gap: 2px;
    }

    .map-highlight-banner__year {
        font-size: 38px;
    }

    .map-highlight-banner__title,
    .map-highlight-banner__subtitle {
        font-size: 24px;
    }

    .province-rank-item {
        padding: 12px;
        gap: 10px;
        flex-wrap: wrap;
    }

    .rank-badge {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }

    .rank-info {
        min-width: 0;
        flex: 1;
    }

    .rank-count {
        min-width: 60px;
    }

    /* Services */
    .services-title {
        font-size: 20px;
    }

    .service-card {
        padding: 20px;
        border-radius: 16px;
    }

    .service-card-title {
        font-size: 16px;
    }

    /* Process */
    .process-title {
        font-size: 20px;
    }

    .process-step-icon {
        width: 48px;
        height: 48px;
        border-radius: 12px;
    }

    .process-step-icon i {
        font-size: 22px;
    }

    /* Directory */
    .directory-title {
        font-size: 20px;
    }

    .directory-search {
        height: 48px;
        padding: 0 14px;
    }

    .directory-search input {
        font-size: 13px;
    }

    /* Transform */
    .transform-image {
        height: 220px;
    }

    .transform-title {
        font-size: 20px;
    }

    .transform-feature-title {
        font-size: 14px;
    }

    .transform-feature-desc {
        font-size: 12px;
    }

    .transform-cta {
        width: 100%;
        justify-content: center;
    }

    /* News */
    .news-main-title {
        font-size: 20px;
    }

    .news-featured-image {
        height: 180px;
    }

    .news-featured-title {
        font-size: 16px;
    }

    .news-side-image {
        height: 150px;
    }

    /* Partners */
    .partners-title {
        font-size: 20px;
    }

    .partners-stats {
        grid-template-columns: 1fr 1fr;
        padding: 20px 12px;
        gap: 16px;
    }

    .partners-stat-value {
        font-size: 24px;
    }

    .partners-stat-label {
        font-size: 11px;
        text-align: center;
    }

    .partner-logo {
        width: 180px;
        height: 68px;
        padding: 10px 14px;
        border-radius: 10px;
    }

    .partner-logo img {
        width: 120px;
        height: 56px;
    }

    /* Footer */
    .footer-top {
        padding: 32px 12px;
    }

    .footer-org {
        font-size: 13px;
    }

    /* Section spacing */
    .section {
        padding: 40px 0;
    }

    .services-section,
    .process-section,
    .directory-section,
    .news-section {
        padding: 40px 0 48px;
    }

    /* Map legend */
    .map-legend-card {
        position: relative;
        bottom: auto;
        left: auto;
        margin-top: 12px;
    }
}

/* ─── Extra Small Mobile (≤ 360px) ─── */
@media (max-width: 360px) {
    .hero-title {
        font-size: 26px;
    }

    .hero-subtitle {
        font-size: 14px;
    }

    .stat-card {
        flex: 1 1 100%;
    }

    .stat-number {
        font-size: 24px;
    }

    .support-cta-title {
        font-size: 18px;
    }

    .partners-stats {
        grid-template-columns: 1fr;
    }

    .news-featured-body {
        padding: 16px;
    }

    .transform-image-stats {
        flex-direction: column;
        gap: 8px;
    }
}