/* ============================
   MOHIR QO'LLAR - Design System
   Mobile-first Marketplace CSS
   ============================ */

:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: all 0.2s ease;
    --container-max: 1200px;
}

[data-bs-theme="dark"] {
    --surface: #0f172a;
    --surface-2: #1e293b;
    --surface-3: #334155;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--surface-2);
    color: var(--text);
    padding-bottom: 70px;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

@media (min-width: 992px) {
    body {
        padding-bottom: 0 !important;
        background-image:
            radial-gradient(circle at 2px 2px, var(--border) 1px, transparent 0);
        background-size: 40px 40px;
        background-attachment: fixed;
    }
}

/* === HEADER === */
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 6px;
}

.logo-icon {
    font-size: 1.5rem;
}

.logo-text {
    font-size: 1.1rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text);
    transition: var(--transition);
    position: relative;
    border: none;
    background: var(--surface-3);
}

.btn-icon:hover {
    background: var(--primary);
    color: #fff;
}

.badge-count {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* === STICKY SEARCH === */
.sticky-search {
    background: var(--surface);
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 48px;
    z-index: 999;
}

.search-form .input-group {
    background: var(--surface-3);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.search-form .form-control {
    padding: 8px 0;
    font-size: 0.875rem;
}

.search-form .form-control:focus {
    box-shadow: none;
}

/* === BOTTOM NAVIGATION === */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 6px 0 env(safe-area-inset-bottom, 8px);
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 500;
    padding: 4px 12px;
    transition: var(--transition);
    position: relative;
}

.bottom-nav-item i {
    font-size: 1.25rem;
    margin-bottom: 2px;
}

.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: -6px;
    width: 24px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 4px 4px;
}

/* === PRODUCT CARDS === */
.product-card {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    text-decoration: none;
    color: var(--text);
    display: block;
    border: 1px solid var(--border);
}

.product-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    color: var(--text);
}

.product-card .product-img {
    aspect-ratio: 1;
    overflow: hidden;
    position: relative;
    background: var(--surface-3);
}

.product-card .product-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-card:hover .product-img img {
    transform: scale(1.05);
}

.product-card .discount-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

.product-card .wishlist-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.product-card .wishlist-btn:hover,
.product-card .wishlist-btn.active {
    color: var(--danger);
    background: #fff;
}

.product-card .product-info {
    padding: 10px;
}

.product-card .product-name {
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
    color: var(--text);
}

.product-card .product-price {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.product-card .current-price {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
}

.product-card .old-price {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: line-through;
}

.product-card .product-rating {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 0.7rem;
    color: var(--secondary);
    margin-top: 4px;
}

.product-card .product-rating span {
    color: var(--text-muted);
}

/* === CATEGORY CARDS === */
.category-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px 12px;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    transition: var(--transition);
    border: 1px solid var(--border);
    display: block;
}

.category-card:hover {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: var(--shadow-md);
}

.category-card .cat-icon {
    font-size: 2rem;
    margin-bottom: 6px;
}

.category-card .cat-name {
    font-size: 0.75rem;
    font-weight: 600;
}

.category-card .cat-count {
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* === ARTISAN CARDS === */
.artisan-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    transition: var(--transition);
    border: 1px solid var(--border);
    display: block;
}

.artisan-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    color: var(--text);
}

.artisan-card .artisan-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary-light);
    margin-bottom: 8px;
}

.artisan-card .artisan-name {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.artisan-card .artisan-specialty {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* === SECTION HEADERS === */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 0 4px;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    color: var(--text);
}

.section-link {
    font-size: 0.8rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

/* === HERO/BANNER === */
.hero-section {
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: #fff;
    padding: 24px 20px;
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    margin-bottom: 16px;
}

.hero-title {
    font-size: 1.3rem;
    font-weight: 800;
    line-height: 1.3;
    margin-bottom: 8px;
}

.hero-subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* === HORIZONTAL SCROLL === */
.scroll-container {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 4px 8px;
}

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

.scroll-container .product-card {
    min-width: 150px;
    max-width: 150px;
    scroll-snap-align: start;
    flex-shrink: 0;
}

.scroll-container .category-card {
    min-width: 90px;
    scroll-snap-align: start;
    flex-shrink: 0;
}

/* === DASHBOARD === */
.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 2px;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* === AUTH FORMS === */
.auth-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    max-width: 400px;
    margin: 0 auto;
    border: 1px solid var(--border);
}

.auth-card .auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-card .auth-title {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.auth-card .auth-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Form styling */
.form-control,
.form-select {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.875rem;
    background: var(--surface);
    color: var(--text);
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    padding: 10px 20px;
    transition: var(--transition);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), #4338ca);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* === CHAT === */
.chat-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    transition: var(--transition);
}

.chat-list-item:hover {
    background: var(--surface-3);
    color: var(--text);
}

.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-name {
    font-size: 0.875rem;
    font-weight: 600;
}

.chat-preview {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    line-height: 1.4;
    position: relative;
}

.message-bubble.sent {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message-bubble.received {
    background: var(--surface-3);
    color: var(--text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 0.6rem;
    opacity: 0.7;
    text-align: right;
    margin-top: 4px;
}

.message-read {
    font-size: 0.6rem;
    opacity: 0.7;
}

/* Chat input */
.chat-input-area {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 8px 12px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.chat-input-area .form-control {
    border-radius: var(--radius-xl);
    resize: none;
    max-height: 120px;
}

/* === PRODUCT DETAIL === */
.product-gallery {
    position: relative;
    aspect-ratio: 1;
    background: var(--surface-3);
    overflow: hidden;
}

.product-gallery img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-gallery-thumbs {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    overflow-x: auto;
}

.product-gallery-thumbs img {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition);
}

.product-gallery-thumbs img.active {
    border-color: var(--primary);
}

/* === RESPONSIVE GRID === */
.products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 0 4px;
}

@media (min-width: 576px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 992px) {
    body {
        padding-bottom: 0;
    }

    .bottom-nav {
        display: none;
    }

    .mobile-only {
        display: none !important;
    }

    .desktop-only {
        display: block !important;
    }

    .desktop-header {
        display: block !important;
        background: rgba(255, 255, 255, 0.8);
        backdrop-filter: blur(10px);
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    .app-content {
        max-width: var(--container-max);
        margin: 20px auto;
        background: var(--surface);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-sm);
        min-height: 80vh;
        border: 1px solid var(--border);
    }

    .products-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 20px;
    }

    .hero-section {
        border-radius: var(--radius-lg);
        height: 300px;
        display: flex;
        align-items: center;
        padding: 0 60px;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .section {
        padding: 40px;
    }
}

.desktop-header {
    display: none;
}

/* === REVIEW STARS === */
.stars {
    display: flex;
    gap: 2px;
}

.stars .bi-star-fill {
    color: var(--secondary);
}

.stars .bi-star {
    color: var(--text-muted);
}

/* === ORDER STATUS TIMELINE === */
.order-timeline {
    display: flex;
    gap: 0;
    padding: 16px 0;
}

.timeline-step {
    flex: 1;
    text-align: center;
    position: relative;
}

.timeline-step::before {
    content: '';
    position: absolute;
    top: 14px;
    left: -50%;
    right: 50%;
    height: 2px;
    background: var(--border);
}

.timeline-step:first-child::before {
    display: none;
}

.timeline-step.active::before {
    background: var(--primary);
}

.timeline-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--surface-3);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 6px;
    font-size: 0.7rem;
    position: relative;
    z-index: 1;
}

.timeline-step.active .timeline-dot {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.timeline-label {
    font-size: 0.6rem;
    color: var(--text-muted);
}

/* === MISC === */
.section {
    padding: 16px 12px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
}

.empty-state i {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.empty-state h5 {
    font-weight: 600;
    margin-bottom: 4px;
}

.empty-state p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Telegram Mini App safe area */
@supports (padding: env(safe-area-inset-bottom)) {
    .bottom-nav {
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }

    body {
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
    }
}

/* Dashboard nav */
.dash-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
}

.dash-nav::-webkit-scrollbar {
    display: none;
}

.dash-nav-item {
    white-space: nowrap;
    padding: 6px 14px;
    border-radius: var(--radius-xl);
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-secondary);
    background: var(--surface-3);
    transition: var(--transition);
    flex-shrink: 0;
}

.dash-nav-item:hover,
.dash-nav-item.active {
    background: var(--primary);
    color: #fff;
}

/* Theme toggle */
.theme-toggle {
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    background: var(--surface-3);
    border: none;
    color: var(--text);
    transition: var(--transition);
}

.theme-toggle:hover {
    background: var(--primary);
    color: #fff;
}

/* Page transition */
.app-content {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}