/* Sari3 Marketplace — brand: #E31E24 red + clean white UI */
:root {
    --primary: #E31E24;
    --primary-light: #FF3B3B;
    --primary-dark: #C01010;
    --black: #000000;
    --grey-900: #212121;
    --grey-700: #616161;
    --grey-500: #9E9E9E;
    --grey-300: #E0E0E0;
    --grey-100: #F5F5F5;
    --bg: #FCFCFC;
    --white: #FFFFFF;
    --border: #E4E4E4;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
    --radius: 16px;
    --radius-sm: 10px;
    --header-h: 72px;
    --font: 'Noto Kufi Arabic', 'Segoe UI', Tahoma, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--grey-900);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

img { max-width: 100%; display: block; }

.container {
    width: min(1280px, 100% - 2rem);
    margin-inline: auto;
}

/* ── Header ── */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    height: var(--header-h);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    height: var(--header-h);
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-shrink: 0;
}

.brand-logo {
    height: 44px;
    width: auto;
    object-fit: contain;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-name {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--black);
    letter-spacing: -0.02em;
}

.brand-tagline {
    font-size: 0.7rem;
    color: var(--primary);
    font-weight: 600;
}

.search-wrap {
    flex: 1;
    max-width: 520px;
    position: relative;
}

.search-wrap input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    border: 1.5px solid var(--border);
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.95rem;
    background: var(--grey-100);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-wrap input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(227, 30, 36, 0.15);
    background: var(--white);
}

.search-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--grey-500);
    pointer-events: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.15rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    box-shadow: 0 4px 14px rgba(227, 30, 36, 0.35);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(227, 30, 36, 0.45);
}

.btn-outline {
    background: var(--white);
    color: var(--grey-900);
    border: 1.5px solid var(--border);
}

.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-ghost {
    background: transparent;
    color: var(--grey-700);
    padding: 0.5rem;
}

.btn-icon {
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 50%;
}

.nav-desktop {
    display: flex;
    gap: 0.25rem;
}

.nav-desktop a {
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--grey-700);
}

.nav-desktop a:hover,
.nav-desktop a.active {
    color: var(--primary);
    background: rgba(227, 30, 36, 0.08);
}

.menu-toggle { display: none; }

/* ── Hero ── */
.hero {
    margin: 1.5rem 0 2rem;
    border-radius: calc(var(--radius) + 4px);
    overflow: hidden;
    background: linear-gradient(135deg, var(--black) 0%, #1a1a1a 50%, var(--primary-dark) 100%);
    color: var(--white);
    position: relative;
    min-height: 280px;
    display: flex;
    align-items: center;
}

.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.5;
}

.hero-content {
    position: relative;
    z-index: 1;
    padding: 2.5rem 3rem;
    max-width: 620px;
}

.hero h1 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.75rem;
}

.hero p {
    font-size: 1.05rem;
    opacity: 0.88;
    margin-bottom: 1.5rem;
}

.hero-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    font-size: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.hero-visual {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 38%;
    max-width: 420px;
    opacity: 0.15;
    pointer-events: none;
}

/* ── Section titles ── */
.section {
    margin-bottom: 2.5rem;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 1rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--black);
}

.section-title span {
    color: var(--primary);
}

.section-link {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
}

/* ── Brands strip ── */
.brands-strip {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.brands-strip::-webkit-scrollbar { height: 4px; }
.brands-strip::-webkit-scrollbar-thumb { background: var(--grey-300); border-radius: 4px; }

.brand-chip {
    flex: 0 0 auto;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    min-width: 88px;
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.brand-chip:hover,
.brand-chip.active {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.brand-chip img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.brand-chip span {
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    color: var(--grey-700);
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Featured carousel ── */
.featured-track {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 0.75rem;
}

.featured-card {
    flex: 0 0 min(340px, 85vw);
    scroll-snap-align: start;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--white);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.featured-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.featured-card .img-wrap {
    position: relative;
    height: 200px;
    background: var(--grey-100);
}

.featured-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.featured-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: linear-gradient(135deg, #FF5726, #FF7043);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.3rem 0.65rem;
    border-radius: 8px;
}

.featured-card .body {
    padding: 1rem 1.15rem;
}

.featured-card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.featured-card .price {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
}

.featured-card .meta {
    font-size: 0.85rem;
    color: var(--grey-500);
    margin-top: 0.25rem;
}

/* ── Filters bar ── */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
    padding: 1rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
}

.filter-select {
    padding: 0.55rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.88rem;
    background: var(--white);
    min-width: 130px;
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.7rem;
    background: rgba(227, 30, 36, 0.1);
    color: var(--primary-dark);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.filter-tag button {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
}

/* ── Cars grid ── */
.cars-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.car-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.car-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    border-color: rgba(227, 30, 36, 0.3);
}

.car-card .img-box {
    position: relative;
    height: 180px;
    background: var(--grey-100);
}

.car-card .img-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.warranty-pill {
    position: absolute;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, #FF5726, #FF7043);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.55rem;
    border-radius: 8px;
}

.car-card .info {
    padding: 1rem 1.1rem 1.15rem;
}

.car-card h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.car-card .price-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}

.car-card .price {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.car-card .specs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    margin-top: 0.6rem;
    font-size: 0.78rem;
    color: var(--grey-500);
}

.car-card .specs span {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* ── Loading / empty ── */
.skeleton {
    background: linear-gradient(90deg, var(--grey-100) 25%, #eee 50%, var(--grey-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
    border-radius: var(--radius);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-card { height: 320px; }

.loading-more {
    text-align: center;
    padding: 2rem;
    color: var(--grey-500);
}

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--grey-500);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    opacity: 0.4;
}

/* ── Footer ── */
.site-footer {
    margin-top: 4rem;
    padding: 2.5rem 0;
    background: var(--black);
    color: rgba(255, 255, 255, 0.85);
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-brand img {
    height: 48px;
    margin-bottom: 0.75rem;
    filter: brightness(0) invert(1);
}

.footer-brand p {
    font-size: 0.9rem;
    opacity: 0.75;
    max-width: 280px;
}

.footer-col h4 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    color: var(--white);
}

.footer-col a {
    display: block;
    font-size: 0.88rem;
    opacity: 0.75;
    padding: 0.25rem 0;
}

.footer-col a:hover { opacity: 1; color: var(--primary-light); }

.footer-bottom {
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.85rem;
    opacity: 0.6;
    text-align: center;
}

/* ── Mobile nav ── */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 0.5rem 0 calc(0.5rem + env(safe-area-inset-bottom));
    justify-content: space-around;
}

.mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.7rem;
    color: var(--grey-500);
    padding: 0.35rem 0.75rem;
}

.mobile-nav a.active { color: var(--primary); }

.mobile-nav svg { width: 22px; height: 22px; }

/* ── Car detail page ── */
.detail-page { padding: 1.5rem 0 4rem; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    color: var(--grey-700);
    margin-bottom: 1.25rem;
}

.back-link:hover { color: var(--primary); }

.detail-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 2rem;
    align-items: start;
}

.gallery-main {
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--grey-100);
    aspect-ratio: 16/10;
}

.gallery-main img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-thumbs {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    overflow-x: auto;
}

.gallery-thumbs img {
    width: 72px;
    height: 54px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: 0.7;
}

.gallery-thumbs img.active,
.gallery-thumbs img:hover {
    border-color: var(--primary);
    opacity: 1;
}

.detail-info h1 {
    font-size: 1.65rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.detail-price {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
}

.specs-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin: 1.25rem 0;
}

.spec-item {
    padding: 0.85rem 1rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.spec-item .label {
    font-size: 0.78rem;
    color: var(--grey-500);
}

.spec-item .value {
    font-weight: 600;
    font-size: 0.95rem;
}

.contact-box {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, rgba(227, 30, 36, 0.08), rgba(227, 30, 36, 0.02));
    border: 1px solid rgba(227, 30, 36, 0.2);
    border-radius: var(--radius);
}

.contact-box .btn { width: 100%; margin-top: 0.75rem; }

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 5rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--black);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 999px;
    font-size: 0.9rem;
    z-index: 2000;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .nav-desktop { display: none; }
    .menu-toggle { display: flex; }
    .search-wrap { max-width: none; }
    .hero-visual { display: none; }
    .hero-content { padding: 2rem 1.5rem; }
    .footer-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .mobile-nav { display: flex; }
    body { padding-bottom: 70px; }
}

/* ── Auth header ── */
.auth-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.auth-user-name {
    font-size: 0.88rem;
    font-weight: 600;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.82rem; }

.hide-desktop { display: none; }

.active-filters-bar {
    display: none;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(227, 30, 36, 0.06);
    border: 1px solid rgba(227, 30, 36, 0.2);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.active-filters-bar.visible { display: flex; }

.active-filters-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-dark);
}

/* ── Modals ── */
.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
}

.modal.open {
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-panel {
    position: relative;
    z-index: 1;
    background: var(--white);
    border-radius: 20px 20px 0 0;
    width: min(100%, 520px);
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.modal.open .modal-panel { transform: translateY(0); }

.modal-panel-lg { width: min(100%, 720px); }

.modal-panel-sm { width: min(100%, 420px); }

.modal-close {
    position: absolute;
    left: 1rem;
    top: 1rem;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--grey-100);
    border-radius: 50%;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: var(--grey-700);
}

.modal-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    padding-top: 0.5rem;
}

.modal-sub {
    font-size: 0.88rem;
    color: var(--grey-500);
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.modal-actions .btn { flex: 1; }

.field-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--grey-700);
    margin-bottom: 0.35rem;
}

.field-input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    margin-bottom: 0.85rem;
}

.field-input:focus {
    outline: none;
    border-color: var(--primary);
}

.otp-input {
    letter-spacing: 0.35em;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 700;
}

.btn-block { width: 100%; margin-top: 0.25rem; }

.auth-error {
    background: rgba(227, 30, 36, 0.1);
    color: var(--primary-dark);
    padding: 0.65rem 0.9rem;
    border-radius: 8px;
    font-size: 0.88rem;
    margin-bottom: 0.75rem;
}

.filter-modal-body { padding: 0.25rem 0; }

.filter-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.filter-brands-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    max-height: 200px;
    overflow-y: auto;
}

.filter-brand-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--white);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.68rem;
    transition: border-color 0.15s;
}

.filter-brand-btn img {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.filter-brand-btn.active {
    border-color: var(--primary);
    background: rgba(227, 30, 36, 0.06);
}

.filter-fields-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem 1rem;
}

.field-group { margin-bottom: 0; }

.field-group .field-input { margin-bottom: 0; }

@media (min-width: 640px) {
    .modal { align-items: center; }
    .modal-panel { border-radius: var(--radius); max-height: 85vh; }
    .modal.open .modal-panel { transform: translateY(0); }
}

@media (max-width: 900px) {
    .hide-desktop { display: inline-flex; }
}

@media (max-width: 600px) {
    .header-inner { gap: 0.5rem; }
    .brand-text { display: none; }
    .btn span.hide-sm { display: none; }
    .cars-grid { grid-template-columns: 1fr; }
    .filter-fields-grid { grid-template-columns: 1fr; }
}
