/* ========================================
   3 SHOP Croatia - Responsive Styles
   Mobile & Tablet Optimizations
   ======================================== */

/* === Large Tablets & Small Desktops (max-width: 1200px) === */
@media (max-width: 1200px) {
    .container {
        padding: 0 var(--spacing-md);
    }
    
    .layers-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--spacing-lg);
    }
    
    .categories-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .listings-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* === Tablets (max-width: 992px) === */
@media (max-width: 992px) {
    /* Typography Adjustments */
    h1 { font-size: 2.5rem; }
    h2 { font-size: 2rem; }
    h3 { font-size: 1.5rem; }
    
    /* Navigation */
    .nav-links {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .nav-search {
        max-width: 400px;
    }
    
    /* Hero */
    .hero-title {
        font-size: 3rem;
    }
    
    .hero-subtitle {
        font-size: 1.25rem;
    }
    
    .hero-features {
        gap: var(--spacing-lg);
    }
    
    .quick-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-md);
    }
    
    /* Layers */
    .layers-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
    
    .layer-card {
        padding: var(--spacing-lg);
    }
    
    /* Categories */
    .categories-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--spacing-md);
    }
    
    /* Monero Section */
    .monero-content {
        grid-template-columns: 1fr;
        gap: var(--spacing-xl);
    }
    
    .monero-perks {
        grid-template-columns: 1fr;
    }
    
    .monero-visual {
        order: -1;
    }
    
    .monero-badge {
        width: 150px;
        height: 150px;
    }
    
    .monero-badge i {
        font-size: 4rem;
    }
    
    /* Listings */
    .listings-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-md);
    }
    
    /* Features */
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-lg);
    }
    
    /* Footer */
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-lg);
    }
    
    .footer-bottom {
        flex-direction: column;
        gap: var(--spacing-md);
        text-align: center;
    }
    
    .footer-badges {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* === Mobile Landscape & Large Phones (max-width: 768px) === */
@media (max-width: 768px) {
    /* Base Adjustments */
    html {
        font-size: 14px;
    }
    
    /* Container */
    .container {
        padding: 0 var(--spacing-sm);
    }
    
    /* Typography */
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.25rem; }
    
    /* Navigation */
    .nav-container {
        gap: var(--spacing-sm);
    }
    
    .logo {
        font-size: 1.25rem;
    }
    
    .logo i {
        font-size: 1.5rem;
    }
    
    .nav-search {
        display: none;
    }
    
    .nav-actions {
        gap: var(--spacing-xs);
    }
    
    .nav-actions .btn-primary,
    .nav-actions .btn-secondary {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 0.875rem;
    }
    
    .nav-actions .btn-primary i,
    .nav-actions .btn-secondary i {
        display: none;
    }
    
    /* Hero */
    .hero {
        padding: var(--spacing-xl) 0;
        min-height: auto;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .hero-features {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-md);
    }
    
    .hero-feature i {
        font-size: 2rem;
    }
    
    .hero-feature span {
        font-size: 0.75rem;
    }
    
    .hero-cta {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-large {
        width: 100%;
        justify-content: center;
    }
    
    .quick-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
    
    /* Sections */
    .three-layers,
    .featured-categories,
    .monero-section,
    .recent-listings,
    .features-overview,
    .cta-section {
        padding: var(--spacing-xl) 0;
    }
    
    .section-title {
        font-size: 2rem;
    }
    
    .section-subtitle {
        font-size: 1rem;
    }
    
    /* Layers */
    .layer-card {
        padding: var(--spacing-md);
    }
    
    .layer-icon {
        width: 60px;
        height: 60px;
    }
    
    .layer-icon i {
        font-size: 2rem;
    }
    
    .layer-title {
        font-size: 1.5rem;
    }
    
    /* Categories */
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .category-icon {
        width: 50px;
        height: 50px;
    }
    
    .category-icon i {
        font-size: 1.5rem;
    }
    
    .category-card h3 {
        font-size: 1rem;
    }
    
    /* Monero Section */
    .monero-perks {
        gap: var(--spacing-sm);
    }
    
    .perk {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .perk i {
        font-size: 1.5rem;
    }
    
    /* Listings */
    .listings-grid {
        grid-template-columns: 1fr;
    }
    
    .listing-filters {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .filter-btn {
        flex: 1;
        min-width: calc(50% - var(--spacing-xs));
    }
    
    /* Features */
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .feature-icon {
        width: 60px;
        height: 60px;
    }
    
    .feature-icon i {
        font-size: 2rem;
    }
    
    /* CTA */
    .cta-content h2 {
        font-size: 2rem;
    }
    
    .cta-content p {
        font-size: 1rem;
    }
    
    .cta-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    /* Footer */
    .footer {
        padding: var(--spacing-xl) 0 var(--spacing-md);
    }
    
    .footer-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
    
    .footer-column h4 {
        margin-bottom: var(--spacing-sm);
    }
    
    /* Modal */
    .modal {
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
    }
    
    /* Forms */
    .form-group input,
    .form-group textarea,
    .form-group select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* === Mobile Portrait (max-width: 576px) === */
@media (max-width: 576px) {
    /* Base */
    html {
        font-size: 13px;
    }
    
    /* Navigation */
    .logo-text .logo-accent {
        display: none;
    }
    
    .user-avatar {
        width: 35px;
        height: 35px;
    }
    
    /* Hero */
    .hero-features {
        grid-template-columns: 1fr;
    }
    
    .quick-stats {
        grid-template-columns: 1fr;
    }
    
    /* Layers */
    .layer-benefits {
        font-size: 0.875rem;
    }
    
    /* Categories */
    .categories-grid {
        grid-template-columns: 1fr;
    }
    
    /* Monero */
    .monero-badge {
        width: 120px;
        height: 120px;
    }
    
    .monero-badge i {
        font-size: 3rem;
    }
    
    .monero-badge span {
        font-size: 1.125rem;
    }
    
    /* Social Links */
    .social-links {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    /* Footer Badges */
    .footer-badges {
        flex-direction: column;
        align-items: center;
    }
    
    .badge-item {
        width: 100%;
        justify-content: center;
    }
    
    /* Buttons */
    .btn-primary,
    .btn-secondary {
        width: 100%;
        justify-content: center;
    }
}

/* === Extra Small Devices (max-width: 400px) === */
@media (max-width: 400px) {
    /* Navigation */
    .logo {
        font-size: 1rem;
    }
    
    .logo i {
        font-size: 1.25rem;
    }
    
    /* Hero */
    .hero-title {
        font-size: 1.75rem;
    }
    
    .stat-number {
        font-size: 1.75rem;
    }
    
    /* Layer Cards */
    .layer-icon {
        width: 50px;
        height: 50px;
    }
    
    .layer-icon i {
        font-size: 1.75rem;
    }
    
    /* Category Cards */
    .category-icon {
        width: 45px;
        height: 45px;
    }
    
    .category-icon i {
        font-size: 1.25rem;
    }
}

/* === Landscape Orientation Adjustments === */
@media (max-height: 600px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: var(--spacing-lg) 0;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-features {
        margin-bottom: var(--spacing-md);
    }
    
    .quick-stats {
        margin-top: var(--spacing-lg);
        padding-top: var(--spacing-md);
    }
    
    .modal {
        max-height: 95vh;
    }
}

/* === Print Styles === */
@media print {
    .navbar,
    .hero,
    .mobile-menu,
    .footer,
    .cta-section,
    .modal-overlay {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .section-title,
    .highlight {
        color: black;
    }
    
    a {
        color: black;
        text-decoration: underline;
    }
}

/* === Accessibility Improvements === */
@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) {
    :root {
        --primary-yellow: #FFFF00;
        --primary-black: #000000;
    }
    
    .btn-primary,
    .btn-secondary,
    .nav-link {
        border-width: 3px;
    }
}

/* === Dark Mode Support (Already Dark, but for completeness) === */
@media (prefers-color-scheme: dark) {
    /* Already optimized for dark mode */
}

/* === Touch Device Optimizations === */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    .btn-primary,
    .btn-secondary,
    .filter-btn,
    .nav-link {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .category-card:hover,
    .layer-card:hover,
    .feature-item:hover .feature-icon {
        transform: none;
    }
    
    /* Improve tap highlighting */
    * {
        -webkit-tap-highlight-color: rgba(255, 215, 0, 0.2);
    }
}

/* === Horizontal Scroll Prevention === */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* === Safe Area Insets for Notched Devices === */
@supports (padding: max(0px)) {
    .navbar,
    .footer {
        padding-left: max(var(--spacing-md), env(safe-area-inset-left));
        padding-right: max(var(--spacing-md), env(safe-area-inset-right));
    }
    
    .hero,
    .three-layers,
    .featured-categories,
    .monero-section,
    .recent-listings,
    .features-overview,
    .cta-section {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
}

/* === Focus Visible Styles for Accessibility === */
:focus-visible {
    outline: 3px solid var(--primary-yellow);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
    outline: 3px solid var(--primary-yellow);
    outline-offset: 2px;
}

/* === Loading States === */
.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    border: 3px solid var(--light-gray);
    border-top-color: var(--primary-yellow);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    transform: translate(-50%, -50%);
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* === Skeleton Loaders === */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--medium-gray) 0%,
        var(--light-gray) 50%,
        var(--medium-gray) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* === Smooth Scrolling for iOS === */
body {
    -webkit-overflow-scrolling: touch;
}

/* === Grid Auto-Fit Fallback === */
@supports not (grid-template-columns: repeat(auto-fit, minmax(250px, 1fr))) {
    .listings-grid,
    .categories-grid,
    .features-grid {
        display: flex;
        flex-wrap: wrap;
        gap: var(--spacing-md);
    }
    
    .listings-grid > *,
    .categories-grid > *,
    .features-grid > * {
        flex: 1 1 calc(33.333% - var(--spacing-md));
        min-width: 250px;
    }
}
