/* 
 * Mobile Responsive Styles
 * Comprehensive mobile-friendly CSS for all pages
 * Set-N-Me-Free Website
 */

/* =============================================
   BASE MOBILE STYLES
   ============================================= */

/* Prevent body scroll when mobile menu is open */
body.mobile-menu-open {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
}

/* Ensure proper viewport handling */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

* {
    box-sizing: border-box;
}

body {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Make images responsive by default */
img {
    max-width: 100%;
    height: auto;
}

/* Prevent horizontal scroll */
.container,
.page-container,
.content-wrapper,
main,
section {
    max-width: 100%;
    overflow-x: hidden;
}

/* =============================================
   DROPDOWN MENU Z-INDEX FIX (Desktop)
   ============================================= */

/* Ensure header and navigation are above page content */
header,
.site-header {
    position: relative;
    z-index: 1000;
}

.header-wrapper {
    position: relative;
    z-index: 1000;
}

.main-nav,
.main-navigation {
    position: relative;
    z-index: 1000;
}

.nav-list {
    position: relative;
    z-index: 1000;
}

/* Parent nav items need positioning context */
.nav-item {
    position: relative;
}

.nav-item.has-dropdown {
    position: relative;
}

/* Dropdown menu must appear above page content */
.dropdown-menu {
    position: absolute !important;
    z-index: 9999 !important;
    background: #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border-radius: 8px;
    min-width: 220px;
    padding: 10px 0;
    margin-top: 0;
    border: 1px solid #e9ecef;
}

/* Nested dropdowns */
.dropdown-menu .dropdown-menu {
    top: 0;
    left: 100%;
    margin-left: 5px;
    margin-top: 0;
}

/* Ensure main content doesn't overlap header */
main,
.main-content,
.page-content,
.hero,
.hero-section {
    position: relative;
    z-index: 1;
}

/* =============================================
   DESKTOP: Hide mobile toggle
   ============================================= */
.mobile-menu-toggle {
    display: none;
}

/* Base hamburger bar styles - always defined */
.mobile-menu-toggle .bar,
.mobile-menu-toggle span.bar {
    display: block;
    width: 24px;
    height: 3px;
    background-color: #333;
    margin: 4px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

/* =============================================
   MOBILE NAVIGATION (max-width: 992px)
   ============================================= */
@media (max-width: 992px) {
    /* Header adjustments */
    header,
    .site-header {
        padding: 0 !important;
        margin-bottom: 0 !important;
        position: static !important;
    }
    
    .header-wrapper {
        flex-wrap: wrap;
        padding: 10px 15px;
        gap: 10px;
        position: relative;
        margin-bottom: 0 !important;
    }
    
    .container {
        padding: 0 10px;
    }
    
    /* Remove any spacing after header/nav */
    header + *,
    .site-header + *,
    nav + *,
    .main-nav + * {
        margin-top: 0 !important;
        padding-top: 0 !important;
    }
    
    /* Logo smaller on mobile */
    .site-logo,
    .logo {
        max-width: 150px;
        margin-right: 0;
        order: 1;
    }
    
    .site-logo img,
    .logo-img,
    .logo img {
        max-height: 45px;
        width: auto;
    }
    
    /* Mobile menu toggle button - HAMBURGER */
    .mobile-menu-toggle {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 44px;
        height: 44px;
        background: #f8f9fa;
        border: 1px solid #ddd;
        border-radius: 8px;
        cursor: pointer;
        padding: 8px;
        z-index: 1001;
        order: 3;
        margin-left: auto;
    }
    
    .mobile-menu-toggle .bar,
    .mobile-menu-toggle span {
        display: block;
        width: 22px;
        height: 2px;
        background-color: #333;
        margin: 3px 0;
        transition: all 0.3s ease;
        border-radius: 2px;
    }
    
    /* Hamburger to X animation when active */
    .mobile-menu-toggle[aria-expanded="true"] .bar:nth-child(1),
    .mobile-menu-toggle.active .bar:nth-child(1),
    .mobile-menu-toggle[aria-expanded="true"] span:nth-child(1),
    .mobile-menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .mobile-menu-toggle[aria-expanded="true"] .bar:nth-child(2),
    .mobile-menu-toggle.active .bar:nth-child(2),
    .mobile-menu-toggle[aria-expanded="true"] span:nth-child(2),
    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-menu-toggle[aria-expanded="true"] .bar:nth-child(3),
    .mobile-menu-toggle.active .bar:nth-child(3),
    .mobile-menu-toggle[aria-expanded="true"] span:nth-child(3),
    .mobile-menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(6px, -6px);
    }
    
    /* Header right side - cart/login buttons */
    .header-right {
        order: 2;
        display: flex;
        align-items: center;
        gap: 5px;
    }
    
    .action-buttons {
        gap: 5px;
    }
    
    .action-button {
        padding: 8px 10px;
        font-size: 14px;
    }
    
    .action-button span {
        display: none;
    }
    
    .action-button svg {
        margin: 0;
    }
    
    /* Hide search on header - will be in menu */
    .search-container,
    .search-form {
        display: none;
    }
    
    /* Main navigation - Full screen overlay on mobile */
    .main-nav,
    .main-navigation,
    nav.main-nav {
        display: none !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 200px;
        max-height: 0 !important;
        overflow: hidden !important;
        opacity: 0 !important;
        visibility: hidden !important;
        background-color: #fff;
        z-index: 1000;
        padding: 0 !important;
        margin: 0 !important;
        order: 4;
    }
    
    .main-nav.active,
    .main-navigation.active,
    nav.main-nav.active {
        display: flex !important;
        flex-direction: column;
        height: 100vh !important;
        max-height: 100vh !important;
        padding-top: 70px !important;
        overflow-y: auto !important;
        opacity: 1 !important;
        visibility: visible !important;
        -webkit-overflow-scrolling: touch;
        animation: mobileMenuSlide 0.3s ease forwards;
    }
    
    @keyframes mobileMenuSlide {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    /* Navigation list */
    .nav-list {
        flex-direction: column;
        width: 100%;
        padding: 15px 20px;
        margin: 0;
        list-style: none;
    }
    
    .nav-item {
        width: 100%;
        margin: 0;
        border-bottom: 1px solid #e9ecef;
    }
    
    .nav-item:last-child {
        border-bottom: none;
    }
    
    .nav-link {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 15px 10px;
        font-size: 16px;
        color: #333;
        text-decoration: none;
        min-height: 50px;
    }
    
    .nav-link:hover,
    .nav-link:focus {
        background-color: #f8f9fa;
        color: #2d7a4f;
    }
    
    /* Dropdown arrow */
    .dropdown-arrow {
        transition: transform 0.3s ease;
        margin-left: 10px;
    }
    
    .has-dropdown.active > .nav-link .dropdown-arrow {
        transform: rotate(180deg);
    }
    
    /* Dropdown menus on mobile */
    .dropdown-menu {
        position: static !important;
        display: none !important;
        width: 100%;
        box-shadow: none !important;
        background: #f8f9fa;
        padding: 0 0 0 15px;
        border-radius: 0;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        border-left: 3px solid #2d7a4f;
        margin: 0;
    }
    
    .has-dropdown.active > .dropdown-menu {
        display: block !important;
    }
    
    .dropdown-menu .nav-item {
        border-bottom: 1px solid #e9ecef;
    }
    
    .dropdown-menu .nav-link {
        padding: 12px 10px;
        font-size: 15px;
    }
    
    /* Nested dropdown (3rd level) */
    .dropdown-menu .dropdown-menu {
        padding-left: 15px;
        border-left-color: #6c757d;
        background: #f1f3f5;
    }
    
    .dropdown-menu .dropdown-menu .nav-link {
        font-size: 14px;
        padding: 10px;
    }
    
    /* Close button for mobile menu */
    .main-nav.active::before {
        content: '✕ Close Menu';
        display: block;
        position: fixed;
        top: 15px;
        right: 15px;
        background: #dc3545;
        color: white;
        padding: 10px 15px;
        border-radius: 5px;
        font-size: 14px;
        font-weight: bold;
        cursor: pointer;
        z-index: 1002;
    }
}

/* =============================================
   TABLET STYLES (768px - 992px)
   ============================================= */
@media (max-width: 992px) and (min-width: 769px) {
    .container {
        padding: 0 20px;
    }
    
    /* 2-column grid on tablet */
    .products-grid,
    .category-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px;
    }
    
    /* Checkout layout */
    .checkout-container {
        flex-direction: column;
    }
    
    .checkout-form-container,
    .checkout-sidebar {
        flex: 1 1 100%;
        max-width: 100%;
    }
}

/* =============================================
   MOBILE PHONE STYLES (max-width: 768px)
   ============================================= */
@media (max-width: 768px) {
    /* Container padding */
    .container {
        padding: 0 15px;
    }
    
    /* Typography adjustments */
    h1 {
        font-size: 1.75rem;
        line-height: 1.2;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    p {
        font-size: 0.95rem;
        line-height: 1.6;
    }
    
    /* Hero section */
    .hero,
    .hero-banner,
    .hero-section {
        min-height: auto !important;
        height: auto !important;
        padding: 30px 15px;
        margin-top: 0 !important;
        padding-top: 30px !important;
    }
    
    /* Override fullscreen hero on mobile */
    .hero-fullscreen,
    .hero-video {
        min-height: auto !important;
        height: auto !important;
        padding: 30px 15px !important;
    }
    
    /* Remove any top padding/margin on main on mobile */
    main {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }
    
    /* Ensure hero content starts right away */
    .hero-content {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }
    
    .hero-title {
        font-size: 1.75rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .hero-buttons .btn {
        width: 100%;
        text-align: center;
    }
    
    /* Feature bars */
    .features-bar,
    .feature-strip {
        flex-direction: column;
        gap: 15px;
        padding: 20px 15px;
    }
    
    .feature-item {
        width: 100%;
        text-align: center;
        padding: 15px;
    }
    
    /* Product grids - 2 columns on mobile */
    .products-grid,
    .product-grid,
    .category-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    
    /* Product cards on mobile */
    .product-card {
        padding: 10px;
    }
    
    .product-card .product-title {
        font-size: 0.85rem;
        line-height: 1.3;
    }
    
    .product-card .product-price {
        font-size: 0.9rem;
    }
    
    .product-card .btn-add-cart {
        padding: 8px 12px;
        font-size: 0.75rem;
    }
    
    /* Section headings */
    .section-title,
    .section-heading {
        font-size: 1.5rem;
        margin-bottom: 15px;
    }
    
    .section-subtitle {
        font-size: 0.9rem;
    }
    
    /* Buttons */
    .btn {
        padding: 12px 20px;
        font-size: 0.9rem;
        width: 100%;
        text-align: center;
    }
    
    .btn-sm {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
    
    /* Forms */
    .form-group {
        margin-bottom: 15px;
    }
    
    .form-control,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 12px 15px;
        width: 100%;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .form-col {
        width: 100%;
        min-width: 100%;
    }
    
    /* Tables - make scrollable */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 500px;
    }
    
    /* Footer */
    footer {
        padding: 30px 15px;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 30px;
    }
    
    .footer-section {
        width: 100%;
        text-align: center;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 10px;
    }
    
    .social-icons {
        justify-content: center;
    }
}

/* =============================================
   SMALL MOBILE STYLES (max-width: 480px)
   ============================================= */
@media (max-width: 480px) {
    /* Even smaller typography */
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
    
    /* Single column for very small screens if needed */
    .products-grid.single-column-xs {
        grid-template-columns: 1fr !important;
    }
    
    /* Cart adjustments */
    .cart-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .qty-controls {
        justify-content: center;
    }
    
    /* Checkout on small screens */
    .checkout-form {
        padding: 15px;
    }
}

/* =============================================
   CART PAGE MOBILE STYLES
   ============================================= */
@media (max-width: 768px) {
    .compact-cart-page {
        padding: 10px;
    }
    
    .compact-cart-page .page-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .compact-cart-page .header-actions {
        flex-direction: row;
        justify-content: center;
        gap: 10px;
    }
    
    /* Cart layout */
    .cart-layout {
        flex-direction: column !important;
        display: flex !important;
    }
    
    .cart-items-box {
        width: 100% !important;
        order: 1;
    }
    
    .order-summary {
        width: 100% !important;
        order: 2;
        position: static !important;
        margin-top: 20px;
    }
    
    /* Cart table on mobile */
    .cart-tbl {
        display: block;
        width: 100%;
    }
    
    .cart-tbl thead {
        display: none;
    }
    
    .cart-tbl tbody {
        display: block;
    }
    
    .cart-row {
        display: flex;
        flex-wrap: wrap;
        padding: 15px;
        margin-bottom: 10px;
        background: white;
        border-radius: 8px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
        position: relative;
    }
    
    .cart-row td {
        display: block;
        border: none;
        padding: 5px 0;
    }
    
    /* Product cell takes full width */
    .cart-row td:first-child {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .product-cell {
        flex-direction: row;
        align-items: center;
    }
    
    .product-thumb {
        width: 60px;
        height: 60px;
        flex-shrink: 0;
    }
    
    .product-info {
        flex: 1;
        padding-left: 10px;
    }
    
    .product-info h4 {
        font-size: 0.9rem;
        margin-bottom: 5px;
    }
    
    /* Quantity and price inline */
    .cart-row .qty-controls {
        display: flex;
        align-items: center;
    }
    
    .cart-row .price-col,
    .cart-row .total-col {
        font-size: 0.9rem;
    }
    
    /* Remove button */
    .cart-row .remove-col {
        position: absolute;
        top: 10px;
        right: 10px;
    }
    
    .remove-btn {
        width: 30px;
        height: 30px;
        font-size: 18px;
    }
    
    /* Order summary */
    .order-summary {
        padding: 15px;
    }
    
    .summary-row {
        padding: 10px 0;
    }
    
    .checkout-btn {
        padding: 15px;
        font-size: 1rem;
    }
}

/* =============================================
   PRODUCT DETAIL PAGE MOBILE
   ============================================= */
@media (max-width: 768px) {
    .product-detail-layout {
        flex-direction: column;
    }
    
    .product-gallery {
        width: 100%;
        margin-bottom: 20px;
    }
    
    .product-info-section {
        width: 100%;
        padding: 0;
    }
    
    .product-title {
        font-size: 1.5rem;
    }
    
    .product-price {
        font-size: 1.5rem;
    }
    
    .product-description {
        font-size: 0.95rem;
    }
    
    /* Product actions */
    .product-actions,
    .buttons-features-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .product-actions .btn,
    .action-btn {
        width: 100%;
    }
    
    /* Quantity selector */
    .quantity-selector {
        justify-content: center;
    }
    
    /* Features box */
    .product-features,
    .features-box {
        width: 100%;
        margin-top: 15px;
    }
    
    /* Tabs */
    .product-tabs .tab-buttons {
        flex-wrap: wrap;
    }
    
    .product-tabs .tab-btn {
        flex: 1 1 50%;
        padding: 10px;
        font-size: 0.85rem;
    }
    
    .tab-content {
        padding: 15px;
    }
}

/* =============================================
   CHECKOUT PAGE MOBILE
   ============================================= */
@media (max-width: 768px) {
    .checkout-page {
        padding: 15px 0;
    }
    
    .checkout-container {
        flex-direction: column;
    }
    
    .checkout-form-container,
    .checkout-sidebar {
        width: 100%;
        min-width: 100%;
    }
    
    .checkout-form {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .form-section h3 {
        font-size: 1.1rem;
    }
    
    /* Shipping methods */
    .shipping-method {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .shipping-method-radio {
        margin-bottom: 10px;
    }
    
    /* Payment section */
    .payment-methods {
        flex-direction: column;
    }
    
    .payment-method-btn {
        width: 100%;
    }
    
    /* Order summary sidebar */
    .checkout-sidebar {
        position: static;
    }
    
    .order-summary-checkout {
        padding: 15px;
    }
}

/* =============================================
   ACCOUNT PAGES MOBILE
   ============================================= */
@media (max-width: 768px) {
    .account-layout {
        flex-direction: column;
    }
    
    .account-sidebar {
        width: 100%;
        margin-bottom: 20px;
    }
    
    .account-sidebar nav {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .account-sidebar a {
        flex: 1 1 calc(50% - 5px);
        text-align: center;
        padding: 10px;
        font-size: 0.85rem;
    }
    
    .account-content {
        width: 100%;
        padding: 15px;
    }
    
    /* Order history table */
    .orders-table {
        display: block;
    }
    
    .orders-table thead {
        display: none;
    }
    
    .orders-table tr {
        display: block;
        margin-bottom: 15px;
        padding: 15px;
        background: #f9f9f9;
        border-radius: 8px;
    }
    
    .orders-table td {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
        border-bottom: 1px solid #eee;
    }
    
    .orders-table td:before {
        content: attr(data-label);
        font-weight: 600;
    }
}

/* =============================================
   LOGIN/REGISTER PAGES MOBILE
   ============================================= */
@media (max-width: 768px) {
    .auth-container {
        padding: 20px;
        margin: 20px 15px;
    }
    
    .auth-form {
        padding: 0;
    }
    
    .auth-title {
        font-size: 1.5rem;
    }
    
    .social-login-buttons {
        flex-direction: column;
    }
    
    .social-login-btn {
        width: 100%;
    }
}

/* =============================================
   CONTACT PAGE MOBILE
   ============================================= */
@media (max-width: 768px) {
    .contact-layout {
        flex-direction: column;
    }
    
    .contact-form-section,
    .contact-info-section {
        width: 100%;
    }
    
    .contact-info-section {
        order: -1;
        margin-bottom: 30px;
    }
    
    .contact-cards {
        flex-direction: column;
    }
    
    .contact-card {
        width: 100%;
    }
    
    .map-container {
        height: 250px;
    }
}

/* =============================================
   BLOG/EDUCATION PAGES MOBILE
   ============================================= */
@media (max-width: 768px) {
    .blog-layout {
        flex-direction: column;
    }
    
    .blog-sidebar {
        width: 100%;
        order: 2;
        margin-top: 30px;
    }
    
    .blog-content {
        width: 100%;
    }
    
    .blog-post-card {
        flex-direction: column;
    }
    
    .blog-post-image {
        width: 100%;
        height: 200px;
    }
}

/* =============================================
   PRODUCTS PAGE MOBILE (products.php specific)
   ============================================= */
@media (max-width: 992px) {
    .page-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        position: static;
        margin-bottom: 20px;
    }
    
    .main-content {
        width: 100%;
        max-width: 100%;
    }
    
    .controls-bar {
        flex-direction: column;
        gap: 10px;
    }
    
    .controls-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .sort-select {
        flex: 1;
    }
}

/* =============================================
   MODERN CART STYLES MOBILE
   ============================================= */
@media (max-width: 768px) {
    .modern-cart-container {
        padding: 15px;
        border-radius: 0;
    }
    
    .cart-header-modern {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
        text-align: center;
    }
    
    .cart-title {
        font-size: 1.5rem;
        justify-content: center;
    }
    
    .cart-controls-section {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }
    
    .view-toggle {
        width: 100%;
        justify-content: center;
    }
    
    .cart-actions-top {
        width: 100%;
        flex-direction: column;
    }
    
    .continue-shopping-btn,
    .clear-cart-btn {
        width: 100%;
        justify-content: center;
    }
}

/* =============================================
   TOUCH-FRIENDLY IMPROVEMENTS
   ============================================= */
@media (max-width: 992px) {
    /* Larger tap targets */
    a, button, .btn, input[type="submit"], input[type="button"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Better spacing for touch */
    .nav-link,
    .menu-link {
        padding: 12px 15px;
    }
    
    /* Checkbox and radio touch targets */
    input[type="checkbox"],
    input[type="radio"] {
        width: 20px;
        height: 20px;
    }
    
    /* Better scroll behavior */
    .scrollable {
        -webkit-overflow-scrolling: touch;
    }
}

/* =============================================
   UTILITY CLASSES FOR MOBILE
   ============================================= */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
    
    .show-mobile {
        display: block !important;
    }
    
    .text-center-mobile {
        text-align: center !important;
    }
    
    .stack-mobile {
        flex-direction: column !important;
    }
    
    .full-width-mobile {
        width: 100% !important;
    }
    
    .no-padding-mobile {
        padding: 0 !important;
    }
    
    .small-padding-mobile {
        padding: 10px !important;
    }
}

@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }
    
    .show-desktop {
        display: block !important;
    }
}

/* =============================================
   PRINT STYLES
   ============================================= */
@media print {
    header,
    footer,
    .mobile-menu-toggle,
    .header-actions,
    .cart-actions,
    .checkout-actions,
    nav {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
    }
    
    .container {
        max-width: 100%;
        padding: 0;
    }
}
