/**
 * Responsive CSS for Charlie Racconta
 * 
 * This file contains additional responsive styles to optimize the website for mobile devices.
 */

/* Base responsive adjustments */
html {
    scroll-behavior: smooth;
}

body {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

/* Mobile typography adjustments */
@media (max-width: 640px) {
    h1 {
        font-size: 1.75rem !important;
    }
    
    h2 {
        font-size: 1.5rem !important;
    }
    
    h3 {
        font-size: 1.25rem !important;
    }
    
    p {
        font-size: 0.95rem !important;
    }
    
    .text-xl {
        font-size: 1.25rem !important;
    }
    
    .text-lg {
        font-size: 1.125rem !important;
    }
}

/* Header and navigation adjustments */
@media (max-width: 768px) {
    .header-nav {
        display: none !important;
    }
    
    .mobile-menu-toggle {
        display: block !important;
    }
    
    .logo-text {
        font-size: 1.5rem !important;
    }
}

/* Hero section adjustments */
@media (max-width: 768px) {
    .hero-content {
        padding: 2rem 1rem !important;
    }
    
    .hero-title {
        font-size: 2rem !important;
        line-height: 1.2 !important;
    }
    
    .hero-subtitle {
        font-size: 1rem !important;
    }
    
    .hero-cta {
        flex-direction: column !important;
    }
    
    .hero-cta .btn {
        width: 100% !important;
        margin-right: 0 !important;
        margin-bottom: 0.75rem !important;
    }
}

/* Featured products section */
@media (max-width: 640px) {
    .product-card {
        margin-bottom: 1.5rem !important;
    }
    
    .product-card-image {
        height: 180px !important;
    }
    
    .product-card-title {
        font-size: 1rem !important;
    }
}

/* Blog section */
@media (max-width: 768px) {
    .blog-grid {
        grid-template-columns: 1fr !important;
    }
    
    .blog-card {
        margin-bottom: 1.5rem !important;
    }
}

/* Footer adjustments */
@media (max-width: 768px) {
    .footer-grid {
        grid-template-columns: 1fr !important;
    }
    
    .footer-column {
        margin-bottom: 1.5rem !important;
    }
    
    .footer-bottom {
        flex-direction: column !important;
        text-align: center !important;
    }
    
    .footer-bottom > div {
        margin-bottom: 1rem !important;
    }
}

/* Product page adjustments */
@media (max-width: 768px) {
    .product-layout {
        flex-direction: column !important;
    }
    
    .product-image-container {
        width: 100% !important;
        margin-bottom: 1.5rem !important;
    }
    
    .product-details {
        width: 100% !important;
    }
    
    .product-tabs {
        flex-direction: column !important;
    }
    
    .product-tab {
        width: 100% !important;
        margin-bottom: 0.5rem !important;
    }
}

/* Shop page adjustments */
@media (max-width: 768px) {
    .shop-layout {
        flex-direction: column !important;
    }
    
    .shop-sidebar {
        width: 100% !important;
        margin-bottom: 1.5rem !important;
    }
    
    .shop-products {
        width: 100% !important;
    }
    
    .shop-filters {
        flex-direction: column !important;
    }
    
    .shop-filter {
        width: 100% !important;
        margin-bottom: 0.75rem !important;
    }
}

/* Cart and checkout adjustments */
@media (max-width: 768px) {
    .cart-table th:nth-child(3),
    .cart-table td:nth-child(3) {
        display: none !important;
    }
    
    .checkout-layout {
        flex-direction: column !important;
    }
    
    .checkout-form {
        width: 100% !important;
        margin-bottom: 1.5rem !important;
    }
    
    .checkout-summary {
        width: 100% !important;
    }
}

/* Form adjustments */
@media (max-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr !important;
    }
    
    .form-control {
        margin-bottom: 1rem !important;
    }
    
    .form-actions {
        flex-direction: column !important;
    }
    
    .form-actions .btn {
        width: 100% !important;
        margin-bottom: 0.75rem !important;
    }
}

/* Modal adjustments */
@media (max-width: 640px) {
    .modal-content {
        width: 95% !important;
        padding: 1.5rem !important;
    }
    
    .modal-title {
        font-size: 1.25rem !important;
    }
}

/* Admin dashboard adjustments */
@media (max-width: 1024px) {
    .admin-sidebar {
        width: 64px !important;
    }
    
    .admin-sidebar-text {
        display: none !important;
    }
    
    .admin-content {
        margin-left: 64px !important;
    }
    
    .admin-card {
        margin-bottom: 1rem !important;
    }
}

/* Utility classes for responsive behavior */
.hide-on-mobile {
    display: none !important;
}

@media (min-width: 768px) {
    .hide-on-mobile {
        display: initial !important;
    }
    
    .hide-on-desktop {
        display: none !important;
    }
}

/* Touch-friendly adjustments - Migliorato per mobile */
@media (hover: none) {
    /* Rimozione highlight su touch devices */
    .btn, 
    .nav-link,
    .product-card,
    .blog-card,
    button,
    a {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Touch feedback migliorato */
    .btn:active,
    .nav-link:active,
    button:active {
        opacity: 0.7;
        transform: scale(0.98);
        transition: all 0.1s ease;
    }
    
    /* Dimensioni minime per touch targets (44px come raccomandato) */
    .btn,
    button,
    .nav-link,
    .add-to-cart-btn,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px !important;
        min-width: 44px !important;
        padding: 12px 20px !important;
        font-size: 16px !important;
    }
    
    /* Links touch-friendly */
    a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        padding: 8px;
        margin: -8px;
    }
    
    /* Product cards touch-friendly */
    .product-card {
        margin-bottom: 20px !important;
    }
    
    .add-to-cart-btn {
        border-radius: 8px;
        font-weight: 600;
        letter-spacing: 0.5px;
    }
}

/* Fix for input zoom on iOS - Migliorato */
@supports (-webkit-touch-callout: none) {
    /* Specifico per iOS */
    select,
    textarea,
    input[type="text"],
    input[type="password"],
    input[type="datetime"],
    input[type="datetime-local"],
    input[type="date"],
    input[type="month"],
    input[type="time"],
    input[type="week"],
    input[type="number"],
    input[type="email"],
    input[type="url"],
    input[type="search"],
    input[type="tel"],
    input[type="color"] {
        font-size: 16px !important;
        transform: translateZ(0); /* Force hardware acceleration */
        -webkit-appearance: none;
        border-radius: 0; /* Remove iOS default styling */
        background-clip: padding-box;
    }
    
    /* Fix per il layout iOS */
    .container {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    /* Fix per il bottom safe area */
    .footer,
    .checkout-summary {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }
}

/* Android Chrome specific fixes */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    select,
    textarea,
    input[type="text"],
    input[type="password"],
    input[type="datetime"],
    input[type="datetime-local"],
    input[type="date"],
    input[type="month"],
    input[type="time"],
    input[type="week"],
    input[type="number"],
    input[type="email"],
    input[type="url"],
    input[type="search"],
    input[type="tel"],
    input[type="color"] {
        font-size: 16px !important;
        -webkit-text-size-adjust: 100%;
    }
}

/* Improve scrolling on iOS - Migliorato */
* {
    -webkit-overflow-scrolling: touch;
}

/* Scrolling ottimizzato per liste e contenuti lunghi */
.scrollable-content {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
    will-change: scroll-position;
}

/* Fix per position:fixed su iOS - Migliorato */
.ios-fixed,
.fixed-header,
.fixed-footer,
.fixed-cart-summary {
    position: fixed;
    width: 100%;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Performance ottimizzazioni per mobile */
@media (max-width: 768px) {
    /* Hardware acceleration per elementi animati */
    .product-card,
    .btn,
    .hero-section,
    .card-hover {
        will-change: transform;
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
    }
    
    /* Riduzione animazioni complesse su mobile */
    .product-card img {
        transition: transform 0.2s ease !important;
    }
    
    /* Ottimizzazione font rendering */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
    }
    
    /* Container ottimizzato per mobile */
    .container {
        max-width: 100% !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
    
    /* Spacing ottimizzato per mobile */
    .section {
        padding: 40px 0 !important;
    }
    
    .py-16 {
        padding-top: 40px !important;
        padding-bottom: 40px !important;
    }
    
    .py-12 {
        padding-top: 32px !important;
        padding-bottom: 32px !important;
    }
    
    /* Grid migliorato per mobile */
    .grid {
        gap: 16px !important;
    }
    
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr !important;
    }
    
    /* Card spacing ottimizzato */
    .card {
        margin-bottom: 16px !important;
    }
}

/* Miglioramenti specifici per iPhone X e versioni successive */
@supports (padding: max(0px)) {
    .header,
    .footer,
    .checkout-summary {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
    
    .fixed-bottom {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}

/* Responsive images */
img {
    max-width: 100%;
    height: auto;
}

/* Responsive tables */
@media (max-width: 768px) {
    .responsive-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .dark-mode-support {
        background-color: #1a202c;
        color: #e2e8f0;
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        color: #000;
        background: #fff;
    }
    
    a {
        text-decoration: underline;
    }
}