/* ============================================================================
   WHEN IT WAS - MOBILE SPECIFIC STYLES
   Mobile-only components: Bottom Sheet, Floating Card, Touch Gestures
   ============================================================================ */

/* ==================== MOBILE BOTTOM SHEET ==================== */
.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(42, 42, 42, 0.98);
    border-radius: 20px 20px 0 0;
    z-index: var(--z-bottom-sheet);
    transform: translateY(100vh);
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

/* Peek position - shows 65% of screen (adjusted from 50%) */
.bottom-sheet.peek {
    transform: translateY(35vh);
}

/* Half position - shows 80% of screen (adjusted from 70%) */
.bottom-sheet.half {
    transform: translateY(20vh);
}

/* Full position - fullscreen, timeline floats on top with higher z-index */
.bottom-sheet.full {
    transform: translateY(0vh);
    height: 100vh;
    max-height: 100vh;
}

.bottom-sheet-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: background 0.2s ease;
}

.bottom-sheet-close:active {
    background: rgba(0, 0, 0, 0.9);
}

/* Compact header - minimal space */
.bottom-sheet-compact-header {
    padding: 16px 20px 10px 20px; /* Minimal top padding */
    flex-shrink: 0;
    background: var(--color-background);
    border-bottom: 1px solid rgba(212, 165, 116, 0.15);
}

.bottom-sheet-handle {
    width: 40px;
    height: 4px;
    background: rgba(212, 165, 116, 0.3);
    border-radius: 2px;
    margin: 0 auto 8px auto;
}

.bottom-sheet-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
    margin-bottom: 6px;
}

.bottom-sheet-subtitle-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--color-text-secondary);
    flex-wrap: wrap;
}

.bottom-sheet-year {
    font-weight: 600;
    color: var(--color-primary);
}

.bottom-sheet-divider {
    color: rgba(212, 165, 116, 0.4);
}

.bottom-sheet-address {
    color: var(--color-text-secondary);
}

/* Main photo inside Details tab - smaller */
.bottom-sheet-main-photo {
    width: 100%;
    overflow: hidden;
    background: var(--color-card-bg);
    flex-shrink: 0;
}

.bottom-sheet-main-photo img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

/* Scrollable content wrapper inside tabs */
.tab-content-scroll {
    padding: 20px;
    padding-bottom: 140px; /* Extra space for timeline at bottom */
}

.bottom-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: var(--z-overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.bottom-sheet-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* ==================== FLOATING INFO CARD (Google Maps Style) ==================== */
.floating-info-card {
    position: fixed;
    bottom: 200px; /* Safe distance above timeline (timeline ~140px tall) */
    left: 16px;
    right: 16px;
    margin: 0 auto;
    transform: translateY(250px);
    background: var(--color-background);
    border-radius: var(--radius-lg); /* Increased from md to lg for more modern feel */
    box-shadow: var(--shadow-xl); /* Increased shadow for better elevation */
    padding: 16px; /* Increased from 12px for better touch targets */
    max-width: 420px; /* Increased from 400px */
    max-height: 180px; /* CRITICAL: Strict height limit to never overlap timeline */
    overflow: hidden; /* Changed from auto - card should be compact */
    z-index: var(--z-floating-card);
    opacity: 0;
    pointer-events: none; /* CRITICAL: Card container doesn't capture events when hidden */
    transition: opacity var(--transition-normal), transform var(--transition-normal);
    cursor: pointer;
    border: 1px solid var(--color-border-strong); /* Add subtle border */
}

.floating-info-card.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto; /* Only enable when active */
    animation: cardSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); /* Bounce effect */
}

/* CRITICAL FIX: Create dead zone below card that passes events to timeline */
.floating-info-card::before {
    content: '';
    position: absolute;
    bottom: -200px; /* Extends down to timeline */
    left: -16px;
    right: -16px;
    height: 200px;
    pointer-events: none !important; /* Never capture events */
    z-index: -1;
}

@keyframes cardSlideUp {
    0% {
        transform: translateY(250px);
        opacity: 0;
    }
    60% {
        transform: translateY(-8px); /* Slight overshoot */
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.floating-info-card-header {
    display: flex;
    gap: 14px; /* Increased from 12px */
    margin-bottom: 10px; /* Increased from 8px */
}

.floating-info-card-thumbnail {
    width: 90px; /* Increased from 80px for better visibility */
    height: 90px;
    object-fit: cover;
    border-radius: 10px; /* Slightly larger radius */
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); /* Add depth */
}

.floating-info-card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px; /* Increased from 4px */
    justify-content: center;
}

.floating-info-card-title {
    font-size: 17px; /* Increased from 16px for better readability */
    font-weight: 700; /* Bolder */
    color: var(--color-text);
    line-height: 1.4; /* Improved line spacing */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.floating-info-card-year {
    font-size: 14px; /* Increased from 13px */
    font-weight: 700; /* Bolder */
    color: var(--color-primary);
    letter-spacing: 0.3px; /* Better spacing */
}

.floating-info-card-address {
    font-size: 13px; /* Increased from 12px */
    color: var(--color-text-secondary);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.floating-info-card-tap-hint {
    font-size: 12px; /* Increased from 11px */
    font-weight: 500;
    color: var(--color-text-dim);
    text-align: center;
    margin-top: 8px; /* Increased from 4px */
    padding-top: 10px; /* Increased from 8px */
    border-top: 1px solid var(--color-border);
}

.floating-info-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

/* ==================== TAB SYSTEM FOR BOTTOM SHEET ==================== */
.bottom-sheet-tabs {
    display: flex;
    border-bottom: 2px solid var(--color-border);
    padding: 0 var(--spacing-lg);
    gap: var(--spacing-lg);
    flex-shrink: 0;
    background: var(--color-background);
    position: sticky;
    top: 0;
    z-index: 10;
    touch-action: none; /* Prevent touch gestures from moving bottom sheet */
    will-change: auto; /* Prevent GPU layer promotion that can cause shifts */
    transform: translateZ(0); /* Force own layer without movement */
}

.bottom-sheet-tab {
    padding: 10px 16px;
    font-size: 15px;
    font-weight: 500;
    color: var(--color-text-secondary);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin: 6px 4px;
    margin-bottom: -2px;
    transition: all var(--transition-fast);
    user-select: none;
    touch-action: manipulation; /* Allow taps but prevent other gestures */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight */
    /* Refined box styling with GOLD borders */
    background: rgba(30, 41, 59, 0.6);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(246, 211, 101, 0.5);
}

.bottom-sheet-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    /* Enhanced styling for active tab with brighter GOLD border */
    background: rgba(246, 211, 101, 0.15);
    box-shadow: 0 4px 12px rgba(246, 211, 101, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(246, 211, 101, 0.9);
}

.bottom-sheet-tab:not(.active):hover {
    color: var(--color-text);
}

/* Container for all tab panels - prevents layout shift */
.bottom-sheet-tabs-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
}

.bottom-sheet-tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.bottom-sheet-tab-content.active {
    display: flex;
}

.tab-placeholder {
    text-align: center;
    padding: var(--spacing-xl) var(--spacing-lg);
    padding-bottom: 140px; /* Extra space for timeline at bottom */
    color: var(--color-text-secondary);
}

.tab-placeholder-icon {
    font-size: 48px;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.tab-placeholder-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--spacing-sm);
}

.tab-placeholder-text {
    font-size: 14px;
    line-height: 1.5;
}

/* ==================== PHOTO CAROUSEL (Google Maps Style) ==================== */
.bottom-sheet-photo-carousel {
    padding: 16px;
    background: var(--color-background);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.bottom-sheet-photo-carousel-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 12px;
}

.photo-carousel-scroll {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    padding: 4px;
    padding-bottom: 140px; /* Extra space for timeline at bottom */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.photo-carousel-scroll::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.photo-carousel-item {
    flex-shrink: 0;
    width: 100%;
    height: 250px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.2s ease;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.photo-carousel-item:active {
    transform: scale(0.98);
}

.photo-carousel-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Photo year badge overlay */
.photo-carousel-year {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: var(--color-primary);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    backdrop-filter: blur(4px);
}

/* Carousel dots indicator - hidden in vertical layout */
.photo-carousel-dots {
    display: none;
}

.photo-carousel-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(212, 165, 116, 0.3);
    transition: all 0.3s ease;
}

.photo-carousel-dot.active {
    width: 20px;
    border-radius: 3px;
    background: var(--color-primary);
}

/* ==================== MOBILE RESPONSIVE STYLES ==================== */
@media (max-width: 768px) {
    /* Hide desktop sidebar and modal on mobile */
    .location-sidebar,
    .sidebar-overlay,
    #modalOverlay {
        display: none !important;
    }

    .sidebar {
        display: none;
    }

    /* Hide timeline and labels toggles on mobile */
    .toggle-switch,
    #labelsToggle,
    #timelineToggle {
        display: none !important;
    }

    /* Make timeline slider area smaller on mobile */
    .timeline-container {
        padding: 12px 15px !important;
    }

    .timeline-header {
        margin-bottom: 8px !important;
    }

    .timeline-label {
        font-size: 14px !important;
    }

    /* Mobile header adjustments - Enhanced */
    .header {
        padding: 12px 16px;
        flex-wrap: wrap;
        background: rgba(22, 27, 34, 0.98);
        backdrop-filter: blur(10px);
        border-bottom: 2px solid rgba(246, 211, 101, 0.3);
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    .logo {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 4px 0;
    }

    .logo img {
        height: 35px;
        object-fit: contain;
    }

    .hamburger-btn {
        display: flex;
        order: 3;
        padding: 10px;
        background: rgba(246, 211, 101, 0.1);
        border-radius: 8px;
        border: 1px solid rgba(246, 211, 101, 0.3);
        transition: all 0.2s ease;
    }

    .hamburger-btn:hover {
        background: rgba(246, 211, 101, 0.2);
        border-color: rgba(246, 211, 101, 0.5);
    }

    .hamburger-btn span {
        width: 22px;
        height: 2.5px;
    }

    .header-controls {
        order: 4;
        width: 100%;
        margin-top: 10px;
        justify-content: flex-start;
        gap: 0;
    }

    .search-bar {
        max-width: none;
        width: 100%;
        position: relative !important; /* CRITICAL: Make search-bar the positioning parent */
    }

    .search-bar input {
        padding: 12px 40px 12px 16px;
        border: 2px solid rgba(246, 211, 101, 0.3);
        border-radius: 12px;
        background: rgba(30, 41, 59, 0.6);
        font-size: 15px;
        transition: all 0.2s ease;
    }

    .search-bar input:focus {
        border-color: rgba(246, 211, 101, 0.7);
        background: rgba(30, 41, 59, 0.8);
        box-shadow: 0 0 0 3px rgba(246, 211, 101, 0.1);
    }

    /* Mobile search dropdown adjustments - dropdown from search bar */
    .search-dropdown {
        position: absolute !important; /* Absolute to search-bar parent */
        top: calc(100% + 5px) !important; /* Right below search input with gap */
        bottom: auto !important;
        left: 0 !important;
        right: 0 !important;
        margin-top: 0 !important;
        max-height: 60vh; /* Taller on mobile */
        border-radius: var(--radius-md);
        z-index: 10001 !important; /* Above everything */
        background: var(--color-background) !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
        overflow-y: auto;
    }

    .search-dropdown.active {
        display: block !important;
    }

    .search-dropdown-item {
        padding: 15px 20px;
        touch-action: manipulation;
    }

    /* Hide category filter and user controls on mobile */
    .header .category-filter,
    .header .user-controls {
        display: none;
    }

    /* Mobile menu overlay */
    .mobile-menu-overlay {
        display: none;
    }

    .map-badge {
        top: 10px;
        right: 10px;
        padding: 6px 12px;
        font-size: 12px;
    }

    .gps-btn {
        bottom: 240px;
        right: 10px;
    }

    /* Timeline fixed at bottom on mobile - always accessible */
    .timeline-container {
        padding: 15px 10px;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 2600 !important; /* Above bottom sheet (2500) - floats on top */
        pointer-events: auto !important; /* Always capture events */
        touch-action: auto !important; /* Enable touch interactions */
    }

    /* Force all timeline children to be interactive */
    .timeline-container,
    .timeline-container *,
    .slider-thumb,
    .slider-track,
    .toggle-switch {
        pointer-events: auto !important;
        touch-action: auto !important;
    }

    .timeline-header {
        margin-bottom: 15px;
    }

    .timeline-label {
        font-size: 14px;
    }

    .toggle-switch {
        padding: 6px 10px;
    }

    .slider-wrapper {
        padding: 8px 0;
    }

    .slider-thumb {
        width: 24px !important;
        height: 24px !important;
        margin-left: -12px !important;
        margin-top: -9px !important;
    }

    /* ==================== MOBILE COMMENTS STYLING ==================== */
    .mobile-comments-section {
        padding: 20px;
    }

    .comment-form {
        margin-bottom: 20px;
    }

    .comment-form textarea {
        width: 100%;
        background: var(--color-background-light);
        border: 1px solid var(--color-border-strong);
        border-radius: 8px;
        padding: 12px;
        color: var(--color-text);
        font-family: inherit;
        font-size: 14px;
        resize: vertical;
        min-height: 80px;
        box-sizing: border-box;
    }

    .comment-form textarea::placeholder {
        color: var(--color-text-secondary);
        opacity: 0.7;
    }

    .comment-form textarea:focus {
        outline: none;
        border-color: var(--color-primary);
    }

    .submit-comment-btn {
        margin-top: 10px;
        padding: 12px 24px;
        background: var(--color-primary);
        color: var(--color-background-dark);
        border: none;
        border-radius: 6px;
        font-weight: 500;
        font-size: 14px;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .submit-comment-btn:active {
        transform: scale(0.98);
        opacity: 0.9;
    }

    .comments-list {
        margin-top: 20px;
    }

    .comment-item {
        padding: 12px;
        background: var(--color-background-light);
        border: 1px solid var(--color-border);
        border-radius: 8px;
        margin-bottom: 10px;
    }

    .comment-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 8px;
    }

    .comment-author {
        font-weight: 500;
        color: var(--color-primary);
        font-size: 14px;
    }

    .comment-date {
        font-size: 11px;
        color: var(--color-text-secondary);
    }

    .comment-text {
        color: var(--color-text);
        font-size: 14px;
        line-height: 1.5;
    }

    /* ==================== MOBILE TOUCH TARGET OPTIMIZATION ==================== */
    /* Minimum 50px touch targets for better usability */

    .popup-btn {
        padding: 14px 16px !important;
        font-size: 14px !important;
        min-height: 50px;
    }

    .modal-close,
    .sidebar-close {
        width: 50px !important;
        height: 50px !important;
        font-size: 24px !important;
    }

    .toggle-switch {
        padding: 15px 16px !important;
        min-height: 50px;
    }

    .toggle-switch-track {
        width: 50px !important;
        height: 26px !important;
    }

    .toggle-switch-thumb {
        width: 22px !important;
        height: 22px !important;
    }

    .toggle-switch-track.active .toggle-switch-thumb {
        left: 26px !important;
    }

    .slider-thumb {
        width: 50px !important;
        height: 50px !important;
        margin-left: -25px !important;
        margin-top: -22px !important;
    }

    .bottom-sheet-preview {
        cursor: pointer;
    }

    .gps-btn {
        width: 50px !important;
        height: 50px !important;
        font-size: 24px !important;
    }

    .action-btn {
        padding: 12px 16px !important;
        min-height: 50px;
        font-size: 14px !important;
    }

    .add-business-btn,
    .add-photo-btn {
        padding: 15px !important;
        min-height: 50px;
        font-size: 16px !important;
    }

    .login-modal-btn {
        padding: 15px !important;
        min-height: 50px;
        font-size: 16px !important;
    }

    .search-bar input {
        padding: 15px 40px 15px 15px !important;
        min-height: 50px;
        font-size: 16px !important;
    }

    .category-filter {
        padding: 15px 20px !important;
        min-height: 50px;
        font-size: 16px !important;
    }

    .bottom-sheet-close {
        width: 50px !important;
        height: 50px !important;
        font-size: 24px !important;
    }

    .legend {
        display: none;
    }
}
