/**
 * Mobile Optimization CSS
 * Responsive design for all screen sizes
 */

/* ===========================================
   1. BASE MOBILE OPTIMIZATIONS
   =========================================== */

/* Prevent text size adjustment */
html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Smooth scrolling on mobile */
body {
    -webkit-overflow-scrolling: touch;
    overflow-scrolling: touch;
}

/* Better tap highlighting */
* {
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    tap-highlight-color: rgba(0,0,0,0.1);
}

/* Remove default button styles on iOS */
button,
input[type="submit"],
input[type="button"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* ===========================================
   2. MOBILE BREAKPOINTS
   =========================================== */

/* Mobile First Approach */

/* Extra Small Devices (phones, 320px and up) */
@media (max-width: 575px) {
    
    /* Typography */
    body {
        font-size: 14px;
        line-height: 1.6;
    }
    
    h1 {
        font-size: 1.75rem; /* 28px */
        line-height: 1.3;
    }
    
    h2 {
        font-size: 1.5rem; /* 24px */
        line-height: 1.3;
    }
    
    h3 {
        font-size: 1.25rem; /* 20px */
        line-height: 1.4;
    }
    
    /* Container */
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* Hero Section */
    .hero-section {
        min-height: auto;
        padding: 40px 15px;
    }
    
    .hero-title {
        font-size: 1.75rem;
        margin-bottom: 15px;
    }
    
    .hero-subtitle {
        font-size: 0.9rem;
        margin-bottom: 20px;
    }
    
    /* Search Bar */
    .search-wrapper {
        width: 100%;
    }
    
    .search-input {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 12px 15px;
    }
    
    .search-button {
        padding: 12px 20px;
        font-size: 14px;
    }
    
    /* Statistics */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    
    .stat-item {
        padding: 15px;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
    
    /* Cards */
    .grid-3-cols {
        grid-template-columns: 1fr !important;
        gap: 20px;
    }
    
    .grid-2-cols {
        grid-template-columns: 1fr !important;
        gap: 20px;
    }
    
    .article-card,
    .plant-card,
    .category-card {
        margin-bottom: 20px;
    }
    
    /* Card Content */
    .card-title {
        font-size: 1.1rem;
    }
    
    .card-description {
        font-size: 0.9rem;
        line-height: 1.5;
    }
    
    /* Buttons */
    .btn {
        width: 100%;
        padding: 14px 20px;
        font-size: 15px;
    }
    
    .btn-group {
        flex-direction: column;
        gap: 10px;
    }
    
    /* Navigation */
    .main-nav {
        padding: 10px 15px;
    }
    
    .nav-menu {
        display: none; /* Show mobile menu instead */
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    /* Section Padding */
    section {
        padding: 40px 0;
    }
    
    .section-title {
        font-size: 1.5rem;
        margin-bottom: 15px;
    }
    
    .section-description {
        font-size: 0.9rem;
        margin-bottom: 25px;
    }
    
    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 30px;
        text-align: center;
    }
    
    .footer-column {
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        padding-bottom: 20px;
    }
    
    .footer-column:last-child {
        border-bottom: none;
    }
    
    /* How-to Cards */
    .howto-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Collection Cards */
    .collection-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Small Devices (landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767px) {
    
    .grid-3-cols {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.75rem;
    }
}

/* Medium Devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991px) {
    
    .container {
        padding-left: 30px;
        padding-right: 30px;
    }
    
    .grid-3-cols {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .grid-6-cols {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    section {
        padding: 60px 0;
    }
}

/* Large Devices (desktops, 992px and up) */
@media (min-width: 992px) {
    
    .container {
        max-width: 1400px;
        margin: 0 auto;
    }
    
    /* Show desktop navigation */
    .mobile-menu-toggle {
        display: none;
    }
    
    .nav-menu {
        display: flex;
    }
}

/* ===========================================
   3. TOUCH OPTIMIZATIONS
   =========================================== */

/* Larger touch targets (minimum 44x44px) */
@media (max-width: 767px) {
    
    button,
    a.btn,
    input[type="submit"],
    input[type="button"],
    .clickable {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
    }
    
    /* Card links */
    .card-link {
        display: block;
        padding: 15px;
    }
    
    /* Icon buttons */
    .icon-button {
        width: 48px;
        height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Form inputs */
    input,
    select,
    textarea {
        min-height: 44px;
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 12px 15px;
    }
}

/* ===========================================
   4. MOBILE NAVIGATION
   =========================================== */

@media (max-width: 991px) {
    
    /* Hamburger Menu */
    .mobile-menu-toggle {
        width: 40px;
        height: 40px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        z-index: 1001;
    }
    
    .hamburger-line {
        width: 25px;
        height: 3px;
        background: #2C3E50;
        margin: 3px 0;
        transition: all 0.3s ease;
        border-radius: 3px;
    }
    
    .mobile-menu-toggle.active .hamburger-line:nth-child(1) {
        transform: translateY(9px) rotate(45deg);
    }
    
    .mobile-menu-toggle.active .hamburger-line:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-menu-toggle.active .hamburger-line:nth-child(3) {
        transform: translateY(-9px) rotate(-45deg);
    }
    
    /* Mobile Menu Overlay */
    .mobile-nav-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        z-index: 999;
    }
    
    .mobile-nav-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Mobile Menu Drawer */
    .mobile-nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 300px;
        height: 100%;
        background: white;
        box-shadow: -2px 0 10px rgba(0,0,0,0.1);
        transition: right 0.3s ease;
        z-index: 1000;
        overflow-y: auto;
        padding: 80px 20px 20px;
    }
    
    .mobile-nav.active {
        right: 0;
    }
    
    .mobile-nav-item {
        padding: 15px 20px;
        border-bottom: 1px solid #f0f0f0;
        font-size: 16px;
        color: #2C3E50;
        text-decoration: none;
        display: block;
        transition: background 0.2s ease;
    }
    
    .mobile-nav-item:hover {
        background: #f8f8f8;
    }
}

/* ===========================================
   5. LANDSCAPE OPTIMIZATIONS
   =========================================== */

@media (max-width: 767px) and (orientation: landscape) {
    
    /* Reduce hero height on landscape */
    .hero-section {
        min-height: auto;
        padding: 30px 15px;
    }
    
    /* Adjust font sizes */
    .hero-title {
        font-size: 1.5rem;
    }
    
    /* Stack elements horizontally */
    .stats-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* ===========================================
   6. IMAGE OPTIMIZATIONS FOR MOBILE
   =========================================== */

@media (max-width: 767px) {
    
    /* Responsive images */
    img {
        max-width: 100%;
        height: auto;
    }
    
    /* Hero images */
    .hero-image {
        width: 100%;
        height: auto;
        margin-bottom: 20px;
    }
    
    /* Card images */
    .card-image {
        height: 200px;
        object-fit: cover;
    }
}

/* ===========================================
   7. MOBILE-SPECIFIC UTILITIES
   =========================================== */

/* Hide on mobile */
@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: none !important;
}

@media (max-width: 767px) {
    .show-mobile {
        display: block !important;
    }
}

/* Stack on mobile */
@media (max-width: 767px) {
    .stack-mobile {
        flex-direction: column !important;
    }
    
    .stack-mobile > * {
        width: 100% !important;
        margin-bottom: 15px;
    }
}

/* Center on mobile */
@media (max-width: 767px) {
    .center-mobile {
        text-align: center !important;
    }
}

/* Full width on mobile */
@media (max-width: 767px) {
    .full-width-mobile {
        width: 100% !important;
    }
}

/* ===========================================
   8. MOBILE PERFORMANCE
   =========================================== */

@media (max-width: 767px) {
    
    /* Disable hover effects on mobile */
    .card:hover {
        transform: none;
    }
    
    /* Reduce animations */
    * {
        animation-duration: 0.2s !important;
    }
    
    /* Simplify shadows */
    .box-shadow-heavy {
        box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
    }
}

/* ===========================================
   9. SAFE AREA (iPhone X notch)
   =========================================== */

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

/* ===========================================
   10. MOBILE FORMS
   =========================================== */

@media (max-width: 767px) {
    
    /* Stack form fields */
    .form-row {
        flex-direction: column;
    }
    
    .form-group {
        width: 100%;
        margin-bottom: 15px;
    }
    
    /* Larger input fields */
    input,
    textarea,
    select {
        width: 100%;
        font-size: 16px;
        padding: 14px;
        border-radius: 8px;
    }
    
    /* Submit buttons */
    input[type="submit"],
    button[type="submit"] {
        width: 100%;
        padding: 16px;
        font-size: 16px;
    }
}
/*
 * Mobile Responsive Enhancements
 * Kasetidea Theme - Version 1.0.0
 */

/* ============================================
   MOBILE BREAKPOINTS
   ============================================ */

/* Extra Small Devices (phones, 320px to 575px) */
@media (max-width: 575px) {
    
    /* Typography */
    body {
        font-size: 14px;
        line-height: 1.6;
    }
    
    h1 { font-size: 1.75rem !important; }
    h2 { font-size: 1.5rem !important; }
    h3 { font-size: 1.25rem !important; }
    h4 { font-size: 1.1rem !important; }
    
    /* Containers */
    .container {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    /* Hero Section */
    .hero-section {
        padding: 40px 0 !important;
    }
    
    .hero-section h1 {
        font-size: 1.75rem !important;
        line-height: 1.3 !important;
    }
    
    .hero-section p {
        font-size: 0.9rem !important;
    }
    
    /* Search Bar */
    .search-bar {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .search-bar input {
        font-size: 14px !important;
        padding: 12px 15px !important;
    }
    
    .search-bar button {
        padding: 10px 15px !important;
        font-size: 13px !important;
    }
    
    /* Statistics */
    .stats-container {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
        margin-top: 20px !important;
    }
    
    .stat-item {
        font-size: 0.9rem !important;
    }
    
    .stat-number {
        font-size: 1.5rem !important;
    }
    
    /* Cards Grid */
    .grid-3-cols,
    .grid-2-cols {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    /* Plant Cards */
    .plant-card,
    .article-card {
        margin-bottom: 15px !important;
    }
    
    .plant-card h3,
    .article-card h3 {
        font-size: 1.1rem !important;
    }
    
    .plant-card p,
    .article-card p {
        font-size: 0.85rem !important;
        line-height: 1.5 !important;
    }
    
    /* Buttons */
    .btn,
    button,
    a.button {
        padding: 10px 20px !important;
        font-size: 14px !important;
        min-height: 44px !important; /* Touch target */
    }
    
    /* Navigation */
    .main-nav {
        padding: 10px 0 !important;
    }
    
    .nav-menu {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
    
    .nav-item {
        width: 100% !important;
        padding: 10px 0 !important;
        border-bottom: 1px solid #eee;
    }
    
    /* Footer */
    footer .footer-columns {
        grid-template-columns: 1fr !important;
        gap: 30px !important;
    }
    
    footer h4 {
        font-size: 1rem !important;
        margin-bottom: 15px !important;
    }
    
    footer ul li {
        padding: 8px 0 !important;
    }
    
    /* Sections Spacing */
    section {
        padding: 40px 0 !important;
    }
    
    .section-header {
        margin-bottom: 25px !important;
    }
    
    /* Collections Cards */
    .collection-card {
        padding: 20px !important;
    }
    
    .collection-items {
        flex-wrap: wrap !important;
    }
    
    .collection-item {
        padding: 6px 12px !important;
        font-size: 0.8rem !important;
        margin: 4px !important;
    }
    
    /* Modals */
    .modal-content {
        width: 95% !important;
        margin: 20px auto !important;
        padding: 20px !important;
    }
    
    /* Hide on Mobile */
    .hide-mobile {
        display: none !important;
    }
}

/* Small Devices (tablets, 576px to 767px) */
@media (min-width: 576px) and (max-width: 767px) {
    
    /* Typography */
    body {
        font-size: 15px;
    }
    
    h1 { font-size: 2rem !important; }
    h2 { font-size: 1.75rem !important; }
    h3 { font-size: 1.5rem !important; }
    
    /* Grid */
    .grid-3-cols {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px !important;
    }
    
    /* Statistics */
    .stats-container {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 15px !important;
    }
    
    /* Cards */
    .plant-card,
    .article-card {
        margin-bottom: 20px !important;
    }
}

/* Medium Devices (tablets, 768px to 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    
    /* Grid */
    .grid-3-cols {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 25px !important;
    }
    
    /* Hero */
    .hero-section h1 {
        font-size: 2.5rem !important;
    }
    
    /* Footer */
    footer .footer-columns {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 30px !important;
    }
}

/* ============================================
   TOUCH OPTIMIZATION
   ============================================ */

/* Touch Targets - Minimum 44x44px */
@media (hover: none) and (pointer: coarse) {
    
    /* Touch targets for interactive elements, but exclude logo links */
    a:not(.site-logo):not(.custom-logo-link):not([class*="logo"]), 
    button:not(.mobile-menu-toggle), 
    input, 
    select, 
    textarea {
        min-height: 44px !important;
        min-width: 44px !important;
    }
    
    /* Menu toggle needs proper touch target */
    .mobile-menu-toggle {
        min-height: 44px !important;
        min-width: 44px !important;
    }
    
    .touch-target {
        padding: 12px !important;
    }
    
    /* Remove hover effects on touch devices */
    .card:hover,
    .button:hover {
        transform: none !important;
    }
    
    /* Tap highlight */
    * {
        -webkit-tap-highlight-color: rgba(39, 174, 96, 0.2);
    }
}

/* ============================================
   LANDSCAPE ORIENTATION
   ============================================ */

@media (max-width: 767px) and (orientation: landscape) {
    
    .hero-section {
        padding: 30px 0 !important;
    }
    
    .hero-section h1 {
        font-size: 1.75rem !important;
    }
    
    section {
        padding: 30px 0 !important;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus Visible for Keyboard Navigation */
@media (hover: none) {
    
    a:focus,
    button:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 3px solid #27AE60 !important;
        outline-offset: 2px !important;
    }
}

/* ============================================
   IMAGE RESPONSIVENESS
   ============================================ */

@media (max-width: 575px) {
    
    /* Plant Images */
    .plant-image,
    .article-image {
        height: 180px !important;
        object-fit: cover;
    }
    
    /* Hero Background */
    .hero-section {
        background-size: cover !important;
        background-position: center !important;
    }
    
    /* Card Images */
    .card-image {
        height: 150px !important;
        object-fit: cover;
    }
}

/* ============================================
   MOBILE MENU
   ============================================ */

@media (max-width: 991px) {
    
    /* Hamburger Menu */
    .mobile-menu-toggle {
        display: block !important;
        font-size: 24px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 10px;
        color: #2C3E50;
    }
    
    .mobile-menu {
        display: none;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        background: white;
        box-shadow: 0 5px 20px rgba(0,0,0,0.1);
        z-index: 999;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    
    .mobile-menu.active {
        display: block;
        max-height: calc(100vh - 60px);
        overflow-y: auto;
    }
    
    .mobile-menu-items {
        padding: 20px;
    }
    
    .mobile-menu-item {
        padding: 15px 0;
        border-bottom: 1px solid #eee;
        font-size: 16px;
    }
    
    .mobile-menu-item:last-child {
        border-bottom: none;
    }
}

/* ============================================
   SAFE AREA (iPhone X+)
   ============================================ */

@supports (padding: max(0px)) {
    
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    .fixed-bottom {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    
    /* Hide non-essential elements */
    header,
    footer,
    .no-print {
        display: none !important;
    }
    
    /* Optimize for print */
    body {
        font-size: 12pt;
        line-height: 1.5;
        color: black;
        background: white;
    }
    
    a {
        text-decoration: underline;
        color: black;
    }
    
    /* Page breaks */
    h1, h2, h3 {
        page-break-after: avoid;
    }
    
    img {
        max-width: 100%;
        page-break-inside: avoid;
    }
}
/*
 * Search Mobile Fix V2 - ULTRA FORCE OVERRIDE
 * Kasetidea Theme - แก้ปัญหา Input Field หายบนมือถือ
 * Priority: MAXIMUM
 */

/* ============================================
   MOBILE SEARCH FIX - EXTRA SMALL (< 480px)
   ULTRA HIGH SPECIFICITY
   ============================================ */

@media (max-width: 479px) {
    
    /* Remove all potential conflicts */
    body .hero-premium .search-box-premium *,
    body .hero-premium .search-box-premium *::before,
    body .hero-premium .search-box-premium *::after {
        box-sizing: border-box !important;
    }
    
    /* Search Box Container */
    body .hero-premium .search-box-premium {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 10px !important;
        margin: 0 auto 40px !important;
    }
    
    /* Form */
    body .hero-premium .search-box-premium form {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Main Search Container - FORCE FLEXBOX */
    body .hero-premium .search-box-premium form > div:first-of-type {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 4px !important;
        
        background: white !important;
        border-radius: 40px !important;
        padding: 4px !important;
        box-shadow: 0 10px 30px rgba(0,0,0,0.15) !important;
        
        width: 100% !important;
        min-height: 44px !important;
        
        position: relative !important;
        overflow: visible !important;
    }
    
    /* Icon - FORCE VISIBLE */
    body .hero-premium .search-box-premium form > div:first-of-type > span:first-child,
    body .hero-premium .search-box-premium form > div:first-of-type > *:first-child:not(input):not(button) {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        flex-grow: 0 !important;
        
        width: auto !important;
        min-width: 28px !important;
        max-width: 35px !important;
        
        padding: 0 6px !important;
        margin: 0 !important;
        
        font-size: 18px !important;
        line-height: 1 !important;
        
        opacity: 1 !important;
        visibility: visible !important;
        position: relative !important;
        z-index: 2 !important;
    }
    
    /* Input Field - FORCE VISIBLE AND FLEXIBLE */
    body .hero-premium .search-box-premium form > div:first-of-type input[type="text"],
    body .hero-premium .search-box-premium form > div:first-of-type input[name="s"],
    body .hero-premium .search-box-premium input[type="text"],
    body .hero-premium .search-box-premium input[name="s"] {
        /* DISPLAY - FORCE VISIBLE */
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
        
        /* FLEXBOX */
        flex: 1 1 auto !important;
        flex-shrink: 1 !important;
        flex-grow: 1 !important;
        
        /* SIZING */
        min-width: 80px !important;
        max-width: none !important;
        width: auto !important;
        height: auto !important;
        min-height: 36px !important;
        
        /* SPACING */
        padding: 10px 8px !important;
        margin: 0 !important;
        
        /* STYLING */
        background: transparent !important;
        border: none !important;
        outline: none !important;
        box-shadow: none !important;
        
        /* TEXT */
        font-size: 13px !important;
        font-weight: 400 !important;
        color: #333 !important;
        line-height: 1.4 !important;
        text-align: left !important;
        
        /* POSITION */
        position: relative !important;
        z-index: 2 !important;
        
        /* REMOVE TRANSFORMS */
        transform: none !important;
        
        /* ENSURE IT'S THERE */
        clip: auto !important;
        clip-path: none !important;
    }
    
    /* Placeholder */
    body .hero-premium .search-box-premium input::placeholder {
        color: #999 !important;
        font-size: 12px !important;
        opacity: 0.7 !important;
    }
    
    body .hero-premium .search-box-premium input::-webkit-input-placeholder {
        color: #999 !important;
        font-size: 12px !important;
    }
    
    body .hero-premium .search-box-premium input::-moz-placeholder {
        color: #999 !important;
        font-size: 12px !important;
    }
    
    /* Button - FORCE SIZE AND POSITION */
    body .hero-premium .search-box-premium form > div:first-of-type button[type="submit"],
    body .hero-premium .search-box-premium button[type="submit"] {
        /* DISPLAY */
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
        
        /* FLEXBOX */
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        flex-grow: 0 !important;
        
        /* SIZING */
        min-width: 60px !important;
        max-width: 80px !important;
        width: auto !important;
        height: 36px !important;
        min-height: 36px !important;
        
        /* SPACING */
        padding: 8px 16px !important;
        margin: 0 !important;
        
        /* STYLING */
        background: linear-gradient(135deg, #27AE60, #2ECC71) !important;
        color: white !important;
        border: none !important;
        border-radius: 32px !important;
        box-shadow: none !important;
        
        /* TEXT */
        font-size: 13px !important;
        font-weight: 700 !important;
        line-height: 1 !important;
        text-align: center !important;
        white-space: nowrap !important;
        
        /* CURSOR */
        cursor: pointer !important;
        
        /* POSITION */
        position: relative !important;
        z-index: 2 !important;
        
        /* REMOVE TRANSFORMS */
        transform: none !important;
    }
    
    /* Quick Search Container */
    body .hero-premium .search-box-premium form > div:last-of-type,
    body .hero-premium .search-box-premium form > div:nth-child(2) {
        margin-top: 12px !important;
        text-align: center !important;
        width: 100% !important;
        padding: 0 !important;
    }
    
    /* Quick Search Label */
    body .hero-premium .search-box-premium form > div:last-of-type > span:first-child {
        display: block !important;
        color: rgba(255,255,255,0.9) !important;
        font-size: 12px !important;
        margin-bottom: 8px !important;
        font-weight: 600 !important;
    }
    
    /* Quick Search Tags */
    body .hero-premium .search-box-premium a.quick-search-tag,
    body .hero-premium .search-box-premium form a {
        display: inline-block !important;
        background: rgba(255,255,255,0.25) !important;
        color: white !important;
        padding: 6px 10px !important;
        border-radius: 15px !important;
        text-decoration: none !important;
        margin: 3px 2px !important;
        font-size: 11px !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
    }
}

/* ============================================
   SMALL MOBILE (480px - 767px)
   ============================================ */

@media (min-width: 480px) and (max-width: 767px) {
    
    body .hero-premium .search-box-premium {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 15px !important;
    }
    
    body .hero-premium .search-box-premium form > div:first-of-type {
        display: flex !important;
        align-items: center !important;
        background: white !important;
        border-radius: 50px !important;
        padding: 4px !important;
        box-shadow: 0 15px 40px rgba(0,0,0,0.2) !important;
    }
    
    body .hero-premium .search-box-premium form > div:first-of-type > span:first-child {
        padding: 0 12px !important;
        font-size: 20px !important;
    }
    
    body .hero-premium .search-box-premium input[type="text"],
    body .hero-premium .search-box-premium input[name="s"] {
        flex: 1 !important;
        border: none !important;
        padding: 12px 8px !important;
        font-size: 14px !important;
        background: transparent !important;
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    body .hero-premium .search-box-premium button[type="submit"] {
        padding: 12px 22px !important;
        font-size: 14px !important;
        border-radius: 40px !important;
        min-width: 70px !important;
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
}

/* ============================================
   FORCE REMOVE TOGGLE (ทุกขนาดหน้าจอ)
   ============================================ */

.search-toggle,
.toggle-switch,
body .hero-premium .search-box-premium .toggle,
body .hero-premium .search-box-premium label[for*="toggle"],
body .hero-premium .search-box-premium input[type="checkbox"],
input[type="checkbox"][id*="search"],
label[for*="search-toggle"] {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    position: absolute !important;
    left: -9999px !important;
}

/* ============================================
   ENSURE SINGLE ROW LAYOUT
   ============================================ */

body .hero-premium .search-box-premium form > div:first-of-type {
    flex-wrap: nowrap !important;
}

body .hero-premium .search-box-premium form > div:first-of-type > * {
    flex-shrink: 0 !important;
}

body .hero-premium .search-box-premium form > div:first-of-type input {
    flex-shrink: 1 !important;
}

/* ============================================
   FOCUS STATES
   ============================================ */

body .hero-premium .search-box-premium input:focus {
    outline: none !important;
    background: rgba(255,255,255,0.05) !important;
}

body .hero-premium .search-box-premium form > div:first-of-type:focus-within {
    box-shadow: 0 20px 50px rgba(0,0,0,0.25), 
                0 0 0 3px rgba(39, 174, 96, 0.3) !important;
}

/* ============================================
   TOUCH OPTIMIZATION
   ============================================ */

@media (hover: none) and (pointer: coarse) {
    body .hero-premium .search-box-premium button {
        min-height: 44px !important;
        min-width: 80px !important;
    }
}

/* ============================================
   DEBUG MODE - Uncomment เพื่อ debug
   ============================================ */

/*
body .hero-premium .search-box-premium {
    border: 3px solid red !important;
}

body .hero-premium .search-box-premium form > div:first-of-type {
    border: 3px solid blue !important;
}

body .hero-premium .search-box-premium input {
    border: 2px solid green !important;
    background: rgba(0,255,0,0.1) !important;
}

body .hero-premium .search-box-premium button {
    border: 2px solid orange !important;
}
*/
/**
 * Mobile Layout Stabilizer v1.3.6.2
 * แก้ปัญหา Layout Shift, Jittering, และ Instability บนมือถือ
 * 
 * @package PlantPedia
 * @version 1.3.6.2
 */

/* ========================================
   CRITICAL MOBILE FIXES
   ======================================== */

/* 1. Prevent Layout Shifts */
* {
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* 2. Fix iOS Safari Bounce/Overscroll */
html, body {
    overflow-x: hidden;
    overscroll-behavior-x: none;
    overscroll-behavior-y: contain;
}

body {
    position: relative;
    width: 100%;
    min-height: 100vh;
}

/* 3. Prevent Content Shifts During Scroll */
.site-wrapper,
.review-container {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

/* ========================================
   FIX ANIMATIONS ON MOBILE
   ======================================== */

@media (max-width: 991px) {
    /* Disable hover animations on touch devices */
    .taxonomy-chip:hover,
    .taxonomy-tag:hover,
    .gallery-thumb:hover,
    .spec-card:hover,
    .cta-btn:hover {
        transform: none !important;
    }
    
    /* Reduce motion for better stability */
    * {
        animation-duration: 0.3s !important;
        transition-duration: 0.2s !important;
    }
    
    /* Disable parallax/heavy animations */
    .hero-section,
    .review-hero {
        transform: none !important;
        will-change: auto !important;
    }
}

/* ========================================
   FIX VIEWPORT HEIGHT ISSUES (iOS Safari)
   ======================================== */

/* Use dvh (dynamic viewport height) when available */
@supports (height: 100dvh) {
    body {
        min-height: 100dvh;
    }
}

/* Fallback for older browsers */
@supports not (height: 100dvh) {
    body {
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }
}

/* ========================================
   FIX FIXED/STICKY ELEMENTS
   ======================================== */

@media (max-width: 991px) {
    /* Ensure fixed elements don't cause layout shifts */
    .site-header {
        position: sticky;
        top: 0;
        z-index: 1000;
        width: 100%;
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        backface-visibility: hidden;
    }
    
    /* Fix sticky TOC on mobile */
    .table-of-contents {
        position: relative !important;
        top: auto !important;
        transform: none !important;
    }
    
    /* Fix floating elements */
    .floating-cta,
    .scroll-to-top {
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        will-change: transform;
    }
}

/* ========================================
   FIX IMAGES CAUSING LAYOUT SHIFTS
   ======================================== */

/* All images should have dimensions */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Product images with aspect ratio */
.product-image img,
.gallery-main img,
.featured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Gallery and product image containers */
.product-image,
.gallery-main,
.featured-image {
    position: relative;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    background: #f8f9fa;
}

/* ========================================
   FIX FONT LOADING SHIFTS (FOUT/FOIT)
   ======================================== */

/* Ensure fonts load smoothly */
body {
    font-display: swap;
}

/* Prevent layout shift during font load */
.product-title,
.section-title,
h1, h2, h3 {
    font-display: optional;
}

/* ========================================
   FIX SCROLLING ISSUES
   ======================================== */

@media (max-width: 991px) {
    /* Smooth scrolling */
    html {
        scroll-behavior: smooth;
        scroll-padding-top: 80px;
    }
    
    /* Prevent momentum scrolling issues */
    body {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Fix horizontal scroll */
    .hero-grid,
    .specs-cards-grid,
    .gallery-thumbnails {
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
}

/* ========================================
   FIX Z-INDEX STACKING ISSUES
   ======================================== */

@media (max-width: 991px) {
    /* Clear z-index hierarchy */
    .site-header { z-index: 1000; }
    .mobile-menu { z-index: 999; }
    .gallery-lightbox { z-index: 10000; }
    .modal { z-index: 9999; }
    .floating-cta { z-index: 998; }
    .scroll-to-top { z-index: 997; }
    
    /* Ensure proper stacking */
    .review-content,
    .product-gallery,
    .technical-specs-cards {
        position: relative;
        z-index: 1;
    }
}

/* ========================================
   FIX TOUCH/TAP TARGETS
   ======================================== */

@media (max-width: 991px) {
    /* Minimum touch target size: 44x44px */
    button,
    a,
    .cta-btn,
    .gallery-nav,
    .gallery-zoom-btn,
    .gallery-thumb {
        min-height: 44px;
        min-width: 44px;
        touch-action: manipulation;
    }
    
    /* Prevent double-tap zoom */
    button,
    .cta-btn,
    .gallery-add-button {
        touch-action: manipulation;
        user-select: none;
    }
}

/* ========================================
   FIX GRID/FLEX LAYOUT SHIFTS
   ======================================== */

@media (max-width: 991px) {
    /* Stable grid layouts */
    .specs-cards-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 12px;
    }
    
    /* Prevent flex wrap shifts */
    .cta-buttons {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    /* Stable container widths */
    .review-container {
        width: 100%;
        max-width: 100%;
        padding-left: 16px;
        padding-right: 16px;
        margin-left: auto;
        margin-right: auto;
        box-sizing: border-box;
    }
}

/* ========================================
   FIX VIEWPORT UNITS ISSUES
   ======================================== */

@media (max-width: 991px) {
    /* Avoid 100vw causing horizontal scroll */
    .full-width-section {
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
    
    /* Use calc() for safer viewport widths */
    .hero-section,
    .review-hero {
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }
}

/* ========================================
   FIX CONTENT JUMPING (CLS)
   ======================================== */

@media (max-width: 991px) {
    /* Reserve space for images */
    .product-image,
    .gallery-main,
    .spec-card {
        min-height: 200px;
    }
    
    /* Prevent content reflow */
    .price-box,
    .product-meta,
    .rating-display {
        min-height: 32px;
        display: flex;
        align-items: center;
    }
    
    /* Stable button heights */
    .cta-btn {
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ========================================
   FIX INPUT/FORM ZOOM (iOS)
   ======================================== */

@media (max-width: 991px) {
    /* Prevent auto-zoom on input focus */
    input,
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* ========================================
   FIX GALLERY SPECIFIC ISSUES
   ======================================== */

@media (max-width: 991px) {
    /* Stable gallery layout */
    .product-gallery {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }
    
    .gallery-main {
        position: relative;
        width: 100%;
        aspect-ratio: 1 / 1;
        border-radius: 12px;
    }
    
    /* Fix thumbnail scrolling */
    .gallery-thumbnails {
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        gap: 8px;
        padding: 8px 0;
    }
    
    .gallery-thumb {
        scroll-snap-align: start;
        flex-shrink: 0;
        width: 64px;
        height: 64px;
    }
    
    /* Prevent lightbox body scroll */
    body.lightbox-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }
}

/* ========================================
   FIX CARDS LAYOUT SHIFTS
   ======================================== */

@media (max-width: 991px) {
    .spec-card {
        min-height: 140px;
        padding: 16px;
    }
    
    .spec-icon {
        width: 48px;
        height: 48px;
        flex-shrink: 0;
    }
    
    .spec-value {
        word-break: break-word;
        overflow-wrap: break-word;
    }
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

@media (max-width: 991px) {
    /* GPU acceleration for smooth rendering */
    .product-gallery,
    .specs-cards-grid,
    .gallery-lightbox,
    .spec-card,
    .cta-btn {
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        will-change: transform;
    }
    
    /* Reduce paint areas */
    .gallery-thumb,
    .spec-card {
        contain: layout style paint;
    }
    
    /* Optimize animations */
    @media (prefers-reduced-motion: reduce) {
        * {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }
}

/* ========================================
   FIX SAFE AREAS (iPhone X+)
   ======================================== */

@media (max-width: 991px) {
    /* Support for iPhone notch/home indicator */
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    .site-header {
        padding-top: env(safe-area-inset-top);
    }
    
    .site-footer {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ========================================
   DEBUG MODE (Remove in production)
   ======================================== */

/* Uncomment to visualize layout shifts
@media (max-width: 991px) {
    * {
        outline: 1px solid rgba(255, 0, 0, 0.1);
    }
}
*/

/* ========================================
   SPECIFIC FIXES FOR PRODUCT REVIEW PAGE
   ======================================== */

@media (max-width: 991px) {
    /* Fix Breadcrumb */
    .breadcrumb,
    .breadcrumb-wrapper {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .breadcrumb::-webkit-scrollbar {
        display: none;
    }
    
    /* Fix Trust Indicators (11 คน กำลังดูตอนนี้) */
    .trust-indicators {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px;
        overflow: hidden;
    }
    
    .trust-item {
        flex-shrink: 0;
        animation: none !important;
        transform: none !important;
    }
    
    .trust-item.live {
        animation: none !important;
    }
    
    /* ปิด animation ของ dot กระพริบ */
    .live-dot {
        animation: none !important;
        opacity: 1;
    }
    
    /* Fix Hero Section */
    .review-hero {
        padding: 20px 0;
        overflow: hidden;
    }
    
    .hero-grid {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }
    
    /* Fix Product Image/Gallery Container */
    .product-gallery {
        width: 100%;
        margin: 0 auto;
        overflow: visible;
        position: relative;
    }
    
    /* Main Gallery - Simple & Stable */
    .gallery-main {
        position: relative;
        width: 100%;
        aspect-ratio: 1 / 1;
        background: #f8f9fa;
        border-radius: 12px;
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .gallery-main img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
        background: #f8f9fa;
    }
    
    /* Fix Gallery Thumbnails Scrolling */
    .gallery-thumbnails {
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        gap: 8px;
        padding: 12px 0;
        margin-top: 12px;
        scrollbar-width: thin;
        scrollbar-color: #cbd5e0 transparent;
    }
    
    .gallery-thumbnails::-webkit-scrollbar {
        height: 4px;
    }
    
    .gallery-thumbnails::-webkit-scrollbar-track {
        background: transparent;
    }
    
    .gallery-thumbnails::-webkit-scrollbar-thumb {
        background: #cbd5e0;
        border-radius: 2px;
    }
    
    .gallery-thumb {
        scroll-snap-align: start;
        flex-shrink: 0;
        width: 64px;
        height: 64px;
        border-radius: 8px;
        border: 2px solid transparent;
        transition: border-color 0.2s ease;
    }
    
    .gallery-thumb:hover {
        transform: none !important;
        box-shadow: none !important;
    }
    
    .gallery-thumb.active {
        border-color: #27AE60;
    }
    
    /* Fix Navigation Arrows */
    .gallery-nav {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        width: 40px;
        height: 40px;
        background: rgba(255, 255, 255, 0.95);
        border: 2px solid rgba(0, 0, 0, 0.1);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        touch-action: manipulation;
        z-index: 10;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }
    
    .gallery-prev {
        left: 8px;
    }
    
    .gallery-next {
        right: 8px;
    }
    
    .gallery-nav svg {
        width: 24px;
        height: 24px;
        color: #2c3e50;
    }
    
    /* Fix Zoom Button */
    .gallery-zoom-btn {
        position: absolute;
        width: 40px;
        height: 40px;
        top: 12px;
        right: 12px;
        background: rgba(255, 255, 255, 0.95);
        border: 2px solid rgba(0, 0, 0, 0.1);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        touch-action: manipulation;
        z-index: 10;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }
    
    .gallery-zoom-btn svg {
        width: 20px;
        height: 20px;
        color: #2c3e50;
    }
    
    /* Fix Counter */
    .gallery-counter {
        bottom: 12px;
        right: 12px;
        padding: 6px 12px;
        font-size: 12px;
    }
    
    /* Fix Product Summary */
    .product-summary {
        padding: 16px;
    }
    
    .product-title {
        font-size: 22px;
        line-height: 1.3;
        margin-bottom: 12px;
        word-break: break-word;
    }
    
    /* Fix Rating Display */
    .rating-display {
        display: flex;
        align-items: center;
        gap: 8px;
        min-height: 24px;
    }
    
    /* Fix Price Box */
    .price-box {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 16px;
        min-height: auto;
    }
    
    /* Fix CTA Buttons */
    .cta-buttons {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 0 16px;
    }
    
    .cta-btn {
        min-height: 48px;
        padding: 12px 20px;
        font-size: 15px;
        touch-action: manipulation;
        user-select: none;
    }
    
    .cta-btn:hover {
        transform: none !important;
    }
    
    /* Fix Spec Cards */
    .specs-cards-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 0 16px;
    }
    
    .spec-card {
        min-height: 120px;
        padding: 16px;
    }
    
    .spec-card:hover {
        transform: none !important;
    }
    
    .spec-icon {
        width: 48px;
        height: 48px;
        margin-bottom: 12px;
    }
    
    .spec-icon:hover {
        transform: none !important;
    }
    
    .spec-value {
        font-size: 14px;
        line-height: 1.4;
        word-break: break-word;
    }
    
    /* Fix Section Titles */
    .section-title {
        font-size: 20px;
        padding: 0 16px;
        margin-bottom: 20px;
    }
    
    /* Fix Review Container */
    .review-container {
        width: 100%;
        max-width: 100%;
        padding-left: 16px;
        padding-right: 16px;
        margin-left: auto;
        margin-right: auto;
        box-sizing: border-box;
    }
    
    /* Fix Hamburger Menu */
    .mobile-menu-toggle {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        touch-action: manipulation;
    }
    
    /* Prevent Menu Shifts */
    .site-header {
        position: sticky;
        top: 0;
        width: 100%;
        z-index: 1000;
        background: white;
        transform: translateZ(0);
        backface-visibility: hidden;
    }
}

/* ========================================
   EXTRA SMALL DEVICES (<400px)
   ======================================== */

@media (max-width: 400px) {
    /* Even smaller adjustments */
    .gallery-thumb {
        width: 56px;
        height: 56px;
    }
    
    .spec-card {
        min-height: 100px;
        padding: 12px;
    }
    
    .spec-icon {
        width: 40px;
        height: 40px;
    }
    
    .product-title {
        font-size: 20px;
    }
}

/* ========================================
   LANDSCAPE MODE
   ======================================== */

@media (max-width: 991px) and (orientation: landscape) {
    /* Adjust for landscape */
    .gallery-main {
        padding-top: 75%; /* 4:3 aspect ratio in landscape */
    }
    
    .specs-cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
