/* Advanced Responsive Design and Layout Enhancements */

/* 1. Fluid Typography System */
:root {
    --fluid-min-width: 320;
    --fluid-max-width: 1140;
    --fluid-screen: 100vw;
    --fluid-bp: calc(
        (var(--fluid-screen) - var(--fluid-min-width) / 16 * 1rem) /
        (var(--fluid-max-width) - var(--fluid-min-width))
    );
}

/* Fluid font sizes */
@media (min-width: 320px) {
    :root {
        --fluid-font-size: calc(1rem + 0.25 * var(--fluid-bp));
        --fluid-heading-size: calc(1.5rem + 1 * var(--fluid-bp));
        --fluid-subheading-size: calc(1.25rem + 0.5 * var(--fluid-bp));
    }
}

@media (min-width: 1140px) {
    :root {
        --fluid-font-size: 1.25rem;
        --fluid-heading-size: 2.5rem;
        --fluid-subheading-size: 1.75rem;
    }
}

/* Apply fluid typography */
body {
    font-size: var(--fluid-font-size);
}

h1, h2, h3, h4, h5, h6 {
    font-size: var(--fluid-heading-size);
}

/* 2. Advanced Grid System */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 3vw, 2rem);
    box-sizing: border-box;
}

/* Advanced grid with auto-fit and minmax */
.advanced-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: clamp(1rem, 3vw, 2rem);
}

/* Masonry-like layout for cards */
.masonry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
    gap: clamp(1rem, 3vw, 2rem);
    grid-auto-flow: dense;
}

.masonry-item:nth-child(3n+1) {
    grid-row: span 2;
}

/* 3. Enhanced Flexbox Layouts */
.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-column {
    display: flex;
    flex-direction: column;
}

.flex-wrap {
    flex-wrap: wrap;
}

.flex-gap {
    gap: clamp(0.5rem, 2vw, 1.5rem);
}

/* 4. Advanced Responsive Spacing */
.section {
    padding: clamp(3rem, 8vw, 6rem) 0;
}

.section-sm {
    padding: clamp(2rem, 5vw, 4rem) 0;
}

.section-xs {
    padding: clamp(1rem, 3vw, 2rem) 0;
}

/* 5. Responsive Images and Media */
.responsive-img {
    width: 100%;
    height: auto;
    object-fit: cover;
    max-width: 100%;
}

.aspect-ratio-16-9 {
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.aspect-ratio-4-3 {
    aspect-ratio: 4 / 3;
    overflow: hidden;
}

.aspect-ratio-1-1 {
    aspect-ratio: 1 / 1;
    overflow: hidden;
}

/* 6. Advanced Card Layouts */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
    gap: clamp(1rem, 3vw, 2rem);
}

.card {
    background: #fff;
    border-radius: clamp(0.5rem, 2vw, 1rem);
    box-shadow: 0 4px clamp(0.5rem, 2vw, 1rem) rgba(0,0,0,0.1);
    overflow: hidden;
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px clamp(1rem, 3vw, 2rem) rgba(0,0,0,0.15);
}

/* 7. Enhanced Navigation for All Screen Sizes */
@media (max-width: 1200px) {
    .mega-menu {
        width: 900px;
        left: -150px;
    }
    
    .mega-menu-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

@media (max-width: 992px) {
    .header-container {
        flex-direction: column;
        height: auto;
        padding: 15px 0;
        gap: 15px;
    }
    
    .logo {
        margin-bottom: 0;
    }
    
    .main-nav {
        margin-left: 0;
        width: 100%;
        order: 3;
    }
    
    .main-nav ul {
        justify-content: center;
        flex-wrap: wrap;
        gap: 15px;
    }
    
    .user-profile-container {
        order: 2;
    }
    
    .mega-menu {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100vh;
        border-radius: 0;
        overflow-y: auto;
        transform: translateY(100%);
        z-index: 1000;
    }
    
    .mega-menu-grid {
        grid-template-columns: 1fr;
        gap: 30px;
        padding: 30px 20px;
    }
    
    .banner-content h1 {
        font-size: clamp(1.5rem, 5vw, 2.5rem);
    }
    
    .banner-content p {
        font-size: clamp(0.875rem, 2.5vw, 1.125rem);
    }
    
    .quick-access-items {
        grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
    }
    
    .services-grid,
    .supply-chain-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
    }
}

@media (max-width: 768px) {
    .main-nav ul {
        gap: 10px;
    }
    
    .main-nav a {
        font-size: 14px;
        padding: 8px 0;
    }
    
    .logo-text {
        font-size: clamp(0.875rem, 3vw, 1.125rem);
    }
    
    .section-header h2 {
        font-size: clamp(1.5rem, 5vw, 2rem);
    }
    
    .section-header p {
        font-size: clamp(0.875rem, 2.5vw, 1rem);
    }
    
    .supply-chain-tabs {
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 10px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .supply-chain-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .tab-item {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .search-access-section {
        padding: 20px 0;
    }
    
    .search-box {
        margin-bottom: 20px;
    }
    
    .access-item {
        padding: 15px;
    }
    
    .access-title {
        font-size: 16px;
    }
    
    .access-subtitle {
        font-size: 13px;
    }
    
    .service-card {
        min-height: 300px;
    }
    
    .card-header {
        padding: 15px;
    }
    
    .card-header-text h3 {
        font-size: 18px;
    }
    
    .card-subtitle {
        font-size: 13px;
    }
    
    .supply-chain-item {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }
    
    .item-icon {
        margin: 0 auto 15px;
    }
}

@media (max-width: 576px) {
    .container {
        padding: 0 15px;
    }
    
    .logo img {
        width: 60px;
        height: 60px;
    }
    
    .main-nav a {
        font-size: 13px;
    }
    
    .banner-content h1 {
        font-size: clamp(1.25rem, 6vw, 2rem);
    }
    
    .banner-content p {
        font-size: clamp(0.75rem, 3vw, 1rem);
    }
    
    .btn-primary {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .search-input {
        padding: 12px 45px 12px 15px;
        font-size: 14px;
    }
    
    .search-btn {
        width: 36px;
        height: 36px;
    }
    
    .quick-access-items {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .access-item {
        padding: 15px;
    }
    
    .services-grid,
    .supply-chain-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .service-card {
        min-height: 280px;
    }
    
    .card-front,
    .card-back {
        padding: 15px;
    }
    
    .card-header {
        padding: 0 0 15px;
    }
    
    .card-image-placeholder {
        height: 150px;
    }
    
    .supply-chain-item {
        padding: 15px;
    }
    
    .item-icon {
        width: 40px;
        height: 40px;
    }
    
    .item-icon svg {
        width: 20px;
        height: 20px;
    }
    
    .item-content h3 {
        font-size: 16px;
    }
    
    .item-content p {
        font-size: 13px;
    }
}

/* 8. Enhanced Footer Responsive Design */
@media (max-width: 992px) {
    .footer-content {
        grid-template-columns: repeat(2, 1fr);
        gap: 30px;
    }
}

@media (max-width: 768px) {
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 25px;
    }
    
    .footer-logo {
        display: flex;
        justify-content: center;
    }
    
    .f-nav-col h4::after {
        left: 50%;
        transform: translateX(-50%);
    }
    
    .footer-contact-info {
        text-align: center;
    }
    
    .footer-bottom-lines p {
        font-size: 11px;
    }
}

/* 9. Advanced Responsive Tables */
.responsive-table {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.responsive-table table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
}

@media (max-width: 768px) {
    .responsive-table {
        border: 1px solid #e8e8e8;
        border-radius: 8px;
    }
    
    .responsive-table table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* 10. Responsive Form Elements */
.form-group {
    margin-bottom: clamp(1rem, 3vw, 1.5rem);
}

.form-control {
    width: 100%;
    padding: clamp(0.75rem, 2vw, 1rem);
    font-size: clamp(0.875rem, 2.5vw, 1rem);
    border: 1px solid #e8e8e8;
    border-radius: clamp(0.25rem, 1vw, 0.5rem);
    transition: all 0.3s ease;
}

.form-control:focus {
    border-color: #1890ff;
    box-shadow: 0 0 0 clamp(0.125rem, 0.5vw, 0.25rem) rgba(24, 144, 255, 0.2);
}

/* 11. Responsive Modal and Dialog */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box;
}

.modal-content {
    background: #fff;
    border-radius: clamp(0.5rem, 2vw, 1rem);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: clamp(1.5rem, 4vw, 2rem);
}

@media (max-width: 768px) {
    .modal {
        padding: 15px;
    }
    
    .modal-content {
        padding: 1.5rem;
        max-height: 95vh;
    }
}

/* 12. Responsive Tabs */
.responsive-tabs {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.responsive-tabs::-webkit-scrollbar {
    display: none;
}

.responsive-tab {
    flex-shrink: 0;
    padding: clamp(0.75rem, 2vw, 1rem) clamp(1rem, 3vw, 1.5rem);
    white-space: nowrap;
}

/* 13. Responsive Accordion */
.accordion-item {
    margin-bottom: 1px;
    border-radius: 0;
}

.accordion-header {
    padding: clamp(0.75rem, 2vw, 1rem);
    font-size: clamp(0.875rem, 2.5vw, 1rem);
}

.accordion-content {
    padding: clamp(0.75rem, 2vw, 1rem);
    font-size: clamp(0.813rem, 2vw, 0.875rem);
}

/* 14. Responsive Carousel - Disabled for homepage banner compatibility
.carousel-container {
    width: 100%;
    overflow: hidden;
}

.carousel-wrapper {
    display: flex;
    transition: transform 0.5s ease;
}

.carousel-slide {
    min-width: 100%;
    flex-shrink: 0;
}
*/

@media (max-width: 768px) {
    .carousel-indicators {
        bottom: 10px;
    }
    
    .indicator {
        width: 30px;
        height: 3px;
    }
    
    .indicator.active {
        width: 45px;
    }
}

/* 15. Responsive Utility Classes */
.hide-mobile {
    display: block;
}

.show-mobile {
    display: none;
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none;
    }
    
    .show-mobile {
        display: block;
    }
}

.hide-tablet {
    display: block;
}

.show-tablet {
    display: none;
}

@media (min-width: 769px) and (max-width: 1024px) {
    .hide-tablet {
        display: none;
    }
    
    .show-tablet {
        display: block;
    }
}

.hide-desktop {
    display: block;
}

.show-desktop {
    display: none;
}

@media (min-width: 1025px) {
    .hide-desktop {
        display: none;
    }
    
    .show-desktop {
        display: block;
    }
}

/* 16. Advanced Responsive Grid with CSS Grid */
.responsive-grid {
    display: grid;
    gap: clamp(1rem, 3vw, 2rem);
}

.responsive-grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
}

.responsive-grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
}

.responsive-grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
}

/* 17. Responsive Typography Scale */
.text-responsive-xs {
    font-size: clamp(0.625rem, 2vw, 0.75rem);
}

.text-responsive-sm {
    font-size: clamp(0.75rem, 2.5vw, 0.875rem);
}

.text-responsive-base {
    font-size: clamp(0.875rem, 3vw, 1rem);
}

.text-responsive-lg {
    font-size: clamp(1rem, 3.5vw, 1.125rem);
}

.text-responsive-xl {
    font-size: clamp(1.125rem, 4vw, 1.25rem);
}

.text-responsive-2xl {
    font-size: clamp(1.25rem, 4.5vw, 1.5rem);
}

.text-responsive-3xl {
    font-size: clamp(1.5rem, 5vw, 1.875rem);
}

.text-responsive-4xl {
    font-size: clamp(1.875rem, 5.5vw, 2.25rem);
}

.text-responsive-5xl {
    font-size: clamp(2.25rem, 6vw, 3rem);
}

/* 18. Responsive Spacing Scale */
.p-responsive-xs {
    padding: clamp(0.25rem, 1vw, 0.5rem);
}

.p-responsive-sm {
    padding: clamp(0.5rem, 1.5vw, 1rem);
}

.p-responsive-md {
    padding: clamp(1rem, 2vw, 1.5rem);
}

.p-responsive-lg {
    padding: clamp(1.5rem, 3vw, 2rem);
}

.p-responsive-xl {
    padding: clamp(2rem, 4vw, 3rem);
}

.m-responsive-xs {
    margin: clamp(0.25rem, 1vw, 0.5rem);
}

.m-responsive-sm {
    margin: clamp(0.5rem, 1.5vw, 1rem);
}

.m-responsive-md {
    margin: clamp(1rem, 2vw, 1.5rem);
}

.m-responsive-lg {
    margin: clamp(1.5rem, 3vw, 2rem);
}

.m-responsive-xl {
    margin: clamp(2rem, 4vw, 3rem);
}

/* 19. Responsive Border Radius */
.rounded-responsive {
    border-radius: clamp(0.25rem, 1vw, 0.5rem);
}

.rounded-responsive-lg {
    border-radius: clamp(0.5rem, 2vw, 1rem);
}

.rounded-responsive-xl {
    border-radius: clamp(0.75rem, 3vw, 1.5rem);
}

.rounded-responsive-2xl {
    border-radius: clamp(1rem, 4vw, 2rem);
}

/* 20. Performance Optimizations */
@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;
    }
}

/* 21. Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .print-break-before {
        page-break-before: always;
    }
    
    .print-break-after {
        page-break-after: always;
    }
    
    .print-break-inside-avoid {
        page-break-inside: avoid;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
    }
    
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }
    
    img {
        max-width: 100% !important;
    }
    
    a {
        text-decoration: none;
        color: inherit;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
}