﻿/*
 | Mobile experience layer
 | Route-aware overrides for ad detail, listing, category and home pages.
 */

:root {
    --mobile-surface: var(--sahibinden-surface, #ffffff);
    --mobile-muted-bg: var(--sahibinden-light-gray, #f5f6f8);
    --mobile-line: var(--sahibinden-border, #e6e8ec);
    --mobile-ink: var(--sahibinden-text, #101828);
    --mobile-subtle: var(--sahibinden-gray, #667085);
    --mobile-accent: var(--sahibinden-orange, #ff6b00);
    --mobile-accent-dark: var(--sahibinden-dark-orange, #d95500);
    --mobile-success: #16a34a;
}

/* PWA install UI */
.pwa-install-prompt {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 84px;
    z-index: 1400;
}

.pwa-install-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid #f1d9b7;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 10px 24px rgba(16, 24, 40, 0.14);
}

.pwa-install-text {
    min-width: 0;
}

.pwa-install-text strong {
    display: block;
    color: var(--mobile-ink);
    font-size: 14px;
}

.pwa-install-text p {
    color: var(--mobile-subtle);
    font-size: 12px;
    line-height: 1.35;
    margin-top: 2px;
}

.pwa-install-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.pwa-install-actions .btn {
    min-height: 44px;
    border-radius: 10px;
    font-weight: 700;
}

@media (min-width: 992px) {
    .pwa-install-prompt {
        display: none !important;
    }
}

@media (max-width: 991.98px) {
    .top-bar,
    .quick-links,
    .category-menu {
        display: none;
    }

    .main-header .main-header-inner {
        gap: 8px;
        flex-wrap: nowrap;
    }

    .main-header .logo {
        flex: 0 0 auto;
        display: inline-flex;
        align-items: center;
        min-width: max-content;
    }

    .main-header .logo-image {
        height: 36px;
        width: auto;
        max-width: 150px;
    }

    .main-header .header-cta {
        display: none;
    }

    .main-header {
        position: static;
        padding: 8px 0;
    }

    .main-header .search-container {
        flex: 1 1 auto;
        width: auto;
    }

    .main-header .search-input {
        width: 100%;
        min-width: 0;
    }

    .main-header .post-ad-btn {
        display: none;
    }

    /* Same design language for listing/category/home cards */
    .ads-listing-page .results-topbar,
    .category-page .category-hero,
    .home-mobile-refresh .content-wrapper {
        border-radius: 12px;
        border: 1px solid var(--mobile-line);
        box-shadow: 0 6px 16px rgba(16, 24, 40, 0.06);
        background: var(--mobile-surface);
    }

    .ads-listing-page .ad-card,
    .category-page .ad-card,
    .home-mobile-refresh .ad-card {
        border-radius: 12px;
        border: 1px solid var(--mobile-line);
        background: var(--mobile-surface);
        box-shadow: 0 6px 16px rgba(16, 24, 40, 0.05);
    }

    .ads-listing-page .ad-card .ad-image,
    .category-page .ad-card .ad-image,
    .home-mobile-refresh .ad-card .ad-card-img {
        border-radius: 10px;
    }

    .ads-listing-page .ad-title,
    .category-page .ad-title,
    .home-mobile-refresh .ad-card-title {
        color: var(--mobile-ink) !important;
        font-size: 13px;
        line-height: 1.4;
        height: auto;
        min-height: 38px;
    }

    .ads-listing-page .ad-price,
    .category-page .ad-price,
    .home-mobile-refresh .ad-card-price {
        color: var(--mobile-accent-dark) !important;
        font-weight: 800;
        font-size: 17px;
    }

    .ads-listing-page .pro-filter-card,
    .category-page .pro-filter-card {
        border-radius: 12px;
    }

    .ads-listing-page .js-filter-drawer-open,
    .category-page .js-filter-drawer-open {
        min-height: 44px;
        border-radius: 10px;
        font-weight: 700;
    }

    .home-mobile-refresh .section-header {
        padding: 12px;
    }

    .home-mobile-refresh .section-header h3 {
        font-size: 15px;
    }

    .home-mobile-refresh .ad-grid {
        gap: 10px;
        padding: 10px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    body {
        padding-bottom: 94px !important;
    }

    .mobile-bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1300;
        height: 74px;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        align-items: stretch;
        background: #fff;
        border-top: 1px solid #cfd6df;
        box-shadow: 0 -8px 20px rgba(15, 23, 42, 0.14);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .mobile-bottom-nav-item {
        border: 0;
        background: transparent;
        color: #7d8794;
        text-decoration: none;
        font-size: 10px;
        font-weight: 600;
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 6px 2px;
    }

    .mobile-bottom-nav-item i {
        font-size: 19px;
        line-height: 1;
    }

    .mobile-bottom-nav-item.active {
        color: #0f5d97;
        font-weight: 700;
    }

    .mobile-bottom-nav-item-highlight {
        color: #0f5d97;
        transform: translateY(-11px);
    }

    .mobile-bottom-nav-item-highlight i {
        width: 38px;
        height: 38px;
        border-radius: 999px;
        background: #0f5d97;
        color: #fff;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 8px 18px rgba(15, 93, 151, 0.35);
    }

    .mobile-bottom-nav-item-more {
        cursor: pointer;
    }

    .mobile-more-offcanvas {
        --bs-offcanvas-zindex: 1500;
        --bs-offcanvas-height: min(70vh, 500px);
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
        border: 1px solid #e5e7eb;
    }

    .offcanvas-backdrop.show {
        z-index: 1490;
    }

    .mobile-more-offcanvas .offcanvas-header {
        border-bottom: 1px solid #eef2f6;
        padding: 12px 14px;
    }

    .mobile-more-offcanvas .offcanvas-title {
        font-size: 16px;
        font-weight: 700;
        color: #1f2937;
    }

    .mobile-more-offcanvas .offcanvas-body {
        padding: 12px;
    }

    .mobile-more-grid {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 10px;
    }

    .mobile-more-link {
        min-height: 76px;
        border-radius: 12px;
        border: 1px solid #e5e7eb;
        background: #fff;
        text-decoration: none;
        color: #334155;
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 6px;
        font-size: 11px;
        font-weight: 700;
        text-align: center;
        padding: 8px 6px;
    }

    .mobile-more-link i {
        font-size: 18px;
    }

    .mobile-more-link:hover {
        border-color: #0f5d97;
        color: #0f5d97;
        background: #f8fbff;
    }

}

@media (max-width: 991.98px) {
    /* Focused mobile ad detail experience */
    .route-ads-show {
        padding-bottom: 128px !important;
        background: #fff;
    }

    .route-ads-show .top-bar,
    .route-ads-show .main-header,
    .route-ads-show .quick-links,
    .route-ads-show .category-menu,
    .route-ads-show .mobile-shortcuts,
    .route-ads-show .mobile-bottom-nav,
    .route-ads-show .main-footer {
        display: none !important;
    }

    .route-ads-show .ad-detail-page {
        padding: 0 !important;
        background: #fff;
    }

    .route-ads-show .ad-detail-page .ad-shell {
        max-width: 100%;
    }

    .route-ads-show .ad-mobile-header {
        position: sticky;
        top: 0;
        z-index: 1250;
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 10px;
        border-bottom: 1px solid var(--mobile-line);
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(8px);
    }

    .route-ads-show .ad-mobile-header__title {
        flex: 1;
        font-size: 13px;
        font-weight: 700;
        line-height: 1.35;
        color: var(--mobile-ink);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .route-ads-show .ad-mobile-header__btn {
        width: 44px;
        min-width: 44px;
        height: 44px;
        border: 1px solid var(--mobile-line);
        border-radius: 12px;
        background: #fff;
        color: #344054;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .route-ads-show .ad-mobile-header__btn.text-decoration-none {
        color: #344054;
    }

    .route-ads-show .ad-mobile-favorite-form {
        margin: 0;
        display: inline-flex;
    }

    .route-ads-show .ad-mobile-header__btn i {
        font-size: 18px;
    }

    .route-ads-show .ad-detail-main-column {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .route-ads-show .ad-detail-main-column > .detail-card {
        order: 5;
    }

    .route-ads-show .detail-gallery-card {
        order: 1 !important;
        margin-bottom: 0 !important;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .route-ads-show .detail-summary-card {
        order: 2 !important;
        margin: 0 12px;
    }

    .route-ads-show .detail-card {
        border-radius: 14px;
        box-shadow: 0 8px 20px rgba(16, 24, 40, 0.06);
        border: 1px solid var(--mobile-line);
    }

    .route-ads-show .detail-summary-card .card-body,
    .route-ads-show .detail-gallery-card .card-body,
    .route-ads-show .detail-gallery-card .card-header,
    .route-ads-show .detail-card .card-body,
    .route-ads-show .detail-card .card-header {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .route-ads-show .detail-gallery-card .card-header {
        padding-top: 10px !important;
        padding-bottom: 8px !important;
    }

    .route-ads-show .detail-gallery-main {
        border-radius: 14px;
        border: 1px solid var(--mobile-line);
        background: #f8fafc;
    }

    .route-ads-show .detail-gallery-main img {
        max-height: 340px;
    }

    .route-ads-show .detail-gallery-nav {
        width: 40px;
        height: 40px;
    }

    .route-ads-show .detail-gallery-counter {
        font-size: 11px;
        padding: 5px 10px;
    }

    .route-ads-show .detail-gallery-thumbs {
        gap: 6px;
        padding-bottom: 4px;
    }

    .route-ads-show .detail-thumb-btn img {
        width: 66px;
        height: 66px;
    }

    .route-ads-show .detail-price {
        font-size: clamp(24px, 7vw, 32px);
        margin: 4px 0 6px;
    }

    .route-ads-show .detail-summary-card .btn-sm {
        min-height: 40px;
        border-radius: 10px;
    }

    .route-ads-show .detail-meta {
        gap: 8px 12px;
        font-size: 12px;
    }

    .route-ads-show .detail-attr-panel {
        border: 0;
        background: transparent;
        padding: 0;
    }

    .route-ads-show .detail-attr-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        max-height: none;
        overflow: visible;
        gap: 8px;
    }

    .route-ads-show .detail-attr-item {
        border-radius: 10px;
        border: 1px solid var(--mobile-line);
        padding: 10px;
    }

    .route-ads-show .detail-attr-item small {
        font-size: 11px;
    }

    .route-ads-show .detail-attr-item strong {
        font-size: 13px;
        line-height: 1.3;
        display: block;
        margin-top: 4px;
        word-break: break-word;
    }

    .route-ads-show .mobile-description-text {
        margin-bottom: 0;
        white-space: pre-line;
        line-height: 1.6;
        color: #1f2937;
        word-break: break-word;
    }

    .route-ads-show .mobile-description-text.is-collapsed {
        display: -webkit-box;
        -webkit-line-clamp: 5;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .route-ads-show .mobile-description-toggle {
        min-height: 44px;
        margin-top: 10px;
        border-radius: 10px;
        font-weight: 700;
    }

    .route-ads-show .mobile-map-shell {
        border: 1px solid var(--mobile-line);
        border-radius: 12px;
        background: #fff;
        overflow: hidden;
    }

    .route-ads-show .mobile-map-actions {
        padding: 10px;
        display: grid;
        gap: 8px;
        padding-bottom: 14px;
    }

    .route-ads-show .mobile-map-actions .btn {
        min-height: 44px;
        border-radius: 10px;
        font-weight: 700;
    }

    .route-ads-show .mobile-inline-map {
        min-height: 220px;
        width: 100%;
    }

    .route-ads-show .mobile-related-scroll {
        display: flex;
        gap: 10px;
        overflow-x: auto;
        padding-bottom: 4px;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }

    .route-ads-show .mobile-related-scroll .detail-related-item {
        min-width: 255px;
        scroll-snap-align: start;
    }

    .route-ads-show .seller-sticky {
        position: static;
    }

    .route-ads-show .seller-card-mobile {
        margin-top: 2px;
    }

    .route-ads-show .seller-avatar {
        width: 68px;
        height: 68px;
    }

    .route-ads-show .ad-mobile-actionbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1300;
        padding: 10px 10px calc(env(safe-area-inset-bottom) + 10px);
        background: rgba(255, 255, 255, 0.98);
        border-top: 1px solid var(--mobile-line);
        box-shadow: 0 -10px 20px rgba(16, 24, 40, 0.14);
    }

    .route-ads-show .ad-mobile-actionbar-grid {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .route-ads-show .ad-mobile-actionbar .btn {
        min-height: 46px;
        border-radius: 11px;
        font-weight: 700;
        font-size: 13px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 8px;
    }

    .route-ads-show .ad-mobile-actionbar .btn-success {
        background: var(--mobile-success);
        border-color: var(--mobile-success);
    }

    .route-ads-show .ad-mobile-actionbar .btn-primary {
        background: linear-gradient(180deg, var(--mobile-accent), var(--mobile-accent-dark));
        border-color: var(--mobile-accent-dark);
    }

    .route-ads-show .image-viewer-modal .modal-dialog {
        margin: 0;
    }

    .route-ads-show .image-viewer-modal .viewer-image {
        max-height: 78vh;
    }

    .route-ads-show .image-viewer-modal .viewer-nav {
        width: 40px;
        height: 40px;
    }

    .route-ads-show .detail-topbar {
        display: none;
    }

    .route-ads-show .ad-detail-secondary-column {
        margin: 0 12px;
    }

    .route-ads-show .ad-detail-secondary-column .detail-card {
        margin-bottom: 12px;
    }

    .route-ads-show .ad-detail-main-column > .detail-card:not(.detail-gallery-card):not(.detail-summary-card) {
        margin: 0 12px 12px;
    }

    .route-ads-show .mobile-share-stack {
        display: none;
    }
}

@media (max-width: 575.98px) {
    .route-ads-show .detail-attr-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .route-ads-show .mobile-related-scroll .detail-related-item {
        min-width: 230px;
    }

    .pwa-install-prompt {
        left: 8px;
        right: 8px;
        bottom: 80px;
    }

    .pwa-install-card {
        padding: 10px;
    }
}
