:root {
    --bs-primary: #1877f2;
    --bs-primary-rgb: 24, 119, 242;
    --bs-primary-text-emphasis: #0a58ca;
    --bs-primary-bg-subtle: #e7f0fe;
    --bs-primary-border-subtle: #bcd4fb;
    --bs-link-color: #1877f2;
    --bs-link-color-rgb: 24, 119, 242;
    --bs-link-hover-color: #166fe5;
    --bs-link-hover-color-rgb: 22, 111, 229;
    --bs-focus-ring-color: rgba(24, 119, 242, 0.25);
}

html {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

body {
    min-height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

app {
    display: block;
    min-height: 100dvh;
    height: 100%;
}

.header-logo {
    flex-shrink: 0;
    background-color: currentColor;
    -webkit-mask: url('../images/Logo.svg');
    mask: url('../images/Logo.svg');
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    width: 180px;
    height: 24px;
}

#blazor-error-ui {
    background: inherit;
    bottom: 0;
    display: none;
    position: fixed;
    width: 100%;
    height: 100%;
    z-index: 100001;
}

body {
    background-color: #f0f2f5;
}

.card {
    border-radius: 12px;
}

.shadow-sm {
    box-shadow: 0 1px 3px rgba(0,0,0,0.08) !important;
}

.btn-primary {
    background-color: #1877f2;
    border-color: #1877f2;
}

.btn-primary:hover {
    background-color: #166fe5;
    border-color: #166fe5;
}

.btn-outline-primary {
    color: #1877f2;
    border-color: #1877f2;
}

.btn-outline-primary:hover {
    background-color: #1877f2;
    border-color: #1877f2;
    color: white;
}

.fw-bold {
    font-weight: 700 !important;
}

.form-control:focus, .form-select:focus {
    border-color: #1877f2;
    box-shadow: 0 0 0 0.2rem rgba(24, 119, 242, 0.25);
}

.navbar-brand {
    font-size: 1.4rem;
}

.badge {
    font-weight: 500;
    font-size: 0.75rem;
}

.list-group-item.active {
    background-color: #1877f2;
    border-color: #1877f2;
}

.vehicle-card:hover, .group-card:hover {
    transform: translateY(-2px);
    transition: all 0.2s ease;
}

.hero-section {
    overflow: hidden;
}

.text-primary {
    color: #1877f2 !important;
}

.bg-primary {
    background-color: rgba(24, 119, 242, var(--bs-bg-opacity, 1)) !important;
}

.bg-opacity-10 {
    --bs-bg-opacity: .1;
}

.border-primary {
    border-color: #1877f2 !important;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* ===== Mobile responsive layer ===== */

html {
    height: auto;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100%;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: auto;
    touch-action: manipulation;
}

/* On desktop the body must NOT be a scroll container, otherwise the sticky feed
   sidebars never engage. Below lg the sidebars are hidden, so hand scrolling back
   to the body (the momentum-scrolling container mobile browsers expect). */
@media (max-width: 991.98px) {
    body {
        overflow: auto;
    }
}

@media (max-width: 767.98px) {
    .container {
        padding-right: 1rem;
        padding-left: 1rem;
        overscroll-behavior-y: auto;
    }

    .row > [class*="col-"] {
        min-width: 0;
    }
}

/* Horizontally scrollable nav tags (Marketplace, Profile tabs) */
@media (max-width: 767.98px) {
    .scroll-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        touch-action: pan-x;
    }
    .scroll-tabs::-webkit-scrollbar {
        display: none;
    }
    .scroll-tabs .nav-link {
        white-space: nowrap;
    }
}

/* Admin dashboard stat icons */
@media (max-width: 767.98px) {
    .admin-stat-icon {
        font-size: 2.25rem;
        line-height: 1;
    }
}

/* Listing detail: single-row thumbnail strip on mobile */
@media (max-width: 767.98px) {
    .listing-thumbs {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        touch-action: pan-x;
    }
    .listing-thumbs::-webkit-scrollbar {
        display: none;
    }
}

/* Disable decorative hover lifts on touch devices */
@media (hover: none) {
    .notification-row:hover {
        transform: none;
        box-shadow: none;
    }
    .vehicle-card:hover,
    .group-card:hover {
        transform: none;
    }
}

/* Blazor circuit reconnect: quiet pill instead of the stock full-screen banner.
   blazor.server.js reuses #components-reconnect-modal and toggles
   components-reconnect-{show,hide,failed,rejected} on it. */
#components-reconnect-modal {
    display: none;
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    z-index: 2000;
    pointer-events: none;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 10px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(24, 25, 30, 0.88);
    color: #f5f6f8;
    font-size: 13px;
    font-weight: 500;
    max-width: min(92vw, 480px);
    text-align: center;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
    animation: delala-reconnect-in 0.18s ease-out;
}

#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    padding: 10px 14px;
    border-radius: 12px;
    white-space: normal;
}

#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: flex;
}

#components-reconnect-modal.components-reconnect-hide {
    display: none;
}

#components-reconnect-modal .spinner-border {
    color: #4680ff;
    width: 0.95rem;
    height: 0.95rem;
}

#components-reconnect-modal .reconnect-note,
#components-reconnect-modal #reconnect-reload {
    display: none;
    color: #c9cbd1;
    font-weight: 400;
}

#components-reconnect-modal.components-reconnect-failed .reconnect-note,
#components-reconnect-modal.components-reconnect-rejected .reconnect-note {
    display: inline;
}

#components-reconnect-modal.components-reconnect-failed #reconnect-reload,
#components-reconnect-modal.components-reconnect-rejected #reconnect-reload {
    display: inline-flex;
    pointer-events: auto;
    margin-left: 4px;
    padding: 4px 12px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    font-size: 13px;
}

@keyframes delala-reconnect-in {
    from { opacity: 0; transform: translate(-50%, 8px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 420px) {
    #components-reconnect-modal {
        bottom: 12px;
        padding: 8px 10px;
        font-size: 12px;
        gap: 6px 8px;
        max-width: min(94vw, 420px);
    }
    #components-reconnect-modal.components-reconnect-failed,
    #components-reconnect-modal.components-reconnect-rejected {
        padding: 8px 12px;
    }
}

/* Post card reached from a notification click */
.feed-post-card {
    scroll-margin-top: 84px;
}

.post-highlight {
    box-shadow: 0 0 0 3px rgba(70, 128, 255, 0.4);
    border-radius: 12px;
    transition: box-shadow 0.4s ease;
}

/* The circuit reconnects in place (see _Host.cshtml retryDelays), so during a drop the
   pill above is shown while blazor.server.js toggles components-reconnect-show, then
   hidden via components-reconnect-hide. The Reload button only appears in the terminal
   failed/rejected states. */

/* ===== Consolidated component/page styles (moved out of .razor <style> blocks) ===== */

/* StoreProductCard.razor */
.spc-card .spc-img-wrap {
    height: 150px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.spc-card .spc-img {
    height: 100%;
    object-fit: cover;
}
.spc-card .spc-title {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* AppTopBar.razor */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.app-topbar-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
}
.app-topbar-toggler {
    display: none;
}
.app-topbar-links {
    display: flex;
    align-items: center;
    flex: 1;
}
.app-topbar-search {
    width: 180px;
}
.app-topbar .btn:hover {
    background: var(--bs-primary-bg-subtle, rgba(24, 119, 242, .1));
    color: var(--bs-primary, #1877f2);
}
.app-topbar .btn.active,
.app-topbar .btn.active:hover {
    background: var(--bs-primary, #1877f2);
    color: #fff;
}
.app-topbar-header {
    display: none;
}
.app-topbar-backdrop {
    display: none;
}
@media (max-width: 767.98px) {
    .app-topbar {
        height: 56px;
    }
    .app-topbar-inner {
        flex-wrap: nowrap;
    }
    .app-topbar-toggler {
        display: inline-flex;
        margin-left: auto;
    }
    .app-topbar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1029;
        animation: fadeIn 0.2s ease;
        overscroll-behavior: contain;
    }
    .app-topbar-links {
        position: fixed;
        top: 0;
        right: 0;
        height: 100dvh;
        height: 100svh;
        width: 280px;
        max-width: 85%;
        background: #fff;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 0;
        z-index: 1031;
        transform: translateX(100%);
        transition: transform 0.25s ease;
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.15);
        display: flex;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
    }
    .app-topbar-links.open {
        transform: translateX(0);
    }
    .app-topbar-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid #dee2e6;
        background: #f8f9fa;
    }
    .app-topbar-nav {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100%;
        padding: 0.5rem;
        gap: 0.25rem !important;
    }
    .app-topbar-nav .btn {
        width: 100%;
        text-align: left;
        padding: 0.625rem 0.75rem;
        border-radius: 8px;
        font-size: 0.95rem;
    }
    .app-topbar-actions {
        flex-wrap: wrap;
        width: 100%;
        margin-left: 0 !important;
        padding: 0.5rem 1rem 1rem;
        gap: 0.5rem 0.75rem;
        border-top: 1px solid #f1f3f5;
    }
    .app-topbar-search {
        width: 100% !important;
    }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Feed.razor */
.add-listing-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    font-size: 1.6rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(24, 119, 242, 0.4);
}
.stat-link {
    color: inherit;
    text-decoration: none;
    text-align: center;
    padding: 0.25rem 0.5rem;
    border-radius: 0.5rem;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.stat-link:hover {
    background-color: var(--bs-primary-bg-subtle, rgba(24, 119, 242, .1));
    color: var(--bs-primary, #1877f2);
}
.stat-link small {
    color: var(--bs-secondary-color, #6c757d);
}
.stat-link:hover small {
    color: inherit;
}

/* Marketplace.razor + Messages.razor */
.listing-card:hover {
    transform: translateY(-4px);
    transition: transform 0.2s ease;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1) !important;
}
.ms-overlay {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ms-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
}
.ms-overlay-dialog {
    position: relative;
    background: #fff;
    border-radius: 0.5rem;
    width: 100%;
    max-width: 520px;
    margin: 1rem;
    padding: 1.5rem;
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}

/* Messages.razor */
.messages-layout {
    min-height: 600px;
}
.messages-list {
    max-height: 500px;
    overflow-y: auto;
}
.messages-bubble {
    max-width: 70%;
    word-break: break-word;
}
@media (max-width: 767.98px) {
    .messages-layout {
        min-height: calc(100vh - 130px);
    }
    .messages-list {
        max-height: calc(100vh - 190px);
    }
    .messages-bubble {
        max-width: 82%;
    }
    .messages-page .messages-list-pane,
    .messages-page .messages-chat-pane {
        display: none;
    }
    .messages-page:not(.showing-chat) .messages-list-pane {
        display: block;
    }
    .messages-page.showing-chat .messages-chat-pane {
        display: flex;
    }
}

/* Notifications.razor */
.notification-row {
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.notification-row:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}

/* Groups.razor */
.group-card:hover {
    transform: translateY(-4px);
    transition: transform 0.2s ease;
}

/* StoreSettings.razor */
.theme-swatch { transition: box-shadow .15s ease, transform .15s ease; }
.theme-swatch:hover { transform: translateY(-2px); }
.theme-swatch-active { box-shadow: 0 0 0 2px var(--bs-primary, #1877f2); }

/* Profile.razor (static rules; per-store CSS variables stay inline in the component) */
.profile-banner { min-height: 200px; }
.profile-avatar { margin-top: -80px; }
.profile-avatar-img { width: 120px; height: 120px; object-fit: cover; }
.profile-avatar-initial { font-size: 2rem; }

.storefront-header .store-banner {
    min-height: 200px;
    background: linear-gradient(120deg, var(--store-primary), var(--store-secondary));
}
.storefront-header .store-logo {
    width: 120px;
    height: 120px;
}
.storefront-header .store-name,
.storefront-header .store-tagline {
    font-family: var(--store-font);
}
.storefront-pg .btn-primary {
    --bs-btn-bg: var(--store-primary);
    --bs-btn-border-color: var(--store-primary);
    --bs-btn-hover-bg: var(--store-secondary);
    --bs-btn-hover-border-color: var(--store-secondary);
    --bs-btn-active-bg: var(--store-secondary);
    --bs-btn-active-border-color: var(--store-secondary);
}
.storefront-pg .text-primary {
    color: var(--store-primary) !important;
}
.storefront-pg .store-contact span { white-space: nowrap; }
@media (max-width: 767.98px) {
    .profile-banner, .storefront-header .store-banner { min-height: 110px; }
    .profile-avatar { margin-top: -48px; }
    .profile-avatar-img, .storefront-header .store-logo { width: 84px; height: 84px; }
    .profile-avatar-initial { font-size: 1.5rem; }
    .store-contact { flex-direction: column !important; }
    .store-contact span { white-space: normal !important; }
}

/* Keep the consolidated hover lifts from re-enabling decorative motion on touch. */
@media (hover: none) {
    .notification-row:hover,
    .vehicle-card:hover,
    .group-card:hover,
    .listing-card:hover {
        transform: none;
        box-shadow: none;
    }
}

/* Feed.razor sidebar advertisement */
.feed-ad-image {
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
}
.feed-ad-text {
    white-space: pre-line;
}

/* ManageAds.razor */
.manage-ads-preview {
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
}
.manage-ads-thumb {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}
.manage-ads-thumb img { width: 100%; height: 100%; object-fit: cover; }
.text-truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.min-width-0 { min-width: 0; }
