/* ============================================================
   حراج اليمن - Haraj Yemen Styles
   ============================================================ */

/* CSS Variables - Yemen Market Colors */
:root {
    --primary: #1B5E20;
    --primary-dark: #0D3A13;
    --primary-light: #4CAF50;
    --secondary: #FFC107;
    --secondary-dark: #FFA000;
    --accent: #FF5722;
    --background: #F5F5F5;
    --surface: #FFFFFF;
    --text-primary: #212121;
    --text-secondary: #757575;
    --text-light: #FFFFFF;
    --divider: #E0E0E0;
    --success: #4CAF50;
    --warning: #FFC107;
    --error: #F44336;
    --verified: #4CAF50;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-strong: rgba(0, 0, 0, 0.2);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    direction: rtl;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
    height: auto;
}

/* Container */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ============================================================
   Header & Navigation
   ============================================================ */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--text-light);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px var(--shadow-strong);
}

/* ============================================================
   Categories Section
   ============================================================ */
.categories-section {
    background: var(--surface);
    padding: 20px 0;
    border-bottom: 1px solid var(--divider);
}

.categories-grid {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: thin;
}

.categories-grid::-webkit-scrollbar {
    height: 4px;
}

.categories-grid::-webkit-scrollbar-track {
    background: var(--divider);
    border-radius: 2px;
}

.categories-grid::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 2px;
}

.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 24px;
    background: var(--background);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    min-width: 100px;
    text-align: center;
}

.category-card:hover {
    background: #e8f5e9;
    border-color: var(--primary-light);
}

.category-card.active {
    background: var(--primary);
    color: var(--text-light);
    border-color: var(--primary);
}

.category-icon {
    font-size: 2rem;
}

.category-name {
    font-size: 0.85rem;
    font-weight: 600;
}

/* Category tag in ad card */
.category-tag {
    background: var(--primary-light);
    color: var(--text-light);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

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

.logo-icon {
    width: 48px;
    height: 48px;
    background: var(--secondary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.logo-text span {
    font-size: 0.75rem;
    opacity: 0.9;
}

.header-actions {
    display: flex;
    gap: 12px;
}

.header-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
    font-size: 0.9rem;
}

.header-btn-primary {
    background: var(--secondary);
    color: var(--text-primary);
}

.header-btn-primary:hover {
    background: var(--secondary-dark);
}

.header-btn-outline {
    background: transparent;
    border: 2px solid var(--text-light);
    color: var(--text-light);
}

.header-btn-outline:hover {
    background: var(--text-light);
    color: var(--primary);
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.user-info .user-name {
    color: var(--text-light);
    font-weight: 600;
    font-size: 0.9rem;
}

.user-info .user-type {
    color: var(--secondary);
    font-size: 0.75rem;
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 1.5rem;
    cursor: pointer;
}

/* ============================================================
   Search & Filters
   ============================================================ */
.search-section {
    background: var(--surface);
    padding: 24px 0;
    box-shadow: 0 2px 4px var(--shadow);
}

.search-box {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.search-input-wrapper {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.search-input-wrapper svg {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    fill: var(--text-secondary);
}

.search-input {
    width: 100%;
    padding: 14px 16px 14px 48px;
    border: 2px solid var(--divider);
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

.filter-select {
    padding: 14px 16px;
    border: 2px solid var(--divider);
    border-radius: 10px;
    font-size: 1rem;
    background: var(--surface);
    cursor: pointer;
    min-width: 150px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ============================================================
   Main Content
   ============================================================ */
.main-content {
    padding: 32px 0;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-title svg {
    width: 24px;
    height: 24px;
    fill: var(--primary);
}

/* ============================================================
   Ads Grid
   ============================================================ */
.ads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

/* Ad Card */
.ad-card {
    background: var(--surface);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 12px var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.ad-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow-strong);
}

.ad-card-image {
    position: relative;
    height: 180px;
    background: linear-gradient(135deg, #e0e0e0 0%, #f5f5f5 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-card-image svg {
    width: 64px;
    height: 64px;
    fill: #bdbdbd;
}

.ad-card-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--primary);
    color: var(--text-light);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.ad-card-verified {
    position: absolute;
    top: 12px;
    left: 12px;
    background: var(--verified);
    color: var(--text-light);
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ad-card-verified svg {
    width: 12px;
    height: 12px;
    fill: var(--text-light);
}

.ad-card-content {
    padding: 20px;
}

.ad-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.4;
}

.ad-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.ad-card-meta span {
    background: #f5f5f5;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.ad-card-location {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.ad-card-location svg {
    width: 14px;
    height: 14px;
    fill: var(--text-secondary);
}

.ad-card-price {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.ad-card-price small {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.ad-card-negotiable {
    display: inline-block;
    background: var(--secondary);
    color: var(--text-primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-right: 8px;
}

.ad-card-trader {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    border-top: 1px solid var(--divider);
    margin-top: 12px;
}

.trader-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-weight: 700;
}

.trader-info {
    flex: 1;
}

.trader-name {
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.trader-rating {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.trader-rating svg {
    width: 14px;
    height: 14px;
    fill: var(--secondary);
}

/* Action Buttons */
.ad-card-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.action-btn {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
}

.action-btn svg {
    width: 18px;
    height: 18px;
}

.action-btn-call {
    background: var(--primary);
    color: var(--text-light);
}

.action-btn-call:hover {
    background: var(--primary-dark);
}

.action-btn-call svg {
    fill: var(--text-light);
}

.action-btn-whatsapp {
    background: #25D366;
    color: var(--text-light);
}

.action-btn-whatsapp:hover {
    background: #128C7E;
}

.action-btn-whatsapp svg {
    fill: var(--text-light);
}

/* ============================================================
   Rating Section
   ============================================================ */
.rating-section {
    background: var(--surface);
    padding: 24px;
    border-radius: 16px;
    margin-top: 32px;
    box-shadow: 0 4px 12px var(--shadow);
}

.rating-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.rating-summary {
    display: flex;
    align-items: center;
    gap: 16px;
}

.rating-score {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
}

.rating-stars {
    display: flex;
    gap: 2px;
}

.rating-stars svg {
    width: 20px;
    height: 20px;
}

.rating-stars svg.filled {
    fill: var(--secondary);
}

.rating-stars svg.empty {
    fill: #e0e0e0;
}

.rating-count {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.rating-form {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 12px;
    margin-top: 20px;
}

.rating-form h4 {
    margin-bottom: 16px;
    font-size: 1rem;
}

.star-rating-input {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    justify-content: center;
}

.star-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    transition: transform 0.2s ease;
}

.star-btn:hover {
    transform: scale(1.2);
}

.star-btn svg {
    width: 32px;
    height: 32px;
    fill: #e0e0e0;
}

.star-btn.active svg {
    fill: var(--secondary);
}

.rating-comment {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--divider);
    border-radius: 10px;
    font-size: 1rem;
    resize: vertical;
    min-height: 80px;
    margin-bottom: 16px;
}

.rating-comment:focus {
    outline: none;
    border-color: var(--primary);
}

.rating-submit {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: var(--text-light);
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
}

.rating-submit:hover {
    background: var(--primary-dark);
}

/* Rating List */
.rating-list {
    margin-top: 24px;
}

.rating-item {
    padding: 16px;
    border-bottom: 1px solid var(--divider);
}

.rating-item:last-child {
    border-bottom: none;
}

.rating-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.rating-item-user {
    font-weight: 600;
}

.rating-item-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.rating-item-stars {
    display: flex;
    gap: 2px;
}

.rating-item-stars svg {
    width: 14px;
    height: 14px;
}

.rating-item-comment {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ============================================================
   Trader Profile Page
   ============================================================ */
.profile-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--text-light);
    padding: 40px 0;
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.profile-details h2 {
    font-size: 1.8rem;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.verified-badge {
    background: var(--secondary);
    color: var(--text-primary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.verified-badge svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.profile-location {
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.9;
    margin-bottom: 12px;
}

.profile-location svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.profile-stats {
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
}

.profile-stat {
    text-align: center;
}

.profile-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.profile-stat-label {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
    background: var(--primary-dark);
    color: var(--text-light);
    padding: 40px 0 20px;
    margin-top: 60px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 32px;
    margin-bottom: 32px;
}

.footer-section h4 {
    margin-bottom: 16px;
    font-size: 1.1rem;
}

.footer-section p,
.footer-section a {
    font-size: 0.9rem;
    opacity: 0.9;
    display: block;
    margin-bottom: 8px;
}

.footer-section a:hover {
    opacity: 1;
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.85rem;
    opacity: 0.7;
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state svg {
    width: 80px;
    height: 80px;
    fill: var(--divider);
    margin-bottom: 20px;
}

.empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

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

/* ============================================================
   Toast Notifications
   ============================================================ */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: var(--text-light);
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow-strong);
    z-index: 2000;
    animation: slideUp 0.3s ease;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--error);
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* ============================================================
   Loading State
   ============================================================ */
.loading {
    display: flex;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--divider);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 80px;
    height: 80px;
    fill: var(--divider);
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.95rem;
}

/* ============================================================
   Responsive Design
   ============================================================ */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 12px;
    }

    .menu-toggle {
        display: block;
    }

    .header-actions {
        display: none;
        width: 100%;
        flex-direction: column;
    }

    .header-actions.active {
        display: flex;
    }

    .search-box {
        flex-direction: column;
    }

    .search-input-wrapper {
        min-width: 100%;
    }

    .filter-select {
        width: 100%;
    }

    .ads-grid {
        grid-template-columns: 1fr;
    }

    .profile-info {
        flex-direction: column;
        text-align: center;
    }

    .profile-stats {
        justify-content: center;
        width: 100%;
    }

    .ad-card-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .container {
        padding: 0 12px;
    }

    .ad-card-content {
        padding: 16px;
    }

    .action-btn {
        padding: 10px;
        font-size: 0.85rem;
    }
}