@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@200;300;400;500;600;700;800&display=swap');

:root {
  --primary-color: #1B6B3A;
  --primary-hover: #14522c;
  --secondary-color: #D4AF37;
  --bg-color: #F5F5F0;
  --card-bg: #ffffff;
  --text-main: #1a1a1a;
  --text-muted: #737373;
  --border-color: #E0E0DC;
  --danger: #CE1126;
  --success: #1B6B3A;
  --muted-bg: #F0F0EC;
  --surface-secondary: #F8F8F4;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.07);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Cairo', sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  direction: rtl;
  min-height: 100vh;
  line-height: 1.5;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header & Navigation */
header {
  background-color: var(--primary-color);
  color: white;
  padding: 1.2rem 0 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.nav-shell {
  display: grid;
  align-items: center;
  gap: 1rem;
  grid-template-columns: minmax(320px, 1fr) minmax(380px, 620px) auto;
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.search-bar {
  width: 100%;
  display: flex;
  position: relative;
  justify-self: center;
}

.search-bar input {
  width: 100%;
  height: 44px;
  padding: 0 1rem;
  padding-right: 3rem;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.96);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.3s ease;
  color: var(--text-main);
}

.search-bar input:focus {
  background: white;
  border-color: rgba(212, 175, 55, 0.45);
  box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.18);
}

.search-icon {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.nav-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  flex-wrap: wrap;
}

.nav-actions a {
  color: white;
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.2s, background-color 0.2s, border-color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 36px;
  padding: 0 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.92rem;
}

.nav-actions a:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.16);
}

.nav-actions a.btn-post {
  background: var(--secondary-color) !important;
  color: var(--primary-color) !important;
  padding: 0 1.15rem !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(212, 175, 55, 0.95) !important;
  font-weight: 800 !important;
  opacity: 1 !important;
}

.nav-actions a.btn-post:visited,
.nav-actions a.btn-post:hover,
.nav-actions a.btn-post:focus,
.nav-actions a.btn-post:focus-visible,
.nav-actions a.btn-post:active {
  background: var(--secondary-color) !important;
  color: var(--primary-color) !important;
  border-color: rgba(212, 175, 55, 0.95) !important;
  opacity: 1 !important;
}

.btn-post i,
.btn-post span {
  color: inherit !important;
}

.nav-actions a.btn-post:hover {
  background: var(--secondary-color) !important;
  border-color: rgba(212, 175, 55, 0.95) !important;
  color: var(--primary-color) !important;
}

.profile-icon {
  font-weight: 700;
}

.download-app {
  background: #fff;
  padding: 4rem 1rem;
  text-align: center;
  border-top: 1px solid var(--border-color);
}

.download-app-title {
  margin-bottom: 1rem;
  color: var(--primary-color);
}

.download-app-text {
  margin-bottom: 2rem;
  color: var(--text-muted);
}

.store-badges {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.store-badge {
  min-width: 212px;
  background: #101010;
  color: #fff;
  border-radius: 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  padding: 0.9rem 1.35rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.store-badge:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.12);
  opacity: 1;
}

.store-badge-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  flex-shrink: 0;
}

.store-badge-icon svg {
  width: 24px;
  height: 24px;
  display: block;
}

.store-badge-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  line-height: 1.1;
}

.store-badge-copy small {
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  opacity: 0.82;
}

.store-badge-copy strong {
  font-size: 1.15rem;
  font-weight: 800;
}

.messages-modal-content {
  max-width: 620px;
}

.messages-page-content {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  border-radius: 0;
  padding: 2rem 2rem 1.5rem;
  margin: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

#messagesModal {
  padding: 0;
  background: rgba(245, 245, 240, 0.98);
  backdrop-filter: none;
}

.messages-header {
  margin-bottom: 1.25rem;
  padding-left: 3rem;
}

.messages-header h2 {
  color: var(--primary-color);
  margin-bottom: 0.4rem;
}

.messages-header p {
  color: var(--text-muted);
}

.messages-empty-state {
  text-align: center;
  padding: 2rem 1rem 1rem;
}

.messages-empty-icon {
  font-size: 3rem;
  color: var(--primary-color);
  margin-bottom: 1rem;
}

.messages-empty-state h3 {
  margin-bottom: 0.6rem;
}

.messages-empty-state p {
  color: var(--text-muted);
  max-width: 420px;
  margin: 0 auto 1.25rem;
  line-height: 1.8;
}

.messages-list {
  display: grid;
  gap: 1rem;
  align-content: start;
  overflow-y: auto;
}

.messages-warning-banner {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.9rem;
  align-items: start;
  border: 1px solid #f7d9a6;
  background: #fff7e6;
  border-radius: 16px;
  padding: 1rem 1.1rem;
  margin-bottom: 1.2rem;
}

.messages-warning-icon {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: rgba(212, 175, 55, 0.18);
  color: #a56d00;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.messages-warning-text {
  display: grid;
  gap: 0.2rem;
}

.messages-warning-text strong {
  color: #a56d00;
  font-size: 1rem;
}

.messages-warning-text p {
  color: #7c5a17;
  line-height: 1.8;
}

.post-modal-content {
  max-width: 720px;
}

.post-form {
  display: grid;
  gap: 1rem;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.post-field {
  display: grid;
  gap: 0.55rem;
}

.post-textarea {
  min-height: 150px;
  resize: vertical;
  line-height: 1.8;
}

.post-file-input {
  padding: 0.75rem;
  background: #fff;
}

.post-image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.75rem;
}

.post-image-preview-grid:not(.hidden) {
  border: 1px solid var(--border-color);
  border-radius: 16px;
  background: #f8fafc;
  padding: 0.75rem;
}

.post-image-thumb {
  border-radius: 12px;
  overflow: hidden;
  background: white;
  border: 1px solid #e5edf8;
}

.post-image-thumb img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
}

.post-upload-hint {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.post-rules {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 16px;
  padding: 1rem 1.1rem;
}

.post-rules h3 {
  color: #c2410c;
  margin-bottom: 0.35rem;
}

.post-rules p {
  color: #9a3412;
  margin-bottom: 0.6rem;
}

.post-rules ul {
  margin: 0;
  padding-right: 1.2rem;
  color: #7c2d12;
  line-height: 1.9;
}

.post-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.message-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--card-bg);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.message-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.message-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.45rem;
}

.message-card-head strong {
  color: var(--text-main);
}

.message-card-head span,
.message-card p {
  color: var(--text-muted);
}

.message-card-thread {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.9rem;
  align-items: center;
}

.message-avatar {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: rgba(27, 107, 58, 0.12);
  color: var(--primary-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.message-thread-body {
  display: grid;
  gap: 0.25rem;
}

.message-thread-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.message-thread-title {
  font-weight: 700;
  font-size: 0.96rem;
  color: var(--text-main);
}

.message-thread-time {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.message-thread-listing {
  font-size: 0.8rem;
  color: var(--primary-color);
}

.message-thread-preview {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.message-unread-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--secondary-color);
}

.chat-view {
  display: grid;
  gap: 1rem;
  align-content: start;
  min-height: 0;
  grid-template-rows: auto auto 1fr auto;
  height: 100%;
}

.chat-back-btn {
  justify-self: start;
  padding: 0;
}

.chat-thread-head h3 {
  color: var(--primary-color);
  margin-bottom: 0.3rem;
}

.chat-thread-head p {
  color: var(--text-muted);
}

.chat-messages {
  display: grid;
  gap: 0.8rem;
  max-height: none;
  min-height: 0;
  overflow-y: auto;
  padding-left: 0.2rem;
  align-content: start;
}

.chat-bubble {
  max-width: 85%;
  padding: 0.9rem 1rem;
  border-radius: 18px;
  line-height: 1.7;
}

.chat-bubble.peer {
  background: #f1f5f9;
  color: var(--text-main);
  justify-self: end;
}

.chat-bubble.mine {
  background: var(--primary-color);
  color: white;
  justify-self: start;
}

.chat-bubble img {
  width: 100%;
  max-width: 260px;
  border-radius: 12px;
  display: block;
}

.chat-bubble audio {
  width: min(280px, 100%);
}

.chat-form {
  display: grid;
  gap: 0.75rem;
  align-self: end;
  position: sticky;
  bottom: 0;
  background: var(--bg-color);
  padding-top: 0.75rem;
}

.chat-tools,
.chat-compose {
  display: grid;
  gap: 0.75rem;
}

.chat-tools {
  grid-template-columns: repeat(2, auto);
  justify-content: start;
}

.chat-compose {
  grid-template-columns: 1fr auto;
}

.chat-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--border-color);
  background: #fbfcfd;
  color: var(--text-main);
  border-radius: 14px;
  padding: 0.8rem 1rem;
  cursor: pointer;
  font-weight: 700;
}

.chat-tool-btn.recording {
  color: white;
  background: var(--danger);
  border-color: var(--danger);
}

.chat-status {
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Categories Bar */
.categories-bar {
  background: transparent;
  border-bottom: none;
  padding: 1rem 0 0.4rem;
  overflow-x: auto;
  white-space: nowrap;
}

.categories-list {
  display: flex;
  gap: 0.65rem;
  justify-content: flex-start;
  min-width: max-content;
}

.category-item {
  color: var(--text-main);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.78rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: color 0.2s, background 0.2s, transform 0.2s, border-color 0.2s;
  min-width: 72px;
  min-height: 74px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 0.5rem;
  box-shadow: var(--shadow-sm);
}

.category-item:hover, .category-item.active {
  color: var(--primary-color);
  background: #f8faf4;
  border-color: rgba(27, 107, 58, 0.2);
  transform: translateY(-1px);
}

.category-item i {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(27, 107, 58, 0.09);
  color: var(--primary-color);
  font-size: 1rem;
}

.subcategories-bar {
  padding: 0 0 0.9rem;
  overflow-x: auto;
  white-space: nowrap;
}

.subcategories-list {
  display: flex;
  gap: 0.55rem;
  justify-content: flex-start;
  min-width: max-content;
}

.subcategory-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-main);
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.subcategory-chip:hover,
.subcategory-chip.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: #fff;
}

.listings-section {
  padding: 0.9rem 0 3rem;
}

.market-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.market-toolbar-right,
.market-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.market-toolbar-left {
  margin-right: auto;
}

.market-label {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.85rem;
}

.market-toolbar-left h2 {
  font-size: 1.15rem;
  color: var(--primary-color);
}

.toolbar-select,
.toolbar-chip {
  border: 1px solid var(--border-color);
  background: white;
  color: var(--text-muted);
  border-radius: var(--radius);
  min-height: 44px;
  padding: 0 1rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.toolbar-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  cursor: pointer;
}

.toolbar-chip.active {
  background: rgba(27, 107, 58, 0.08);
  color: var(--primary-color);
  border-color: rgba(27, 107, 58, 0.2);
}

.listings-feed {
  display: grid;
  gap: 0.9rem;
}

.listing-page {
  display: grid;
  gap: 1rem;
}

.listing-back-btn {
  justify-self: start;
  padding: 0;
}

.listing-page-shell {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 1.25rem;
  display: grid;
  gap: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  border: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: 140px 1fr;
  align-items: stretch;
  min-height: 158px;
}

.card.card-no-image {
  grid-template-columns: 1fr;
  min-height: auto;
}

.card.card-no-image .card-content {
  padding-top: 0.95rem;
}

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

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background-color: var(--muted-bg);
  display: block;
}

.card-content {
  padding: 0.9rem 1rem;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 0.45rem;
}

.card-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.card-category-chip,
.listing-category-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 0.75rem;
  border-radius: 999px;
  background: rgba(27, 107, 58, 0.08);
  color: var(--primary-color);
  font-size: 0.78rem;
  font-weight: 700;
}

.card-time {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.card-featured-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 0.55rem;
  border-radius: 8px;
  background: rgba(212, 175, 55, 0.18);
  color: #8b6a08;
  font-size: 0.72rem;
  font-weight: 700;
}

.card-price {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary-color);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.card-title {
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1.75;
}

.card-description {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.8;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-price-type {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  margin-top: 0.1rem;
}

.card-footer-right,
.card-footer-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.card-governorate {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--muted-bg);
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  color: var(--text-muted);
}

.listing-delete-btn {
  border: 1px solid #fecaca;
  background: #fff5f5;
  color: #dc2626;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
}

.profile-panel {
  display: grid;
  gap: 1rem;
}

.profile-summary {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--card-bg);
}

.profile-avatar-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  flex: 0 0 80px;
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 999px;
  background: var(--primary-color);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.5rem;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}

.profile-avatar.has-image {
  color: transparent;
}

.profile-avatar-edit {
  position: absolute;
  left: -6px;
  bottom: -6px;
  min-height: 32px;
  padding: 0 0.7rem;
  border-radius: 999px;
  background: var(--primary-color);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  border: 2px solid #fff;
  box-shadow: var(--shadow-sm);
}

.profile-summary-text {
  display: grid;
  gap: 0.2rem;
}

.profile-summary-text strong {
  font-size: 1.2rem;
}

.profile-summary-text span {
  color: var(--text-muted);
}

.profile-form {
  display: grid;
  gap: 0.75rem;
}

.profile-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.profile-stat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  background: rgba(27, 107, 58, 0.08);
  color: var(--primary-color);
  font-weight: 700;
  font-size: 0.9rem;
}

.card-seller-badge {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #d8e1f4;
  color: #6d7e9e;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

.card-seller-badge.has-image {
  color: transparent;
}

.details-actions-bar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: var(--surface-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 1.25rem;
}

.details-action-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  min-height: 48px;
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  cursor: pointer;
  padding: 0 0.75rem;
  text-decoration: none;
}

.details-action-btn + .details-action-btn {
  border-right: 1px solid var(--border-color);
}

.details-action-btn.active {
  color: var(--primary-color);
  background: rgba(27, 107, 58, 0.08);
}

.listing-page-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 1.5rem;
}

.listing-page-grid--single {
  grid-template-columns: 1fr;
}

.modal-info {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.listing-gallery {
  display: grid;
  gap: 0.8rem;
  align-content: start;
  justify-items: center;
}

.listing-main-image {
  width: 100%;
  border-radius: 16px;
  height: 520px;
  object-fit: contain;
  object-position: center;
  background: var(--muted-bg);
  cursor: zoom-in;
}

.listing-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.6rem;
  width: 100%;
}

.listing-thumb {
  width: 100%;
  height: 110px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--muted-bg);
  cursor: zoom-in;
}

.listing-meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.listing-time {
  color: var(--text-muted);
  font-size: 0.84rem;
}

.listing-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.8rem;
  line-height: 1.5;
}

.listing-price {
  font-size: 2rem;
  color: var(--primary-color);
  font-weight: 800;
  margin-bottom: 1rem;
}

.listing-quick-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.listing-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 34px;
  padding: 0 0.75rem;
  background: var(--muted-bg);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.listing-info-card,
.listing-seller-card {
  background: var(--surface-secondary);
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
}

.listing-info-card {
  margin-bottom: 1rem;
}

.listing-info-card h4,
.listing-seller-card h4 {
  margin-bottom: 0.45rem;
  color: var(--text-main);
  font-size: 1rem;
}

.listing-info-card p,
.listing-seller-card p {
  color: var(--text-muted);
  line-height: 1.85;
}

.listing-seller-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.4rem;
}

.listing-seller-avatar {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: rgba(27, 107, 58, 0.12);
  color: var(--primary-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  background-size: cover;
  background-position: center;
}

.listing-seller-avatar.has-image {
  color: transparent;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.modal-content {
  background: white;
  width: 100%;
  max-width: 800px;
  border-radius: 20px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  padding: 2rem;
  box-shadow: var(--shadow-md);
}

.auth-modal-content {
  max-width: 520px;
  padding: 0;
  overflow: hidden;
}

.auth-shell {
  padding: 2rem;
}

.auth-hero {
  background: linear-gradient(135deg, var(--primary-color) 0%, #134e2b 100%);
  color: white;
  margin: -2rem -2rem 1.5rem;
  padding: 2rem;
}

.auth-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.14);
  color: var(--secondary-color);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.auth-hero h2 {
  font-size: 1.9rem;
  margin-bottom: 0.5rem;
}

.auth-hero p {
  color: rgba(255, 255, 255, 0.84);
  line-height: 1.8;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.auth-tab {
  padding: 0.6rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-family: 'Cairo', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab.active {
  border-color: var(--primary-color);
  background: var(--primary-color);
  color: #fff;
}

.auth-step {
  display: grid;
  gap: 0.9rem;
}

.hidden {
  display: none !important;
}

.auth-label {
  color: var(--text-main);
  font-weight: 700;
}

.auth-input-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.auth-prefix {
  min-width: 72px;
  text-align: center;
  padding: 0.95rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 700;
}

.auth-input {
  width: 100%;
  padding: 0.95rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(27, 107, 58, 0.12);
}

.auth-input-center {
  text-align: center;
  letter-spacing: 0.6rem;
  font-size: 1.5rem;
  font-weight: 700;
}

.auth-btn,
.auth-link-btn {
  border: none;
  border-radius: var(--radius);
  padding: 0.95rem 1.2rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.auth-btn {
  background: var(--primary-color);
  color: white;
}

.auth-btn:hover {
  background: var(--primary-hover);
}

.auth-link-btn {
  background: transparent;
  color: var(--primary-color);
}

.auth-link-btn.danger {
  color: var(--danger);
}

.auth-code-box {
  background: rgba(212, 175, 55, 0.14);
  border: 1px solid rgba(212, 175, 55, 0.45);
  border-radius: 16px;
  padding: 1rem;
  text-align: center;
  color: var(--text-main);
}

.auth-code-box strong {
  display: block;
  font-size: 2rem;
  letter-spacing: 0.7rem;
  color: var(--primary-color);
  margin-top: 0.4rem;
}

.auth-note {
  color: var(--text-muted);
  line-height: 1.8;
}

.auth-otp-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.otp-boxes {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  direction: ltr;
  margin: 1.25rem 0;
}

.otp-box {
  width: 58px;
  height: 62px;
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  background: var(--muted-bg);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.otp-box:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(26,92,56,0.15);
  background: white;
}

.otp-box.filled {
  border-color: var(--primary-color);
  background: #f0fdf4;
}

.auth-error {
  margin-top: 1rem;
  color: var(--danger);
  font-weight: 700;
  text-align: center;
}

.auth-success {
  text-align: center;
}

.auth-success-icon {
  font-size: 3rem;
  color: var(--success);
}

.auth-success h3 {
  font-size: 1.5rem;
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
}

.auth-success p {
  color: var(--text-muted);
}

.auth-success-actions {
  display: grid;
  gap: 0.6rem;
  margin-top: 1rem;
}

.agreement-modal-content {
  max-width: 760px;
}

.agreement-shell {
  display: grid;
  gap: 1rem;
}

.agreement-basmalah {
  text-align: right;
  color: var(--text-main);
  font-size: 1.45rem;
  font-weight: 700;
}

.agreement-verse,
.agreement-verse-note {
  text-align: center;
  color: #7d869a;
}

.agreement-verse {
  font-size: 1.1rem;
  line-height: 2;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

.agreement-verse-note {
  font-weight: 700;
}

.agreement-card {
  display: grid;
  gap: 1rem;
  padding: 1.2rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  background: #fff;
}

.agreement-check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.9;
}

.agreement-check-row input {
  width: 24px;
  height: 24px;
  margin-top: 0.15rem;
  accent-color: var(--primary-color);
}

.agreement-line {
  color: var(--text-main);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.9;
}

.agreement-required {
  color: #d14a2e;
  font-size: 0.98rem;
  font-weight: 800;
}

.agreement-note {
  text-align: right;
  padding: 0.5rem 0 0;
}

.agreement-note h3 {
  color: #2f8a14;
  margin-bottom: 0.4rem;
  font-size: 1.1rem;
}

.agreement-note p {
  color: #54810c;
  line-height: 1.9;
  font-size: 1rem;
}

.agreement-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.image-lightbox-shell {
  position: relative;
  width: min(96vw, 1180px);
  height: min(92vh, 900px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-lightbox-target {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  background: rgba(255, 255, 255, 0.04);
}

.image-lightbox-close {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.close-btn {
  position: absolute;
  top: 1rem;
  left: 1.5rem;
  font-size: 2rem;
  cursor: pointer;
  color: var(--text-muted);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  animation: fadeIn 0.5s ease backwards;
}

/* RTL Helpers */
.ml-2 { margin-left: 0.5rem; }
.mr-2 { margin-right: 0.5rem; }

/* Responsive */
@media (max-width: 768px) {

  /* ── Header ── */
  header {
    padding: 0.5rem 0 0.4rem;
  }

  .nav-shell {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
  }

  /* Row 1: logo on left, nav buttons on right */
  .nav-shell {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
  }

  .nav-shell .logo {
    order: -1;
    font-size: 1.15rem;
  }

  .nav-actions {
    order: 0;
    gap: 0.35rem;
    justify-content: flex-end;
    flex-wrap: nowrap;
    flex-shrink: 0;
  }

  .search-bar {
    flex: 0 0 100%;
    order: 1;
    max-width: none;
    margin-top: 0.2rem;
  }

  .search-bar input {
    height: 32px;
    font-size: 0.82rem;
    padding: 0 0.75rem;
    padding-right: 2.5rem;
  }

  /* Icon-only nav buttons on mobile */
  .nav-actions a .nav-label {
    display: none;
  }

  .nav-actions a {
    min-height: 34px;
    min-width: 34px;
    padding: 0 0.55rem;
    font-size: 1rem;
    gap: 0;
    border-radius: 50%;
  }

  .nav-actions a.btn-post {
    min-width: auto;
    padding: 0 0.75rem !important;
    border-radius: var(--radius) !important;
    font-size: 0.82rem !important;
  }

  /* ── Categories ── */
  .categories-bar {
    padding: 0.6rem 0 0.3rem;
  }

  .category-item {
    min-width: 64px;
    min-height: 66px;
    font-size: 0.72rem;
    padding: 0.4rem 0.3rem;
  }

  .category-item i {
    width: 34px;
    height: 34px;
    font-size: 0.88rem;
  }

  /* ── Toolbar ── */
  .market-toolbar {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    padding: 0.6rem 0;
  }

  .market-toolbar-left {
    flex: 1;
  }

  .market-toolbar-left h2 {
    font-size: 1.1rem;
  }

  .market-toolbar-right {
    display: flex;
    gap: 0.4rem;
    align-items: center;
  }

  .toolbar-select {
    width: auto;
    font-size: 0.8rem;
    padding: 0.3rem 0.5rem;
    min-height: 32px;
  }

  .toolbar-chip {
    width: auto;
    min-height: 32px;
    padding: 0 0.6rem;
    font-size: 0.8rem;
  }

  /* ── Listing Cards ── */
  .card {
    grid-template-columns: 120px 1fr;
    min-height: 130px;
  }

  .card-img {
    object-fit: cover;
  }

  .card-content {
    padding: 0.65rem 0.75rem;
    gap: 0.3rem;
  }

  .card-title {
    font-size: 0.88rem;
    line-height: 1.35;
    -webkit-line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .card-price {
    font-size: 1rem;
  }

  .card-footer {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.3rem;
    align-items: center;
  }

  .card-location,
  .card-time {
    font-size: 0.72rem;
  }

  /* ── Listing Detail Page ── */
  .listing-page-grid {
    grid-template-columns: 1fr;
  }

  .listing-main-image {
    height: 260px;
  }

  .details-actions-bar {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  /* ── Modals (full screen on mobile) ── */
  .modal {
    padding: 0;
    align-items: flex-end;
  }

  .modal-content {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 1.25rem 1rem;
    max-height: 92vh;
    overflow-y: auto;
  }

  .auth-modal-content {
    border-radius: var(--radius) var(--radius) 0 0;
  }

  .messages-modal-content {
    max-height: 96vh;
  }

  .post-modal-content {
    max-height: 96vh;
  }

  /* ── Messages / Chat ── */
  .messages-page-content {
    padding: 1rem 0.85rem;
  }

  .messages-header {
    padding-left: 2rem;
  }

  .messages-warning-banner {
    grid-template-columns: 1fr;
  }

  .chat-messages {
    max-height: 45vh;
  }

  .chat-compose {
    gap: 0.4rem;
  }

  .chat-compose .auth-btn {
    padding: 0 0.9rem;
    font-size: 0.85rem;
  }

  /* ── Post Form ── */
  .post-grid {
    grid-template-columns: 1fr;
  }

  .post-actions {
    flex-direction: column;
    align-items: stretch;
  }

  /* ── Auth Modal ── */
  .auth-shell {
    padding: 1rem;
  }

  .auth-hero {
    margin: -1rem -1rem 1rem;
    padding: 1.25rem 1rem;
  }

  /* ── Footer ── */
  footer .container > div {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
    padding: 1.5rem 0 !important;
  }

  /* ── Download section ── */
  .store-badges {
    flex-direction: column;
    align-items: center;
  }
}
