/* Mobile-First Responsive Design for PSG HCodes */

/* Base mobile styles (up to 480px) */
@media (max-width: 480px) {
    /* Typography */
    h1 { font-size: 2rem !important; line-height: 1.2; }
    h2 { font-size: 1.5rem !important; line-height: 1.3; }
    h3 { font-size: 1.25rem !important; line-height: 1.4; }
    p { font-size: 0.95rem !important; line-height: 1.6; }
    
    /* Header & Navigation */
    .floating-header {
        padding: 0.5rem 0;
    }
    
    .floating-header nav {
        padding: 0 1rem;
    }
    
    .floating-header .flex.justify-between {
        height: 3.5rem;
    }
    
    /* Logo adjustments */
    .floating-header img {
        height: 1.25rem !important;
    }
    
    .floating-header span {
        font-size: 1.1rem !important;
    }
    
    /* Mobile menu toggle */
    .mobile-menu-toggle {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 2.5rem;
        height: 2.5rem;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0.5rem;
        border-radius: 0.5rem;
        transition: all 0.3s ease;
        z-index: 1001;
        position: relative;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        user-select: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
    }
    
    .mobile-menu-toggle:hover {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .mobile-menu-toggle:active {
        background: rgba(255, 255, 255, 0.2);
        transform: scale(0.95);
    }
    
    .mobile-menu-toggle.active {
        background: rgba(16, 124, 16, 0.2);
    }
    
    .mobile-menu-toggle span {
        width: 1.5rem;
        height: 2px;
        background: white;
        margin: 2px 0;
        transition: all 0.3s ease;
        border-radius: 1px;
        pointer-events: none;
    }
    
    .mobile-menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }
    
    /* Mobile navigation menu */
    .nav-menu {
        display: none;
        position: fixed;
        top: 4rem;
        left: 0;
        right: 0;
        background: linear-gradient(135deg, #0F0F23 0%, #3A3A3A 100%);
        backdrop-filter: blur(20px);
        border-bottom: 2px solid rgba(16, 124, 16, 0.3);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
        z-index: 1000;
        padding: 1rem;
        transform: translateY(-100%);
        transition: all 0.3s ease-out;
        min-height: 200px;
        max-height: 80vh;
        overflow-y: auto;
        opacity: 0;
        visibility: hidden;
    }
    
    .nav-menu.active {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
    
    .nav-menu a {
        padding: 1rem;
        border-radius: 0.5rem;
        font-weight: 500;
        transition: all 0.3s ease;
        border: 1px solid transparent;
    }
    
    .nav-menu a:hover {
        background: rgba(16, 124, 16, 0.1);
        border-color: rgba(16, 124, 16, 0.3);
        transform: translateX(5px);
    }
    
    /* User actions in header */
    .floating-header .flex.items-center.space-x-4 {
        gap: 0.5rem;
    }
    
    .floating-header .flex.items-center.space-x-2 {
        gap: 0.25rem;
    }
    
    .floating-header a {
        font-size: 0.8rem;
        padding: 0.5rem;
    }
    
    /* Hide login/register text links on mobile, keep user icon */
    .floating-header .flex.items-center.space-x-2 a[href="login/"],
    .floating-header .flex.items-center.space-x-2 a[href="register/"],
    .floating-header .flex.items-center.space-x-2 a[href="../login/"],
    .floating-header .flex.items-center.space-x-2 a[href="../../login/"],
    .floating-header .flex.items-center.space-x-2 a[href="../register/"],
    .floating-header .flex.items-center.space-x-2 a[href="../../register/"],
    .floating-header .flex.items-center.space-x-2 span {
        display: none !important;
    }
    
    /* Ensure user icon stays visible and properly spaced */
    .floating-header .flex.items-center.space-x-2 a[href="login/"]:last-child,
    .floating-header .flex.items-center.space-x-2 a[href="../login/"]:last-child,
    .floating-header .flex.items-center.space-x-2 a[href="../../login/"]:last-child,
    .floating-header .flex.items-center.space-x-2 a[href="javascript:void(0)"]:last-child {
        display: flex !important;
        margin-left: 0 !important;
    }
    
    /* Style the user icon for mobile */
    .floating-header .flex.items-center.space-x-2 a[href="login/"]:last-child,
    .floating-header .flex.items-center.space-x-2 a[href="../login/"]:last-child,
    .floating-header .flex.items-center.space-x-2 a[href="../../login/"]:last-child,
    .floating-header .flex.items-center.space-x-2 a[href="javascript:void(0)"]:last-child {
        width: 2.5rem !important;
        height: 2.5rem !important;
        min-width: 2.5rem !important;
        min-height: 2.5rem !important;
    }
    
    /* Additional rules for different user icon structures */
    .floating-header .flex.items-center.space-x-4 a[href="javascript:void(0)"]:last-child,
    .floating-header .flex.items-center.space-x-4 a[href="../login/"]:last-child,
    .floating-header .flex.items-center.space-x-4 a[href="../../login/"]:last-child {
        width: 2.5rem !important;
        height: 2.5rem !important;
        min-width: 2.5rem !important;
        min-height: 2.5rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Hide text links in different structures */
    .floating-header .flex.items-center.space-x-4 a[href="../login/"]:not(:last-child),
    .floating-header .flex.items-center.space-x-4 a[href="../../login/"]:not(:last-child),
    .floating-header .flex.items-center.space-x-4 a[href="../register/"]:not(:last-child),
    .floating-header .flex.items-center.space-x-4 a[href="../../register/"]:not(:last-child) {
        display: none !important;
    }
    
    /* Hero section */
    .hero-section {
        padding: 2rem 1rem;
        min-height: 60vh;
    }
    
    .hero h1 {
        font-size: 2.5rem !important;
        line-height: 1.1;
        margin-bottom: 1rem;
    }
    
    .hero p {
        font-size: 1rem !important;
        line-height: 1.5;
        margin-bottom: 1.5rem;
    }
    
    /* Buttons */
    .btn {
        padding: 0.875rem 1.5rem;
        font-size: 0.95rem;
        min-height: 3rem;
        min-width: 8rem;
    }
    
    /* Product grid */
    .product-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
        padding: 1rem;
    }
    
    .product-card {
        padding: 1rem;
        min-height: auto;
    }
    
    /* Service cards */
    .service-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
        padding: 1rem;
    }
    
    .service-card {
        padding: 1.5rem;
        min-height: auto;
    }
    
    /* Cart sidebar */
    #cart-sidebar {
        width: 100% !important;
    }
    
    #cart-sidebar .flex.justify-between {
        padding: 1rem;
    }
    
    #cart-sidebar h3 {
        font-size: 1.5rem;
    }
    
    /* Forms */
    .contact-form,
    .login-form,
    .register-form {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-group input,
    .form-group textarea,
    .form-group select {
        padding: 0.875rem;
        font-size: 1rem;
        min-height: 3rem;
    }
    
    /* Footer */
    footer {
        padding: 2rem 1rem;
    }
    
    .footer-content {
        grid-template-columns: 1fr !important;
        gap: 2rem;
        text-align: center;
    }
    
    /* Blog cards */
    .blog-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
        padding: 1rem;
    }
    
    .blog-card {
        padding: 1rem;
    }
    
    /* Team section */
    .team-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
        padding: 1rem;
    }
    
    /* Testimonials */
    .testimonial-card {
        padding: 1.5rem;
        margin: 0 1rem;
    }
    
    /* Cookie consent */
    .cookie-consent-container {
        margin: 0.5rem;
        padding: 1rem;
        max-height: 80vh;
    }
    
    .cookie-consent-header h2 {
        font-size: 1.25rem;
    }
    
    .cookie-consent-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .cookie-btn {
        width: 100%;
        padding: 0.875rem;
    }
}

/* Small tablets (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    /* Typography */
    h1 { font-size: 2.75rem !important; }
    h2 { font-size: 1.75rem !important; }
    h3 { font-size: 1.4rem !important; }
    
    /* Header */
    .floating-header nav {
        padding: 0 1.5rem;
    }
    
    .floating-header .flex.justify-between {
        height: 4rem;
    }
    
    /* Hero section */
    .hero-section {
        padding: 3rem 1.5rem;
        min-height: 70vh;
    }
    
    .hero h1 {
        font-size: 3rem !important;
    }
    
    /* Product grid */
    .product-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.5rem;
        padding: 1.5rem;
    }
    
    /* Service grid */
    .service-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.5rem;
        padding: 1.5rem;
    }
    
    /* Blog grid */
    .blog-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.5rem;
        padding: 1.5rem;
    }
    
    /* Team grid */
    .team-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 2rem;
        padding: 1.5rem;
    }
    
    /* Footer */
    .footer-content {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 2rem;
    }
    
    /* Forms */
    .contact-form,
    .login-form,
    .register-form {
        padding: 2rem;
        margin: 1.5rem;
    }
}

/* Large tablets (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Typography */
    h1 { font-size: 3.5rem !important; }
    h2 { font-size: 2rem !important; }
    h3 { font-size: 1.5rem !important; }
    
    /* Header */
    .floating-header nav {
        padding: 0 2rem;
    }
    
    /* Hero section */
    .hero-section {
        padding: 4rem 2rem;
        min-height: 80vh;
    }
    
    .hero h1 {
        font-size: 3.5rem !important;
    }
    
    /* Product grid */
    .product-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 2rem;
        padding: 2rem;
    }
    
    /* Service grid */
    .service-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 2rem;
        padding: 2rem;
    }
    
    /* Blog grid */
    .blog-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 2rem;
        padding: 2rem;
    }
    
    /* Team grid */
    .team-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 2.5rem;
        padding: 2rem;
    }
    
    /* Footer */
    .footer-content {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 2.5rem;
    }
    
    /* Forms */
    .contact-form,
    .login-form,
    .register-form {
        padding: 2.5rem;
        margin: 2rem;
        max-width: 600px;
    }
}

/* Desktop (1025px and up) */
@media (min-width: 1025px) {
    /* Container max-width */
    .container {
        max-width: 1200px;
        margin: 0 auto;
    }
    
    /* Typography */
    h1 { font-size: 4rem !important; }
    h2 { font-size: 2.5rem !important; }
    h3 { font-size: 1.75rem !important; }
    
    /* Hero section */
    .hero-section {
        padding: 5rem 2rem;
        min-height: 90vh;
    }
    
    .hero h1 {
        font-size: 4rem !important;
    }
    
    /* Product grid */
    .product-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 2.5rem;
        padding: 2.5rem;
    }
    
    /* Service grid */
    .service-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 2.5rem;
        padding: 2.5rem;
    }
    
    /* Blog grid */
    .blog-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 2.5rem;
        padding: 2.5rem;
    }
    
    /* Team grid */
    .team-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 3rem;
        padding: 2.5rem;
    }
    
    /* Footer */
    .footer-content {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 3rem;
    }
    
    /* Forms */
    .contact-form,
    .login-form,
    .register-form {
        padding: 3rem;
        margin: 2.5rem auto;
        max-width: 700px;
    }
}

/* Large desktop (1440px and up) */
@media (min-width: 1440px) {
    .container {
        max-width: 1400px;
    }
    
    .hero h1 {
        font-size: 4.5rem !important;
    }
    
    .product-grid,
    .service-grid,
    .blog-grid {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 3rem;
        padding: 3rem;
    }
    
    .team-grid {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 3.5rem;
        padding: 3rem;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    .btn,
    .nav-menu a,
    .floating-header a,
    .mobile-menu-toggle {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Add touch feedback */
    .btn:active,
    .nav-menu a:active,
    .floating-header a:active {
        transform: scale(0.95);
    }
    
    /* Improve scrolling */
    .main-content {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Better touch interactions */
    .product-card,
    .service-card,
    .blog-card {
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(16, 124, 16, 0.1);
    }
    
    /* Prevent unwanted select box appearance on touch */
    body {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    
    /* Ensure form elements only respond when intended */
    select:not(:focus),
    input:not(:focus),
    textarea:not(:focus) {
        -webkit-tap-highlight-color: transparent;
    }
    
    .product-card:active,
    .service-card:active,
    .blog-card:active {
        transform: scale(0.98);
    }
    
    /* Improve form interactions */
    input:focus,
    textarea:focus,
    select:focus {
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Better button feedback */
    .btn:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
    
    /* Improve navigation touch */
    .nav-menu a:active {
        background: rgba(16, 124, 16, 0.2);
        transform: scale(0.95);
    }
    
    /* Better cart interactions */
    .cart-toggle:active {
        transform: scale(0.9);
    }
    
    /* Improve mobile menu toggle */
    .mobile-menu-toggle:active {
        transform: scale(0.9);
    }
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .hero-section {
        min-height: 50vh;
        padding: 1.5rem;
    }
    
    .hero h1 {
        font-size: 2rem !important;
    }
    
    .nav-menu {
        max-height: 60vh;
        overflow-y: auto;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .floating-header img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

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

/* High contrast mode */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
    
    .nav-menu a {
        border: 1px solid currentColor;
    }
    
    .product-card,
    .service-card,
    .blog-card {
        border: 2px solid currentColor;
    }
    
    .floating-header {
        border-bottom: 2px solid currentColor;
    }
}

/* Mobile-specific accessibility improvements */
@media (max-width: 768px) {
    /* Better focus indicators */
    .btn:focus,
    .nav-menu a:focus,
    .floating-header a:focus,
    input:focus,
    textarea:focus,
    select:focus {
        outline: 3px solid #107C10;
        outline-offset: 2px;
        border-radius: 4px;
    }
    
    /* Improve text contrast */
    .text-gray-400 {
        color: #9CA3AF !important;
    }
    
    .text-gray-500 {
        color: #6B7280 !important;
    }
    
    /* Better button contrast */
    .btn {
        font-weight: 600;
        letter-spacing: 0.025em;
    }
    
    /* Improve form labels */
    label {
        font-weight: 500;
        color: #E5E7EB;
    }
    
    /* Better mobile navigation */
    .nav-menu a {
        font-weight: 500;
        letter-spacing: 0.025em;
    }
    
    /* Improve mobile menu toggle */
    .mobile-menu-toggle {
        border: 1px solid transparent;
    }
    
    .mobile-menu-toggle:focus {
        border-color: #107C10;
        outline: 2px solid #107C10;
        outline-offset: 2px;
    }
    
    /* Better mobile images */
    img {
        max-width: 100%;
        height: auto;
        display: block;
    }
    
    /* Improve mobile loading states */
    .loading {
        opacity: 0.6;
        pointer-events: none;
    }
    
    /* Better mobile error states */
    .error {
        border-color: #EF4444;
        background-color: rgba(239, 68, 68, 0.1);
    }
    
    .error-message {
        color: #EF4444;
        font-size: 0.875rem;
        margin-top: 0.25rem;
    }
    
    /* Improve mobile success states */
    .success {
        border-color: #10B981;
        background-color: rgba(16, 185, 129, 0.1);
    }
    
    .success-message {
        color: #10B981;
        font-size: 0.875rem;
        margin-top: 0.25rem;
    }
}

/* Print styles */
@media print {
    .floating-header,
    .nav-menu,
    .mobile-menu-toggle,
    .btn,
    #cart-sidebar,
    .cookie-consent-container,
    .cookie-settings-btn {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
        color: black;
        background: white;
    }
    
    .hero-section {
        background: white !important;
        color: black !important;
        min-height: auto;
        padding: 1rem;
    }
    
    .product-card,
    .service-card,
    .blog-card {
        border: 1px solid #ccc;
        background: white !important;
        color: black !important;
        box-shadow: none;
    }
}

/* Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Utility classes for responsive design */
.responsive-text {
    font-size: clamp(0.875rem, 2.5vw, 1.125rem);
}

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

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

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

/* Hide elements on mobile */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
}

/* Show elements only on mobile */
@media (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }
}
