/* ============================================
   KHERRATA WORK — Professional Marketplace UI
   Visual polish only — no logic changes
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap');

:root {
  /* Brand */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --secondary: #059669;
  --secondary-soft: #ecfdf5;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning: #d97706;

  /* Neutrals */
  --dark: #0f172a;
  --text: #1e293b;
  --text-muted: #64748b;
  --gray: #64748b;
  --light: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  /* Radius & shadow */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 28px rgba(15, 23, 42, 0.08);
  --shadow-hover: 0 12px 32px rgba(15, 23, 42, 0.12);

  /* Layout */
  --container: 1140px;
  --nav-h: 68px;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  background: #f1f5f9;
  color: var(--text);
  line-height: 1.65;
  direction: rtl;
  font-size: 15.5px;
  -webkit-font-smoothing: antialiased;
}

a {
  text-decoration: none;
  color: inherit;
  transition: color 0.2s ease;
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

/* ========== Container ========== */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ========== Navbar ========== */
.navbar {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 0;
  min-height: var(--nav-h);
  display: flex;
  align-items: center;
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 1rem;
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.logo span {
  color: var(--dark);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.35rem 1.1rem;
  list-style: none;
  flex-wrap: wrap;
}

.nav-links a:not(.btn) {
  font-weight: 500;
  font-size: 0.92rem;
  color: var(--text-muted);
  padding: 0.35rem 0.2rem;
  position: relative;
}

.nav-links a:not(.btn):hover {
  color: var(--primary);
}

.nav-links .btn {
  margin-inline-start: 0.15rem;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  line-height: 1.3;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-outline {
  background: transparent;
  border-color: var(--primary);
  color: var(--primary);
}

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

.btn-success {
  background: var(--secondary);
  color: #fff;
}

.btn-success:hover {
  background: #047857;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
}

/* ========== Hero ========== */
.hero {
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(37, 99, 235, 0.35), transparent),
    linear-gradient(145deg, #1e3a8a 0%, #2563eb 45%, #3b82f6 100%);
  color: #fff;
  padding: 4.5rem 0 4rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::after {
  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.04'%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");
  pointer-events: none;
}

.hero .container {
  position: relative;
  z-index: 1;
}

.hero h1 {
  font-size: clamp(1.9rem, 4vw, 2.75rem);
  margin-bottom: 0.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.hero p {
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  opacity: 0.92;
  margin-bottom: 1.75rem;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.7;
  font-weight: 400;
}

.hero-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.hero-buttons .btn {
  min-width: 140px;
  padding: 0.7rem 1.4rem;
  border-radius: 10px;
  font-size: 0.95rem;
}

/* ========== Section ========== */
.section {
  padding: 3.25rem 0;
}

.section-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--dark);
  letter-spacing: -0.02em;
}

.section-title h2 {
  font-size: inherit;
  font-weight: inherit;
}

.section-title a {
  font-size: 0.9rem;
  color: var(--primary);
  font-weight: 600;
  white-space: nowrap;
}

.section-title a:hover {
  text-decoration: underline;
}

/* ========== Listing Cards ========== */
.auctions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.35rem;
}

.auction-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
  display: flex;
  flex-direction: column;
}

.auction-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.auction-card .image-wrapper {
  position: relative;
  height: 190px;
  overflow: hidden;
  background: linear-gradient(135deg, #e2e8f0, #f1f5f9);
}

.auction-card .image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.45s ease;
}

.auction-card:hover .image-wrapper img {
  transform: scale(1.04);
}

.auction-card .badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(15, 23, 42, 0.82);
  color: #fff;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  backdrop-filter: blur(4px);
}

.auction-card .content {
  padding: 1.1rem 1.15rem 1.2rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.auction-card .title {
  font-size: 0.98rem;
  font-weight: 600;
  margin-bottom: 0.45rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
  color: var(--dark);
  line-height: 1.4;
}

.auction-card .price {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.35rem;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.auction-card .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: auto;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
  gap: 0.5rem;
}

.auction-card .time-left {
  color: var(--danger);
  font-weight: 600;
}

/* ========== Categories ========== */
.categories {
  display: flex;
  gap: 0.55rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  margin-bottom: 1.5rem;
  scrollbar-width: thin;
}

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

.category-btn {
  white-space: nowrap;
  padding: 0.5rem 1.05rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.18s ease;
  color: var(--text-muted);
}

.category-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.category-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

/* ========== Footer ========== */
.footer {
  background: var(--dark);
  color: #94a3b8;
  padding: 3.25rem 0 1.5rem;
  margin-top: 2.5rem;
}

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

.footer h4 {
  color: #f8fafc;
  margin-bottom: 0.9rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.footer p {
  font-size: 0.88rem;
  line-height: 1.7;
  max-width: 280px;
}

.footer ul {
  list-style: none;
}

.footer ul li {
  margin-bottom: 0.45rem;
}

.footer ul a {
  font-size: 0.88rem;
  color: #94a3b8;
}

.footer a:hover {
  color: #fff;
}

.footer-bottom {
  border-top: 1px solid #1e293b;
  padding-top: 1.25rem;
  text-align: center;
  font-size: 0.82rem;
  color: #64748b;
}

/* ========== Utilities ========== */
.text-center { text-align: center; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }

/* Loading */
.loading {
  display: flex;
  justify-content: center;
  padding: 3rem;
  grid-column: 1 / -1;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ========== Auth Forms ========== */
.auth-page {
  min-height: calc(100vh - var(--nav-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1rem;
  background:
    radial-gradient(ellipse at top, var(--primary-soft), transparent 55%),
    #f1f5f9;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 420px;
  padding: 2.25rem 1.75rem;
}

.auth-card h1 {
  font-size: 1.45rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  text-align: center;
  color: var(--dark);
  letter-spacing: -0.02em;
}

.auth-card .subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
  font-size: 0.9rem;
}

.form-group {
  margin-bottom: 1.1rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.7rem 0.95rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
  color: var(--text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-group .error {
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 0.3rem;
  display: none;
}

.form-group.has-error input {
  border-color: var(--danger);
}

.form-group.has-error .error {
  display: block;
}

.auth-card .btn {
  width: 100%;
  padding: 0.8rem;
  font-size: 0.95rem;
  margin-top: 0.4rem;
  border-radius: 10px;
}

.auth-footer {
  text-align: center;
  margin-top: 1.35rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.auth-footer a {
  color: var(--primary);
  font-weight: 600;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.alert {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.1rem;
  font-size: 0.88rem;
  display: none;
}

.alert-error {
  background: var(--danger-soft);
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: var(--secondary-soft);
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.alert.show {
  display: block;
}

/* How it works steps */
.section .container > div[style*="grid"] {
  gap: 1.5rem !important;
}

/* Form cards (create/edit) */
.form-card {
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow) !important;
  border-radius: var(--radius-lg) !important;
}

.form-card h1 {
  letter-spacing: -0.02em;
  color: var(--dark);
}

/* Search & filters on listings page */
.search-bar input,
.filters-row select {
  border-radius: var(--radius-sm) !important;
  border-color: var(--border) !important;
}

.search-bar input:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Status badges */
.status-badge {
  font-size: 0.75rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.01em;
}

/* Listing actions */
.listing-actions .btn {
  font-size: 0.8rem !important;
  padding: 0.4rem 0.75rem !important;
}

/* Empty states */
.empty-state {
  border: 1px dashed var(--border) !important;
  box-shadow: none !important;
}

/* Comments polish */
.comments-section {
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow-xs) !important;
}

.btn-fav {
  border-radius: var(--radius-sm) !important;
}

.btn-fav.favorited {
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.2);
}

/* Hero button variants */
.btn-hero-light {
  background: #fff !important;
  color: var(--primary) !important;
  border-color: #fff !important;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}

.btn-hero-light:hover {
  background: #f8fafc !important;
  color: var(--primary-dark) !important;
}

.btn-hero-ghost {
  background: transparent !important;
  border-color: rgba(255,255,255,0.85) !important;
  color: #fff !important;
}

.btn-hero-ghost:hover {
  background: rgba(255,255,255,0.12) !important;
  color: #fff !important;
}

/* عدد الصور الإضافية على الكارت */
.auction-card .img-count {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}

/* معرض صور تفاصيل الإعلان */
.listing-gallery {
  position: relative;
  background: #e2e8f0;
  min-height: 320px;
}

.listing-gallery .main-img {
  width: 100%;
  height: 380px;
  object-fit: cover;
  display: block;
}

.listing-thumbs {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem;
  overflow-x: auto;
  background: #f8fafc;
  border-top: 1px solid var(--border);
}

.listing-thumbs button {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  padding: 0;
  cursor: pointer;
  background: none;
  opacity: 0.7;
  transition: opacity 0.15s, border-color 0.15s;
}

.listing-thumbs button.active,
.listing-thumbs button:hover {
  opacity: 1;
  border-color: var(--primary);
}

.listing-thumbs img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* تسريع إدراك تحميل الصور */
.auction-card {
  content-visibility: auto;
  contain-intrinsic-size: 320px;
}

.auction-card .image-wrapper {
  aspect-ratio: 4 / 3;
  height: auto;
  min-height: 0;
  background:
    linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

.auction-card .image-wrapper img {
  position: relative;
  z-index: 1;
  background: #e2e8f0;
}

.auction-card .image-wrapper.no-img,
.auction-card .image-wrapper.no-img {
  animation: none;
  background: linear-gradient(135deg, #e2e8f0, #f8fafc);
}

.auction-card .image-wrapper.no-img::after {
  content: 'بدون صورة';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 500;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* أوقف الـ shimmer بعد تحميل الصورة */
.auction-card .image-wrapper:has(img[complete]),
.auction-card .image-wrapper:has(img) {
  animation: none;
  background: #e2e8f0;
}

/* شارة الرسائل — تظهر فقط عند وجود غير مقروء */
.messages-badge,
[data-msg-badge] {
  display: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-inline-start: 0.35rem;
  border-radius: 999px;
  background: #dc2626;
  color: #fff !important;
  font-size: 0.68rem;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  line-height: 1;
  vertical-align: middle;
}
a[href="messages.html"] {
  display: inline-flex;
  align-items: center;
}

/* تقييم النجوم */
.rating-stars {
  color: #f59e0b;
  letter-spacing: 0.05em;
  font-size: 1rem;
}
.rating-meta {
  color: #64748b;
  font-size: 0.85rem;
  font-weight: 500;
}
.rating-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin: 1rem 0;
}
.rating-box h3 {
  font-size: 0.95rem;
  margin-bottom: 0.6rem;
  color: #0f172a;
}
.rate-stars-input {
  display: flex;
  gap: 0.35rem;
  direction: ltr;
  justify-content: flex-end;
  margin: 0.5rem 0;
}
.rate-stars-input button {
  background: none;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: #cbd5e1;
  padding: 0;
  line-height: 1;
}
.rate-stars-input button.on {
  color: #f59e0b;
}
.rate-stars-input button:hover {
  transform: scale(1.1);
}
.auction-card .rating-line {
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
}
