/* Responsive Stylesheet
   Breakpoints:
   - xs: < 576px (Mobile)
   - sm: >= 576px (Small)
   - md: >= 768px (Medium/Tablet)
   - lg: >= 992px (Large/Laptop)
   - xl: >= 1200px (XL/Desktop)
   - xxl: >= 1400px (XXL/Large Desktop)
*/

/* ============================================
   Mobile First Approach
   Base styles are for mobile devices
   ============================================ */

@media (min-width: 576px) {
    .container-sm {
        max-width: 540px;
        margin-left: auto;
        margin-right: auto;
    }

    .hero-actions {
        flex-direction: row;
    }

    .hero-actions .btn {
        width: auto;
        max-width: none;
    }

    .counter-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .partners-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .container-md {
        max-width: 720px;
        margin-left: auto;
        margin-right: auto;
    }

    .grid-md-2 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-md-3 {
        grid-template-columns: repeat(3, 1fr);
    }

    .grid-md-4 {
        grid-template-columns: repeat(4, 1fr);
    }

    .footer-grid {
        grid-template-columns: 2fr 1fr;
    }

    .counter-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .partners-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .cta-actions {
        flex-direction: row;
    }

    .cta-actions .btn {
        width: auto;
        max-width: none;
    }
}

@media (min-width: 992px) {
    .container-lg {
        max-width: 960px;
        margin-left: auto;
        margin-right: auto;
    }

    .grid-lg-2 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-lg-3 {
        grid-template-columns: repeat(3, 1fr);
    }

    .grid-lg-4 {
        grid-template-columns: repeat(4, 1fr);
    }

    .footer-grid {
        grid-template-columns: 2fr 1fr 1fr 1fr;
    }

    .partners-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1200px) {
    .container-xl {
        max-width: 1140px;
        margin-left: auto;
        margin-right: auto;
    }

    .grid-xl-2 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-xl-3 {
        grid-template-columns: repeat(3, 1fr);
    }

    .grid-xl-4 {
        grid-template-columns: repeat(4, 1fr);
    }

    .grid-xl-5 {
        grid-template-columns: repeat(5, 1fr);
    }

    .partners-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (min-width: 1400px) {
    .container-xxl {
        max-width: 1320px;
        margin-left: auto;
        margin-right: auto;
    }

    :root {
        --header-height: 80px;
    }
}

/* ============================================
   Responsive Typography
   ============================================ */

@media (max-width: 768px) {
    html {
        font-size: 15px;
    }

    .display-1 {
        font-size: 2.5rem;
    }

    .display-2 {
        font-size: 2rem;
    }

    .display-3 {
        font-size: 1.75rem;
    }
}

@media (max-width: 576px) {
    html {
        font-size: 14px;
    }

    .display-1 {
        font-size: 2rem;
    }

    .display-2 {
        font-size: 1.75rem;
    }

    .display-3 {
        font-size: 1.5rem;
    }
}

/* ============================================
   Responsive Header
   ============================================ */

@media (max-width: 991px) {
    .header {
        background: var(--bg-white);
        box-shadow: var(--shadow-sm);
    }

    .header-logo .logo-text {
        color: var(--primary);
    }

    /* 以下 .header 作用域内的规则属于旧版页头体系（style.css 的 .header / .mobile-menu），
       不能匹配 VeriQa 的 .site-header > .header-actions，否则会把移动端登录按钮静默隐藏 */
    .header .header-actions .btn-outline {
        display: none;
    }

    .header .header-actions .btn-primary {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }

    .mobile-menu {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--bg-white);
        z-index: 998;
        padding: 2rem 1.5rem;
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform var(--transition-slow);
    }

    .mobile-menu.active {
        transform: translateX(0);
    }

    .mobile-menu-nav {
        list-style: none;
        padding: 0;
        margin: 0 0 2rem;
    }

    .mobile-menu-nav li {
        border-bottom: 1px solid var(--border-light);
    }

    .mobile-menu-nav a {
        display: block;
        padding: 1rem 0;
        font-size: 1.125rem;
        font-weight: 500;
        color: var(--text-dark);
        text-decoration: none;
        transition: color var(--transition-fast);
    }

    .mobile-menu-nav a:hover,
    .mobile-menu-nav a.active {
        color: var(--primary);
    }

    .mobile-menu-actions {
        padding-top: 1.5rem;
        border-top: 1px solid var(--border-light);
    }

    .mobile-menu-actions .btn {
        width: 100%;
        margin-bottom: 0.75rem;
    }
}

@media (max-width: 480px) {
    .header .header-actions .language-switcher {
        display: none;
    }
}

/* ============================================
   Responsive Hero
   ============================================ */

@media (max-width: 768px) {
    .hero {
        min-height: auto;
        padding: calc(var(--header-height) + 3rem) 0 4rem;
    }

    .hero-with-image {
        padding-top: 64px;
    }

    .hero-with-image .hero-inner {
        padding: 1rem 1rem 3rem;
    }

    .hero-stats {
        gap: 1.5rem;
        padding-top: 2rem;
        margin-top: 2rem;
    }

    .hero-stat {
        flex: 1 1 calc(50% - 0.75rem);
    }

    .hero-stat .stat-number {
        font-size: 1.75rem;
    }
}

@media (max-width: 480px) {
    .hero-stat {
        flex: 1 1 100%;
    }
}

/* ============================================
   Responsive Navigation
   ============================================ */

@media (max-width: 991px) {
    .header-nav {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        background: var(--bg-white);
        flex-direction: column;
        padding: 1.5rem;
        gap: 0;
        box-shadow: var(--shadow-md);
        transform: translateY(-150%);
        transition: transform var(--transition-slow);
    }

    .header-nav.active {
        transform: translateY(0);
    }

    .header-nav ul {
        flex-direction: column;
        width: 100%;
        gap: 0;
    }

    .header-nav ul li {
        width: 100%;
        border-bottom: 1px solid var(--border-light);
    }

    .header-nav ul li:last-child {
        border-bottom: none;
    }

    .header-nav a {
        display: block;
        padding: 1rem 0;
        color: var(--text-dark);
        font-size: 1rem;
        border-bottom: none;
    }

    .header-nav a::after {
        display: none;
    }

    .header-nav a:hover {
        color: var(--primary);
    }

    .header-nav .dropdown-menu {
        position: static;
        box-shadow: none;
        opacity: 1;
        visibility: visible;
        transform: none;
        display: none;
        padding: 0 0 0 1rem;
        min-width: auto;
    }

    .header-nav .dropdown:hover .dropdown-menu,
    .header-nav .dropdown.active .dropdown-menu {
        display: block;
    }
}

/* ============================================
   Responsive Cards
   ============================================ */

@media (max-width: 768px) {
    .card {
        margin-bottom: 1.5rem;
    }

    .card-image {
        height: 180px;
    }

    .feature-card {
        padding: 1.5rem;
    }

    .feature-icon {
        width: 56px;
        height: 56px;
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }

    .news-card-image {
        height: 180px;
    }
}

@media (max-width: 480px) {
    .card-body {
        padding: 1.25rem;
    }

    .card-footer {
        padding: 0.875rem 1.25rem;
    }
}

/* ============================================
   Responsive Forms
   ============================================ */

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .form-group {
        margin-bottom: 1.25rem;
    }
}

/* ============================================
   Responsive Footer
   ============================================ */

@media (max-width: 768px) {
    .footer-top {
        padding: 3rem 0 2rem;
    }

    .footer-brand {
        max-width: 100%;
        margin-bottom: 2rem;
    }

    .footer-bottom .container {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .footer-legal {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .footer-grid {
        gap: 1.5rem;
    }

    .footer-col {
        text-align: center;
    }

    .footer-social {
        justify-content: center;
    }
}

/* ============================================
   Responsive Grid Utilities
   ============================================ */

@media (max-width: 768px) {
    .row {
        flex-direction: column;
    }

    .col-half,
    .col-third,
    .col-quarter {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

@media (min-width: 769px) {
    .row {
        display: flex;
        flex-wrap: wrap;
        margin: 0 -1rem;
    }

    .col-half {
        flex: 0 0 50%;
        max-width: 50%;
        padding: 0 1rem;
    }

    .col-third {
        flex: 0 0 33.3333%;
        max-width: 33.3333%;
        padding: 0 1rem;
    }

    .col-quarter {
        flex: 0 0 25%;
        max-width: 25%;
        padding: 0 1rem;
    }
}

/* ============================================
   Responsive Tables
   ============================================ */

@media (max-width: 768px) {
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }
}

/* ============================================
   Responsive Tabs
   ============================================ */

@media (max-width: 768px) {
    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab {
        flex: 0 0 auto;
        padding: 0.875rem 1.25rem;
    }
}

/* ============================================
   Responsive Modals
   ============================================ */

@media (max-width: 576px) {
    .modal-dialog {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }

    .modal-header {
        padding: 1rem 1.25rem;
    }

    .modal-body {
        padding: 1.25rem;
    }

    .modal-footer {
        padding: 1rem 1.25rem;
        flex-direction: column-reverse;
    }

    .modal-footer .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .modal-footer .btn:last-child {
        margin-bottom: 0;
    }
}

/* ============================================
   Touch Device Optimizations
   ============================================ */

@media (hover: none) {
    .hover-effect:hover {
        transform: none;
        box-shadow: var(--shadow-sm);
    }

    .card:hover {
        transform: none;
        box-shadow: var(--shadow-sm);
    }

    .btn:hover:not(:disabled) {
        transform: none;
    }

    .reveal {
        opacity: 1;
        transform: none;
    }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .header,
    .footer,
    .mobile-toggle,
    .back-to-top,
    .cta-section,
    .header-actions,
    .hero-actions,
    .footer-social,
    .partner-item:hover {
        display: none !important;
    }

    body {
        background: var(--bg-white);
        color: var(--text-dark);
    }

    .hero {
        background: none;
        color: var(--text-dark);
        min-height: auto;
        padding: 2rem 0;
    }

    .hero h1,
    .page-header h1 {
        color: var(--text-dark);
    }

    .hero-subtitle,
    .page-header p {
        color: var(--text-body);
    }

    .section {
        padding: 2rem 0;
        page-break-inside: avoid;
    }

    .card {
        box-shadow: none;
        border: 1px solid var(--border);
        page-break-inside: avoid;
    }

    a {
        color: var(--text-dark);
        text-decoration: underline;
    }

    img {
        max-width: 100%;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }
}

/* ============================================
   Reduced Motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .reveal {
        opacity: 1;
        transform: none;
    }
}