/* ===================================
   MOBILE-FIRST RESPONSIVE FIXES
   SmartStone - Production Ready
   =================================== */

/* ===================================
   1. GLOBAL OVERFLOW PREVENTION
   =================================== */

html {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

.page-wrapper {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* Ensure all containers respect viewport */
.container {
    width: 100%;
    max-width: 100%;
    padding-left: 15px;
    padding-right: 15px;
    box-sizing: border-box;
}

/* Prevent any element from causing horizontal scroll */
*, *::before, *::after {
    box-sizing: border-box;
}

img, video, iframe, embed, object {
    max-width: 100%;
    height: auto;
}

/* ===================================
   2. MOBILE HEADER FIXES
   =================================== */

/* Header actions - clean layout */
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* Search toggle - smaller on mobile */
.search-toggle {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

/* Mobile menu toggle - always visible on mobile */
.mobile-menu-toggle {
    display: none;
    width: 44px;
    height: 44px;
    padding: 10px;
    flex-shrink: 0;
}

/* ===================================
   3. MOBILE MENU FIXES
   =================================== */

.mobile-menu {
    position: fixed;
    top: 0;
    left: -100%;
    width: min(320px, 85vw);
    height: 100vh;
    height: 100dvh;
    background: var(--bg);
    z-index: 2000;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mobile-menu.active {
    left: 0;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.mobile-nav {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.mobile-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

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

.mobile-nav ul li a {
    display: block;
    padding: 15px 0;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    font-size: 1rem;
}

.mobile-menu-footer {
    padding: 15px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.mobile-menu-footer .btn {
    width: 100%;
    justify-content: center;
}

/* Mobile menu overlay */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ===================================
   4. TOP BAR MOBILE FIXES
   =================================== */

.top-bar {
    padding: 8px 0;
}

.top-bar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
}

.top-bar-left {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    font-size: 0.8rem;
}

.top-bar-left span {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.social-links {
    display: flex;
    gap: 10px;
}

.theme-toggle {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

/* ===================================
   5. HERO SECTION MOBILE FIXES
   =================================== */

.hero-section {
    min-height: 70vh;
    overflow: hidden;
}

.hero-content {
    max-width: 100%;
    padding: 0 15px;
}

.hero-title {
    font-size: clamp(1.5rem, 5vw, 2.5rem) !important;
    line-height: 1.2;
    word-wrap: break-word;
}

.hero-title span {
    display: inline;
}

.hero-description {
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    line-height: 1.6;
}

.hero-subtitle {
    font-size: clamp(0.65rem, 2vw, 0.8rem);
    padding: 8px 16px;
    letter-spacing: 1px;
}

.hero-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.hero-buttons .btn {
    flex: 1 1 auto;
    min-width: 140px;
    padding: 12px 20px;
    font-size: 0.9rem;
}

/* ===================================
   6. SECTION & GRID MOBILE FIXES
   =================================== */

.section {
    padding: 50px 0;
    overflow: hidden;
}

.section-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 0 15px;
}

.section-title {
    font-size: clamp(1.25rem, 4vw, 2rem) !important;
    line-height: 1.3;
}

.section-subtitle {
    font-size: clamp(0.75rem, 2vw, 0.9rem);
}

.section-description {
    font-size: clamp(0.875rem, 2.5vw, 1rem);
    max-width: 100%;
}

/* Product grids */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
    gap: 20px;
    padding: 0;
}

/* Category grids */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr));
    gap: 20px;
}

/* Features grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr));
    gap: 20px;
}

/* ===================================
   7. CARD MOBILE FIXES
   =================================== */

.product-card,
.category-card,
.feature-card,
.service-card,
.client-card {
    width: 100%;
    max-width: 100%;
}

.product-card-image img,
.category-card-image,
.service-image {
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* ===================================
   8. SLIDER/CAROUSEL MOBILE FIXES
   =================================== */

/* Services Owl Carousel */
.services-owl-wrapper {
    margin: 30px -15px 0;
    padding: 20px 15px;
    border-radius: 0;
    overflow: hidden;
}

.services-owl-carousel {
    min-height: auto;
}

.service-item {
    padding: 0 10px;
}

.service-card {
    min-height: auto;
}

/* Clients slider */
.clients-slider-wrapper {
    overflow: hidden;
}

.clients-slider {
    display: flex;
    gap: 1rem;
    overflow: hidden;
    padding: 1rem 0;
}

.client-slide {
    flex: 0 0 auto;
    width: min(240px, 80vw);
}

/* Projects grid */
.projects-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

/* ===================================
   9. FOOTER MOBILE FIXES
   =================================== */

.site-footer {
    overflow: hidden;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
}

.footer-col {
    width: 100%;
}

.footer-bottom-content {
    flex-direction: column;
    gap: 15px;
    text-align: center;
}

.footer-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
}

.newsletter-form {
    flex-direction: column;
    gap: 10px;
}

.newsletter-form input {
    width: 100%;
}

.newsletter-form button {
    width: 100%;
    height: auto;
    padding: 14px;
}

/* ===================================
   10. FORM MOBILE FIXES
   =================================== */

.form-control {
    width: 100%;
    padding: 12px 15px;
    font-size: 16px; /* Prevents iOS zoom */
}

input, textarea, select {
    font-size: 16px; /* Prevents iOS zoom */
}

/* ===================================
   11. BUTTON MOBILE FIXES
   =================================== */

.btn {
    padding: 12px 20px;
    font-size: 0.9rem;
    white-space: nowrap;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 1rem;
}

.btn-xl {
    padding: 16px 28px;
    font-size: 1rem;
}

/* ===================================
   12. CTA SECTION MOBILE FIXES
   =================================== */

.cta-section {
    padding: 50px 0;
    overflow: hidden;
}

.cta-title {
    font-size: clamp(1.25rem, 4vw, 2rem);
    line-height: 1.3;
}

.cta-description {
    font-size: clamp(0.875rem, 2.5vw, 1rem);
}

.cta-buttons {
    flex-direction: column;
    gap: 15px !important;
    width: 100%;
}

.cta-buttons .btn {
    width: 100%;
    justify-content: center;
}

/* ===================================
   13. MEGA MENU - HIDE ON MOBILE
   =================================== */

.mega-menu {
    display: none;
}

/* ===================================
   14. SEARCH OVERLAY MOBILE FIXES
   =================================== */

.search-overlay {
    padding: 20px 0;
}

.search-form {
    flex-direction: row;
    gap: 10px;
    padding: 0 15px;
}

.search-form input {
    flex: 1;
    padding: 14px 18px;
    font-size: 16px;
}

.search-form button {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
}

/* ===================================
   15. FLIPBOOK MOBILE FIXES
   =================================== */

.flipbook-spread {
    grid-template-columns: 1fr;
}

.flipbook-page {
    min-height: 50vh;
}

/* ===================================
   16. RESPONSIVE BREAKPOINTS
   =================================== */

/* Extra small devices (phones, less than 576px) */
@media (max-width: 575.98px) {
    .container {
        padding-left: 12px;
        padding-right: 12px;
    }
    
    .top-bar-left {
        display: none;
    }
    
    .hero-section {
        min-height: 60vh;
    }
    
    .hero-buttons {
        flex-direction: column;
    }
    
    .hero-buttons .btn {
        width: 100%;
    }
    
    .section {
        padding: 40px 0;
    }
    
    .products-grid,
    .categories-grid,
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .cta-buttons {
        flex-direction: column;
    }
    
    .footer-grid {
        grid-template-columns: 1fr;
    }
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
    .container {
        max-width: 540px;
        padding-left: 15px;
        padding-right: 15px;
    }
    
    .products-grid,
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
    .container {
        max-width: 720px;
    }
    
    .top-bar-left {
        display: flex;
    }
    
    .hero-section {
        min-height: 80vh;
    }
    
    .hero-buttons {
        flex-direction: row;
    }
    
    .section {
        padding: 60px 0;
    }
    
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .categories-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .cta-buttons {
        flex-direction: row !important;
    }
    
    .cta-buttons .btn {
        width: auto;
    }
    
    .newsletter-form {
        flex-direction: row;
    }
    
    .newsletter-form button {
        width: 50px;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .container {
        max-width: 960px;
    }
    
    .mobile-menu-toggle {
        display: none !important;
    }
    
    .main-nav {
        display: flex !important;
    }
    
    .mega-menu {
        display: block;
    }
    
    .hero-section {
        min-height: 90vh;
    }
    
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .categories-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .features-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .footer-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
    
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .projects-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* XXL devices (1400px and up) */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}

/* ===================================
   17. MOBILE-SPECIFIC OVERRIDES
   =================================== */

@media (max-width: 991.98px) {
    /* Force mobile menu toggle visible */
    .mobile-menu-toggle {
        display: flex !important;
    }
    
    /* Hide desktop nav */
    .main-nav {
        display: none !important;
    }
    
    /* Header content layout */
    .header-content {
        padding: 10px 0;
    }
    
    /* Logo sizing */
    .logo img {
        height: 50px;
    }
    
    /* Prevent fixed width issues */
    .mega-menu {
        display: none !important;
    }
}

/* ===================================
   18. TOUCH DEVICE OPTIMIZATIONS
   =================================== */

@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects that don't work on touch */
    .btn:hover {
        transform: none;
    }
    
    .product-card:hover {
        transform: none;
    }
    
    .category-card:hover {
        transform: none;
    }
    
    /* Larger touch targets */
    .mobile-nav ul li a {
        padding: 18px 0;
    }
    
    .btn {
        min-height: 44px;
    }
}

/* ===================================
   19. SAFE AREA INSETS (NOTCH PHONES)
   =================================== */

@supports (padding: max(0px)) {
    .mobile-menu {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
    
    .mobile-menu-footer {
        padding-bottom: max(15px, env(safe-area-inset-bottom));
    }
}

/* ===================================
   20. PRINT STYLES
   =================================== */

@media print {
    .mobile-menu,
    .mobile-menu-overlay,
    .mobile-menu-toggle,
    .search-toggle,
    .theme-toggle {
        display: none !important;
    }
}
