/* CSS Reset & Variable Definitions */
:root {
  /* Light Theme Variables (Default) */
  --primary: hsl(38, 95%, 50%);       /* Golden Sand */
  --primary-hover: hsl(38, 95%, 42%);
  --secondary: hsl(207, 85%, 45%);     /* Deep Sea Blue */
  --secondary-hover: hsl(207, 85%, 38%);
  
  --bg-color: hsl(210, 30%, 98%);
  --surface-color: hsl(0, 0%, 100%);
  --border-color: hsl(210, 20%, 90%);
  
  --text-primary: hsl(210, 30%, 15%);
  --text-muted: hsl(210, 15%, 48%);
  --text-on-primary: hsl(0, 0%, 100%);
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 10px 20px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.08);
  
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  
  --transition-fast: 0.2s ease;
  --transition-normal: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  
  --glass-bg: rgba(255, 255, 255, 0.75);
  --glass-border: rgba(255, 255, 255, 0.4);
}

/* Dark Theme Variables */
body.dark-theme {
  --bg-color: hsl(210, 24%, 7%);
  --surface-color: hsl(210, 24%, 12%);
  --border-color: hsl(210, 20%, 18%);
  
  --text-primary: hsl(210, 20%, 95%);
  --text-muted: hsl(210, 10%, 65%);
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 10px 25px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 45px rgba(0, 0, 0, 0.45);
  
  --glass-bg: rgba(20, 26, 38, 0.8);
  --glass-border: rgba(255, 255, 255, 0.05);
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

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

ul {
  list-style: none;
}

.container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Header Styles */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
  transition: background var(--transition-normal), border var(--transition-normal);
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 80px;
  gap: 20px;
}

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

.logo-icon {
  font-size: 2.2rem;
  animation: pulse 2s infinite ease-in-out;
}

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

.logo-slogan {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Search Bar Styles */
.search-bar-container {
  flex: 1;
  max-width: 500px;
}

.search-form {
  display: flex;
  background: var(--surface-color);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 4px 6px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-form:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(255, 179, 0, 0.15);
}

.search-form input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 16px;
  font-size: 0.95rem;
  color: var(--text-primary);
  outline: none;
}

.btn-search {
  background: var(--primary);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.btn-search:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Theme Toggle Button */
.btn-theme {
  background: var(--border-color);
  border: none;
  font-size: 1.2rem;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.btn-theme:hover {
  background: var(--primary);
  transform: rotate(15deg);
}

/* Button styles */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #ffa000);
  color: #fff;
  border: none;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
  box-shadow: 0 4px 12px rgba(255, 160, 0, 0.2);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 160, 0, 0.35);
}

.btn-secondary {
  background: var(--border-color);
  color: var(--text-primary);
  border: none;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

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

.btn-link {
  background: none;
  border: none;
  color: var(--secondary);
  font-weight: 600;
  cursor: pointer;
  transition: color var(--transition-fast);
  margin-top: 10px;
}

.btn-link:hover {
  color: var(--secondary-hover);
  text-decoration: underline;
}

/* Category Navigation Bar */
.categories-bar {
  background: var(--surface-color);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 0;
  overflow-x: auto;
  white-space: nowrap;
}

.categories-nav::-webkit-scrollbar {
  display: none; /* Hide scrollbar for clean view */
}

.categories-nav {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

.categories-nav ul {
  display: flex;
  justify-content: flex-start;
  gap: 12px;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: var(--radius-lg);
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.9rem;
  font-weight: 700;
}

.category-item:hover, .category-item.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: scale(1.03);
}

.cat-icon {
  font-size: 1.15rem;
}

/* Main Layout Grid */
.main-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 32px;
  margin-top: 32px;
  margin-bottom: 64px;
}

/* Sidebar Styles */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

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

.card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 8px;
  display: inline-block;
}

.filter-group {
  margin-bottom: 18px;
}

.filter-group label {
  display: block;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.filter-group select {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  outline: none;
  font-weight: 600;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

.radio-label input {
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
}

/* Commission calculator style */
.commission-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.calc-group input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  outline: none;
  margin-bottom: 16px;
  font-size: 1rem;
}

.calc-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-color);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}

.calc-result strong {
  font-size: 1.4rem;
  color: var(--primary);
  font-weight: 800;
}

/* Mobile App Banner Link */
.app-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.btn-app {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  transition: all var(--transition-fast);
}

.btn-app:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-2px);
}

/* Content Area / Ads Feed */
.content-area {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.listings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
}

.listings-header h2 {
  font-size: 1.3rem;
  font-weight: 800;
}

#listings-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--border-color);
  padding: 4px 12px;
  border-radius: var(--radius-lg);
}

/* Loader Styles */
.loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
  gap: 16px;
  color: var(--text-muted);
  grid-column: 1 / -1;
}

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

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

.ad-card {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.ad-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
}

.ad-img-wrapper {
  position: relative;
  height: 180px;
  background: #eaeaea;
  overflow: hidden;
}

.ad-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-normal);
}

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

.badge-type {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  backdrop-filter: blur(4px);
}

.badge-type.sale {
  background: rgba(46, 125, 50, 0.9); /* green */
}

.badge-type.wanted {
  background: rgba(21, 101, 192, 0.9); /* blue */
}

.ad-details {
  padding: 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.ad-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.ad-title {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 12px;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 2.7rem;
}

.ad-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
}

.ad-price {
  font-weight: 800;
  color: var(--primary);
  font-size: 1.1rem;
}

.ad-price.negotiable {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.ad-location {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}





/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 16px;
  animation: fadeIn 0.3s ease;
}

.modal.active {
  display: flex;
}
.modal-content {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  max-width: 950px; /* تم رفع العرض من 600px إلى 950px ليصبح عريضاً ومريحاً */
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 28px;
}


.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 14px;
}

.modal-header h2 {
  font-size: 1.3rem;
  font-weight: 800;
}

.close-btn {
  font-size: 2rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: color var(--transition-fast);
  line-height: 1;
}

.close-btn:hover {
  color: var(--primary);
}

/* Forms */
.form-group {
  margin-bottom: 18px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group label {
  display: block;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  outline: none;
  font-size: 0.95rem;
  transition: border-color var(--transition-fast);
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
}

.btn-block {
  width: 100%;
  justify-content: center;
  padding: 14px;
  font-size: 1rem;
}

/* Auth Modal Specifics */
.auth-modal-content {
  max-width: 420px;
}

.auth-tabs {
  display: flex;
  gap: 16px;
}

.auth-tab {
  background: none;
  border: none;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-muted);
  cursor: pointer;
  padding-bottom: 6px;
  border-bottom: 3px solid transparent;
}

.auth-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--primary);
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

/* Detail Modal Specifics */
.detail-modal-content {
  max-width: 700px;
  padding: 0;
  overflow: hidden;
}

.detail-modal-content .modal-header {
  padding: 20px 24px 10px;
  margin-bottom: 0;
}

.detail-body {
  padding: 24px;
  max-height: 75vh;
  overflow-y: auto;
}

.detail-image-container {
  position: relative;
  height: 320px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #f0f0f0;
  margin-bottom: 24px;
}

.detail-image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.badge {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--primary);
  color: #fff;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-weight: 700;
}

.detail-info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.info-item {
  display: flex;
  justify-content: space-between;
  background: var(--bg-color);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.info-item span {
  color: var(--text-muted);
  font-weight: 600;
}

.info-item strong {
  font-weight: 700;
}

.text-primary {
  color: var(--primary);
}

hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 20px 0;
}

.detail-description h3 {
  font-size: 1.1rem;
  margin-bottom: 12px;
  font-weight: 800;
}

.detail-description p {
  color: var(--text-primary);
  white-space: pre-line;
  font-size: 0.95rem;
  line-height: 1.7;
}

.detail-contact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--bg-color);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

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

.author-info .avatar {
  font-size: 2rem;
  background: var(--border-color);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.author-info h4 {
  font-size: 1rem;
  font-weight: 700;
}

.author-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

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

.btn-contact {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  transition: transform var(--transition-fast);
}

.btn-contact:hover {
  transform: translateY(-2px);
}

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

.btn-contact.whatsapp {
  background: #25d366;
  color: #fff;
}

/* Footer */
.footer {
  background: var(--surface-color);
  border-top: 1px solid var(--border-color);
  padding: 48px 0 24px;
  margin-top: auto;
}

.footer-container {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 64px;
}

.footer-info h3 {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 16px;
  color: var(--primary);
}

.footer-info p {
  color: var(--text-muted);
  max-width: 500px;
  font-size: 0.9rem;
}

.footer-links h4 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.footer-links ul {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.footer-links a {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  transition: color var(--transition-fast);
}

.footer-links a:hover {
  color: var(--primary);
}

.footer-bottom {
  text-align: center;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

/* Animations */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Responsive Media Queries */
@media (max-width: 1024px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    order: 2;
  }
  
  .content-area {
    order: 1;
  }
}

@media (max-width: 768px) {
  .header-container {
    height: auto;
    padding: 16px 0;
    flex-direction: column;
    gap: 16px;
  }
  
  .search-bar-container {
    width: 100%;
    max-width: none;
  }
  
  .header-actions {
    width: 100%;
    justify-content: space-between;
  }
  
  .footer-container {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  
  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
  
  .detail-info-grid {
    grid-template-columns: 1fr;
  }
}

/* SQL Console Drawer Styles */
.sql-console-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 380px;
  background: hsl(210, 24%, 10%);
  color: #fff;
  border-top: 3px solid var(--primary);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.4);
  z-index: 999;
  display: none; /* Hidden by default for visitors */
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  direction: ltr; /* Set code parts to LTR */
  text-align: left;
}

.sql-console-drawer.active {
  transform: translateY(0);
}

.sql-console-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: hsl(210, 24%, 6%);
  padding: 10px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  direction: rtl; /* Header text in Arabic */
  text-align: right;
}

.sql-console-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
}

.sql-console-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.sql-console-actions .btn-secondary {
  padding: 4px 12px;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sql-console-actions .btn-secondary:hover {
  background: var(--primary);
}

.sql-console-actions .btn-theme {
  width: 28px;
  height: 28px;
  font-size: 0.8rem;
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.sql-console-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 1;
  overflow: hidden;
  background: hsl(210, 24%, 9%);
}

.sql-query-runner {
  padding: 16px 24px;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 10px;
  direction: rtl;
  text-align: right;
}

.sql-query-runner label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #aaa;
}

.runner-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sql-query-runner textarea {
  width: 100%;
  background: hsl(210, 24%, 4%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  color: #00ff66;
  font-family: 'Courier New', Courier, monospace;
  padding: 12px;
  font-size: 0.9rem;
  resize: none;
  outline: none;
  direction: ltr;
  text-align: left;
}

.sql-query-runner textarea:focus {
  border-color: var(--primary);
}

.custom-sql-result {
  flex: 1;
  overflow-y: auto;
  background: hsl(210, 24%, 4%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: monospace;
  font-size: 0.8rem;
  color: #ddd;
  direction: ltr;
  text-align: left;
}

.sql-table-result {
  width: 100%;
  border-collapse: collapse;
}

.sql-table-result th, .sql-table-result td {
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 6px 8px;
  text-align: left;
}

.sql-table-result th {
  background: rgba(255, 255, 255, 0.08);
  color: var(--primary);
}

.sql-log-section {
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  direction: rtl;
  text-align: right;
}

.sql-log-section h4 {
  font-size: 0.85rem;
  font-weight: 700;
  color: #aaa;
}

.sql-log-container {
  flex: 1;
  background: hsl(210, 24%, 4%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  direction: ltr;
  text-align: left;
}

.sql-log-entry {
  border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
  padding-bottom: 6px;
}

.sql-log-query {
  color: #00ff66;
  font-weight: bold;
}

.sql-log-info {
  color: #ffcc00;
  margin-top: 2px;
}

/* Floating SQL button */
.floating-sql-btn {
  position: fixed;
  bottom: 24px;
  left: 24px;
  background: linear-gradient(135deg, var(--secondary), #1d4ed8);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: var(--radius-lg);
  font-weight: 700;
  cursor: pointer;
  z-index: 998;
  box-shadow: 0 4px 15px rgba(29, 78, 216, 0.4);
  transition: all var(--transition-fast);
  display: none; /* Hidden by default for visitors */
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.floating-sql-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(29, 78, 216, 0.6);
}

@media (max-width: 768px) {
  .sql-console-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .sql-console-drawer {
    height: 80vh;
  }
}

/* ==========================================================================
   صندوق الرسائل الخاصة والاتصال (Messages Inbox & Conversations)
   ========================================================================== */
.messages-modal-content {
  max-width: 850px;
  width: 95%;
  padding: 0;
  overflow: hidden;
}

.messages-modal-content .modal-header {
  padding: 20px 24px 10px;
  margin-bottom: 0;
}

.messages-body {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 60vh;
  min-height: 450px;
  background: var(--surface-color);
}

.messages-sidebar {
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  background: var(--bg-color);
  overflow-y: auto;
}

.messages-sidebar h3 {
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border-color);
  margin: 0;
}

.conversations-list {
  flex: 1;
  overflow-y: auto;
}

.conversation-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conversation-item:hover, .conversation-item.active {
  background: var(--surface-color);
}

.conversation-item.active {
  border-right: 4px solid var(--primary);
}

.conv-partner {
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-primary);
}

.conv-unread-dot {
  width: 8px;
  height: 8px;
  background-color: var(--primary);
  border-radius: 50%;
  display: inline-block;
}

.conv-ad-title {
  font-size: 0.75rem;
  color: var(--secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.conv-last-msg {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.messages-chat-area {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--surface-color);
}

.chat-header h4 {
  font-size: 1rem;
  font-weight: 700;
}

.chat-ad-title {
  font-size: 0.8rem;
  color: var(--secondary);
  font-weight: 600;
}

.chat-history {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: var(--bg-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-placeholder {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  gap: 12px;
}

.chat-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-bubble.sent {
  align-self: flex-start;
  background: var(--secondary);
  color: #fff;
  border-top-right-radius: 2px;
}

.chat-bubble.received {
  align-self: flex-end;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-top-left-radius: 2px;
}

.chat-bubble .time {
  font-size: 0.7rem;
  align-self: flex-end;
  opacity: 0.7;
}

.chat-send-form {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--surface-color);
}

.chat-send-form textarea {
  flex: 1;
  height: 44px;
  resize: none;
  padding: 10px 14px;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  outline: none;
  background: var(--bg-color);
  color: var(--text-primary);
}

.chat-send-form textarea:focus {
  border-color: var(--primary);
}

.chat-send-form button {
  height: 44px;
  white-space: nowrap;
}

/* زر صندوق الرسائل والتنبيه */
.user-pill-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-inbox-trigger {
  background: var(--border-color);
  border: none;
  font-size: 1.2rem;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  position: relative;
}

.btn-inbox-trigger:hover {
  background: var(--secondary);
  color: #fff;
}

.inbox-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #f44336;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(244, 67, 54, 0.4);
}

/* زر إعدادات الموقع للإدارة */
.btn-admin-settings {
  background: var(--border-color);
  border: none;
  font-size: 1.2rem;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-admin-settings:hover {
  background: var(--primary);
  color: #fff;
  transform: rotate(45deg);
}

.settings-modal-content {
  max-width: 550px;
}

@media (max-width: 768px) {
  .messages-body {
    grid-template-columns: 1fr;
    height: 70vh;
  }
  .messages-sidebar {
    height: 150px;
    border-left: none;
    border-bottom: 1px solid var(--border-color);
  }
}







/* 1. إخفاء زر "كل الإعلانات" الأصفر من الشريط العلوي نهائياً */
#categories-list .category-item[data-id=""], 
#categories-list li:first-child {
    display: none !important;
}

/* 2. إخفاء شريط التمرير الأبيض المشوه من شريط الأقسام على الكمبيوتر مع بقاء ميزة السحب */
.categories-bar {
    overflow-x: auto;
    white-space: nowrap;
    -ms-overflow-style: none;  /* لمتصفحات إيدج القديمة */
    scrollbar-width: none;  /* لمتصفح فايرفوكس */
}

/* إخفاء شريط التمرير لمتصفحات جوجل كروم، سفاري، وإيدج الحديث */
.categories-bar::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

/* توسيع أبعاد النافذة المنبثقة للإعلانات */
.modal-content, [class*="modal-dialog"], .popup-box {
    width: 90% !important;        /* تجعل النافذة مرنة وتأخذ معظم عرض الشاشة على الجوال */
    max-width: 950px !important;  /* ترفع الحد الأقصى للعرض على الكمبيوتر (بدلاً من 500px أو 600px القديمة) */
    border-radius: 16px !important; /* حواف دائرية ناعمة وحديثة تتناسب مع شكل أزرارك */
    transition: all 0.3s ease;
}






/* كود قوي لإجبار أي صورة داخل تفاصيل الإعلان المنبثق على التصغير والتوسيط */
.modal-content div img, 
.modal-content picture img,
.modal-content img {
    width: auto !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 280px !important; /* تقليل الارتفاع لتبدو الصورة ملمومة */
    margin: 0 auto 20px auto !important;
    display: block !important;
    object-fit: contain !important; /* منع المط والقص نهائياً */
    border-radius: 12px !important;
    cursor: zoom-in !important;
    background-color: #fafafa !important;
}

/* التأكد من أن صندوق الحاوية المحيط بالصورة لا يجبرها على التمدد */
.modal-content .image-container,
.modal-content [class*="image"],
.modal-content [class*="img-wrap"] {
    width: 100% !important;
    max-height: 280px !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    background: transparent !important;
    overflow: hidden !important;
}


/* كود إجبار صورة الإعلان المنبثق على التصغير والتوسيط */
.modal-content img {
    width: auto !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 280px !important;
    margin: 0 auto 20px auto !important;
    display: block !important;
    object-fit: contain !important;
    border-radius: 12px !important;
}
