/**
 * SecondScent Responsive Utilities
 * Mobile-first responsive design enhancements
 */

/* ===================================
   TOUCH TARGETS
==================================== */

/* Minimum touch target size: 44x44px (Apple HIG, Material Design) */
.touch-target {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Increase tap area without changing visual size */
.touch-area {
    position: relative;
}

.touch-area::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 44px;
    min-height: 44px;
}

/* ===================================
   MOBILE NAVIGATION
==================================== */

/* Safe area for notched devices (iPhone X+) */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .safe-area-bottom {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .mobile-bottom-nav {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }
}

/* Sticky mobile nav */
.mobile-nav-sticky {
    position: sticky;
    bottom: 0;
    z-index: 100;
}

/* ===================================
   MOBILE MODALS
==================================== */

@media (max-width: 640px) {
    /* Full-screen modals on mobile */
    .modal-mobile-full {
        max-width: 100% !important;
        min-height: 100vh;
        margin: 0;
        border-radius: 0 !important;
    }
    
    /* Slide up from bottom on mobile */
    .modal-mobile-bottom {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 90vh;
        border-radius: 1.5rem 1.5rem 0 0 !important;
    }
}

/* ===================================
   MOBILE CARDS
==================================== */

@media (max-width: 640px) {
    /* Stack cards vertically on mobile */
    .card-grid-mobile-stack > * {
        grid-column: span 1 !important;
    }
    
    /* Reduce padding on mobile */
    .card-mobile-compact {
        padding: 1rem !important;
    }
    
    /* Full-width cards on mobile */
    .card-mobile-full {
        border-radius: 0;
        margin-left: -1rem;
        margin-right: -1rem;
        width: calc(100% + 2rem);
    }
}

/* ===================================
   HORIZONTAL SCROLL CONTAINERS
==================================== */

.scroll-container {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}

.scroll-container::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
}

.scroll-item {
    scroll-snap-align: start;
    flex-shrink: 0;
}

/* Scroll indicators */
.scroll-container-wrapper {
    position: relative;
}

.scroll-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 10;
    cursor: pointer;
    transition: all 0.3s ease;
}

.scroll-indicator:hover {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.scroll-indicator-left {
    left: 1rem;
}

.scroll-indicator-right {
    right: 1rem;
}

/* Hide indicators on mobile */
@media (max-width: 768px) {
    .scroll-indicator {
        display: none;
    }
}

/* ===================================
   MOBILE FORMS
==================================== */

@media (max-width: 640px) {
    /* Larger inputs on mobile */
    input, textarea, select {
        font-size: 16px !important; /* Prevents zoom on iOS */
        min-height: 44px;
    }
    
    /* Stack form layouts */
    .form-row {
        flex-direction: column !important;
    }
    
    .form-row > * {
        width: 100% !important;
    }
}

/* ===================================
   MOBILE TABLES
==================================== */

@media (max-width: 768px) {
    /* Responsive table - card layout */
    .table-responsive-cards {
        display: block;
    }
    
    .table-responsive-cards thead {
        display: none;
    }
    
    .table-responsive-cards tbody {
        display: block;
    }
    
    .table-responsive-cards tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #e5e7eb;
        border-radius: 0.5rem;
        padding: 1rem;
        background: white;
    }
    
    .table-responsive-cards td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border: none;
    }
    
    .table-responsive-cards td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
    }
}

/* ===================================
   MOBILE GRID ADJUSTMENTS
==================================== */

@media (max-width: 640px) {
    /* 1 column on mobile */
    .grid-mobile-1 {
        grid-template-columns: repeat(1, 1fr) !important;
    }
    
    /* 2 columns on mobile */
    .grid-mobile-2 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Reduce gaps on mobile */
    .gap-mobile-sm {
        gap: 0.5rem !important;
    }
}

/* ===================================
   SWIPEABLE ELEMENTS
==================================== */

.swipeable {
    touch-action: pan-y;
    user-select: none;
}

.swipeable-item {
    transition: transform 0.3s ease;
}

/* ===================================
   PULL TO REFRESH
==================================== */

.pull-to-refresh {
    position: relative;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.pull-to-refresh-indicator {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.pull-to-refresh.pulling .pull-to-refresh-indicator {
    top: 10px;
}

/* ===================================
   MOBILE TYPOGRAPHY
==================================== */

@media (max-width: 640px) {
    /* Reduce heading sizes on mobile */
    h1, .text-5xl, .text-6xl {
        font-size: 2rem !important;
        line-height: 1.2 !important;
    }
    
    h2, .text-4xl {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
    }
    
    h3, .text-3xl {
        font-size: 1.25rem !important;
        line-height: 1.4 !important;
    }
    
    /* Adjust line height for readability */
    p {
        line-height: 1.6 !important;
    }
}

/* ===================================
   MOBILE SPACING
==================================== */

@media (max-width: 640px) {
    /* Reduce padding on mobile */
    .px-mobile-4 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .py-mobile-4 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
    
    .p-mobile-4 {
        padding: 1rem !important;
    }
    
    /* Reduce margins on mobile */
    .my-mobile-4 {
        margin-top: 1rem !important;
        margin-bottom: 1rem !important;
    }
}

/* ===================================
   TABLET SPECIFIC
==================================== */

@media (min-width: 641px) and (max-width: 1024px) {
    /* 2-column layouts on tablet */
    .grid-tablet-2 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* 3-column layouts on tablet */
    .grid-tablet-3 {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* ===================================
   LANDSCAPE MOBILE
==================================== */

@media (max-width: 896px) and (orientation: landscape) {
    /* Reduce vertical spacing in landscape */
    .py-landscape-2 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
    
    /* Hide elements that take too much space */
    .hide-landscape {
        display: none !important;
    }
}

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

/* Ensure clickable elements are large enough */
@media (hover: none) {
    a, button, [role="button"], [onclick] {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
}

/* Remove hover effects on touch devices */
@media (hover: none) {
    .hover\:scale-105:hover,
    .hover\:scale-110:hover {
        transform: none !important;
    }
}

/* ===================================
   MOBILE UTILITIES
==================================== */

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

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

@media (max-width: 640px) {
    .mobile-only {
        display: block;
    }
}

.mobile-only-flex {
    display: none;
}

@media (max-width: 640px) {
    .mobile-only-flex {
        display: flex;
    }
}

/* Hide on tablet */
@media (min-width: 641px) and (max-width: 1024px) {
    .tablet-hidden {
        display: none !important;
    }
}

/* Show only on tablet */
.tablet-only {
    display: none;
}

@media (min-width: 641px) and (max-width: 1024px) {
    .tablet-only {
        display: block;
    }
}

/* Desktop only */
.desktop-only {
    display: none;
}

@media (min-width: 1025px) {
    .desktop-only {
        display: block;
    }
}

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

@media print {
    .no-print {
        display: none !important;
    }
    
    /* Remove backgrounds for print */
    * {
        background: white !important;
        color: black !important;
    }
    
    /* Show URLs for links */
    a[href]:after {
        content: " (" attr(href) ")";
    }
}

