/* ==================== REELS PAGE - FULLSCREEN ==================== */

/* Ensure no unexpected borders/outlines on reels elements */
.reels-page *,
.reels-page *::before,
.reels-page *::after {
    box-sizing: border-box;
}

.reels-page *:focus {
    outline: none;
}

/* Hide main header and footer when reels is active */
body:has(.reels-page.active) {
    overflow: hidden !important;
    width: 100vw !important;
    position: fixed;
}

body:has(.reels-page.active) .header,
body:has(.reels-page.active) .footer {
    display: none !important;
}

/* Page Container - True fullscreen */
.reels-page {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 56px !important;
    width: 100vw !important;
    background: #000;
    overflow: hidden;
    padding: 0 !important;
    margin: 0 !important;
    z-index: 100;
    border: none;
    outline: none;
}

.reels-page.active {
    display: block;
}

/* Reels Wrapper - Full width */
.reels-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    background: #000;
    border: none;
    outline: none;
    margin: 0;
    padding: 0;
}

/* Reels Header */
.reels-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top));
    background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.4) 70%, transparent 100%);
    z-index: 100;
    box-sizing: border-box;
}

.reels-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.02em;
    flex-shrink: 0;
}

.reels-filter-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    flex-shrink: 0;
}

/* Filters Bottom Sheet */
.reels-filters-sheet {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
}

.reels-filters-sheet.active {
    display: block;
}

.reels-filters-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.reels-filters-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1c1c1e;
    border-radius: 20px 20px 0 0;
    max-height: 85vh;
    max-height: 85dvh;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    overflow: hidden;
    max-width: 100vw;
    box-sizing: border-box;
}

.reels-filters-sheet.active .reels-filters-content {
    transform: translateY(0);
}

.reels-filters-handle {
    width: 36px;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    margin: 8px auto;
}

.reels-filters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.reels-filters-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: white;
    margin: 0;
}

.reels-filters-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 20px;
    cursor: pointer;
}

.reels-filters-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 20px;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

.reels-filter-section {
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
}

.reels-filter-section > label {
    display: block;
    font-size: 13px;
    color: rgba(255,255,255,0.6);
    font-weight: 600;
    margin-bottom: 10px;
}

.reels-filter-section select {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 16px;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.reels-filter-section select:focus {
    outline: none;
    background: rgba(255,255,255,0.15);
}

.reels-filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.reels-filter-row input {
    flex: 1;
    min-width: 0;
    padding: 14px 12px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 16px;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
}

.reels-filter-row input::placeholder {
    color: rgba(255,255,255,0.4);
}

.reels-filter-row input:focus {
    outline: none;
    background: rgba(255,255,255,0.15);
}

.reels-filter-separator {
    color: rgba(255,255,255,0.4);
    font-size: 16px;
}

.reels-filters-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(255,255,255,0.1);
    background: #1c1c1e;
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .reels-filters-footer {
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }
}

.reels-filter-reset-btn {
    flex: 1;
    padding: 16px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 14px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.reels-filter-apply-btn {
    flex: 2;
    padding: 16px;
    background: #007AFF;
    border: none;
    border-radius: 14px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.reels-filter-reset-btn:active,
.reels-filter-apply-btn:active {
    opacity: 0.7;
}

/* Reels Brand Picker */
.reels-brand-picker {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.reels-brand-picker::-webkit-scrollbar {
    display: none;
}

.reels-brand-item {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    background: white;
    border: 3px solid transparent;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reels-brand-item.active {
    border-color: #007AFF;
}

.reels-brand-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.reels-brand-all {
    font-size: 12px;
    font-weight: 700;
    color: #333;
}

/* ==================== REELS CONTAINER ==================== */
.reels-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    overflow-y: scroll;
    overflow-x: hidden;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    border: none;
    outline: none;
    margin: 0;
    padding: 0;
}

.reels-container::-webkit-scrollbar {
    display: none;
}

/* ==================== SINGLE REEL ITEM ==================== */
.reel-item {
    height: calc(100vh - 56px);
    height: calc(100dvh - 56px);
    width: 100vw;
    max-width: 100vw;
    position: relative;
    scroll-snap-align: start;
    background: #000;
    overflow: hidden;
    border: none;
    outline: none;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ==================== HORIZONTAL PHOTO GALLERY (SWIPER) ==================== */
.reel-gallery {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100%;
    margin: 0;
    padding: 0;
    touch-action: pan-y pinch-zoom;
}

.reel-gallery .swiper {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.reel-gallery .swiper-slide {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    overflow: visible;
}

.reel-gallery .swiper-zoom-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-origin: center center;
    will-change: transform;
    touch-action: none;
}

.reel-gallery .swiper-slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

/* Desktop: Center image with max width */
@media (min-width: 768px) {
    .reel-slide img {
        width: auto;
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
    }
}

.reel-placeholder {
    color: rgba(255,255,255,0.3);
}

/* ==================== PHOTO INDICATORS (SWIPER PAGINATION) ==================== */
.swiper-pagination {
    position: absolute !important;
    top: 70px !important;
    bottom: auto !important;
    left: 16px !important;
    right: 16px !important;
    width: auto !important;
    display: flex !important;
    gap: 4px;
    z-index: 80;
}

@media (min-width: 768px) {
    .swiper-pagination {
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%);
        width: 300px !important;
    }
}

.reel-indicator {
    flex: 1;
    height: 3px !important;
    width: auto !important;
    border-radius: 2px;
    background: rgba(255,255,255,0.35) !important;
    transition: background 0.2s ease;
    opacity: 1 !important;
    margin: 0 !important;
}

.reel-indicator.active {
    background: white !important;
}

/* ==================== ACTION BUTTONS (RIGHT SIDE) ==================== */
.reel-actions {
    position: absolute;
    right: 16px;
    bottom: 100px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 80;
}

@media (min-width: 768px) {
    .reel-actions {
        right: calc(50% - 220px);
        right: max(16px, calc(50% - 220px));
    }
}

.reel-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
}

.reel-action-btn:active {
    transform: scale(0.9);
}

.reel-action-icon {
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
}

.reel-action-label {
    font-size: 10px;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* ==================== CAR INFO PANEL (BOTTOM) ==================== */
.reel-info {
    position: absolute;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: auto !important;
    padding: 50px 16px 16px 16px;
    background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.7) 50%, transparent 100%);
    z-index: 70;
    border: none !important;
    outline: none !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    overflow: hidden;
}

@media (min-width: 768px) {
    .reel-info {
        left: 50% !important;
        transform: translateX(-50%);
        right: auto !important;
        width: 500px !important;
        max-width: calc(100% - 100px);
        text-align: center;
        padding: 50px 24px 24px 24px;
        border: none;
    }

    .reel-car-specs {
        justify-content: center;
    }

    .reel-seller {
        justify-content: center;
    }
}

.reel-car-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: white;
    margin-bottom: 4px;
}

.reel-car-price {
    font-size: 1.5rem;
    font-weight: 800;
    color: #30D158;
    margin-bottom: 10px;
}

.reel-car-specs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.reel-spec {
    padding: 5px 10px;
    background: rgba(255,255,255,0.2);
    border-radius: 6px;
    font-size: 12px;
    color: white;
    font-weight: 500;
}

.reel-car-description {
    font-size: 13px;
    color: rgba(255,255,255,0.9);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 6px;
}

.reel-car-location {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
}

.reel-seller {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.15);
}

.reel-seller-avatar {
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 13px;
}

.reel-seller-name {
    font-size: 13px;
    font-weight: 600;
    color: white;
}

/* ==================== LOADING ==================== */
.reels-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    z-index: 200;
}

.reels-loading.active {
    display: block;
}

.reels-loading::after {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== CHAT MODAL ==================== */
#modal-chat {
    z-index: 60000 !important;
}

#modal-chat.active {
    display: flex !important;
}

.chat-modal-content {
    max-width: 340px;
    text-align: center;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--separator);
}

.chat-seller-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-seller-info {
    text-align: left;
}

.chat-seller-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.chat-car-title {
    font-size: 13px;
    color: var(--text-tertiary);
}

.chat-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
}

.chat-action-btn.whatsapp {
    background: #25D366;
    color: white;
}

.chat-action-btn.telegram {
    background: #0088cc;
    color: white;
}

.chat-action-btn.phone {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.chat-phone-display {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-tertiary);
}

.chat-no-contact {
    padding: 20px;
    color: var(--text-tertiary);
}

/* ==================== BOTTOM SHEET ==================== */
.reels-bottom-sheet {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50000;
    display: none;
}

.reels-bottom-sheet.active {
    display: block;
}

.bottom-sheet-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
}

.bottom-sheet-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: #1c1c1e;
    border-radius: 20px 20px 0 0;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    border: none;
    outline: none;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .bottom-sheet-content {
        left: 50%;
        transform: translateX(-50%) translateY(100%);
        width: 400px;
    }

    .reels-bottom-sheet.active .bottom-sheet-content {
        transform: translateX(-50%) translateY(0);
    }
}

.reels-bottom-sheet.active .bottom-sheet-content {
    transform: translateY(0);
}

.bottom-sheet-handle {
    width: 36px;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    margin: 10px auto;
}

.bottom-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.bottom-sheet-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: white;
    margin: 0;
}

.bottom-sheet-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
}

.bottom-sheet-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

.sheet-car-header {
    display: flex;
    gap: 14px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sheet-car-image {
    width: 100px;
    height: 75px;
    border-radius: 10px;
    object-fit: cover;
    background: rgba(255,255,255,0.1);
}

.sheet-car-image-placeholder {
    width: 100px;
    height: 75px;
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.3);
}

.sheet-car-info {
    flex: 1;
}

.sheet-car-title {
    font-size: 1rem;
    font-weight: 600;
    color: white;
    margin-bottom: 4px;
}

.sheet-car-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: #30D158;
}

.sheet-specs-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.sheet-spec-item {
    background: rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 14px;
}

.sheet-spec-label {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    margin-bottom: 4px;
    text-transform: uppercase;
    font-weight: 600;
}

.sheet-spec-value {
    font-size: 15px;
    font-weight: 600;
    color: white;
}

.sheet-contact-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 16px;
    margin-top: 20px;
    background: white;
    color: #000;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.sheet-view-full {
    display: block;
    width: 100%;
    padding: 14px;
    margin-top: 10px;
    background: transparent;
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 14px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
}

/* ==================== DOUBLE TAP HEART ==================== */
.double-tap-heart {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    z-index: 55000;
    pointer-events: none;
    opacity: 0;
}

.double-tap-heart svg {
    width: 100px;
    height: 100px;
    color: #FF453A;
    filter: drop-shadow(0 4px 20px rgba(255, 69, 58, 0.6));
}

.double-tap-heart.active {
    animation: heartPop 0.8s ease-out forwards;
}

@keyframes heartPop {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    15% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
    30% { transform: translate(-50%, -50%) scale(0.95); opacity: 1; }
    45% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
    60% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}
