:root {
  --sand-50: #fffdf8;
  --sand-100: #f9f3e8;
  --sand-200: #f0e6d4;
  --sand-300: #e4d4b6;
  --sand-400: #d2b98e;
  --sand-500: #bfa070;
  --sand-600: #a68555;
  --sand-700: #856543;
  --sand-800: #6d4f38;
  --sand-900: #5a4131;

  --terracotta: #b56a45;
  --terracotta-light: #d48965;
  --gold: #c9a96e;
  --gold-light: #dcc094;
  --palm-green: #4a5d3f;
  --palm-green-dark: #35452c;

  --text-primary: #3d2b1f;
  --text-secondary: #7a6351;
  --text-muted: #a08d7a;
  --white: #ffffff;

  --shadow-sm: 0 2px 8px rgba(61, 43, 31, 0.06);
  --shadow-md: 0 8px 30px rgba(61, 43, 31, 0.10);
  --shadow-lg: 0 20px 50px rgba(61, 43, 31, 0.14);

  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;

  --font-heading: 'Amiri', 'Scheherazade New', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --transition: all 0.25s ease;
  --header-height: 76px;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-body);
  background: var(--sand-100);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

body[dir="rtl"] {
  direction: rtl;
}

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

a {
  color: var(--palm-green);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--terracotta);
}

/* Typography */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  color: var(--text-primary);
  margin: 0 0 0.5em;
  line-height: 1.2;
  font-weight: 700;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.65rem; }
h3 { font-size: 1.25rem; }

p {
  margin: 0 0 1em;
}

/* Floating Header */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 0.75rem 1.5rem;
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1.25rem;
  background: rgba(255, 253, 248, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(191, 160, 112, 0.22);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-primary);
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--sand-500) 100%);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  color: var(--white);
  font-family: var(--font-heading);
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(201, 169, 110, 0.3);
}

.brand-text h1 {
  font-size: 1.25rem;
  margin: 0;
  color: var(--text-primary);
}

.brand-text span {
  font-size: 0.7rem;
  color: var(--text-secondary);
  display: block;
  margin-top: -3px;
  letter-spacing: 0.3px;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.main-nav a,
.main-nav button {
  color: var(--text-primary);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.9rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}

.main-nav a:hover,
.main-nav button:hover {
  background: rgba(191, 160, 112, 0.12);
  color: var(--palm-green-dark);
}

.main-nav .btn-gold {
  background: var(--gold);
  color: var(--white);
}

.main-nav .btn-gold:hover {
  background: var(--sand-600);
  color: var(--white);
}

.language-switcher {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  margin-inline-start: 0.5rem;
  padding-inline-start: 0.75rem;
  border-inline-start: 1px solid rgba(191, 160, 112, 0.35);
}

.language-switcher a {
  font-size: 0.75rem;
  padding: 0.3rem 0.55rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 600;
}

.language-switcher a.active,
.language-switcher a:hover {
  color: var(--text-primary);
  background: rgba(191, 160, 112, 0.15);
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
}

/* Map Layout */
.map-app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

#map {
  flex: 1;
  width: 100%;
  height: 100%;
  background: var(--sand-200);
  z-index: 1;
}

/* Geometric pattern overlay */
.map-app::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0.035;
  background-image:
    linear-gradient(30deg, var(--sand-900) 12%, transparent 12.5%, transparent 87%, var(--sand-900) 87.5%, var(--sand-900)),
    linear-gradient(150deg, var(--sand-900) 12%, transparent 12.5%, transparent 87%, var(--sand-900) 87.5%, var(--sand-900)),
    linear-gradient(30deg, var(--sand-900) 12%, transparent 12.5%, transparent 87%, var(--sand-900) 87.5%, var(--sand-900)),
    linear-gradient(150deg, var(--sand-900) 12%, transparent 12.5%, transparent 87%, var(--sand-900) 87.5%, var(--sand-900)),
    linear-gradient(60deg, rgba(61,43,31,0.05) 25%, transparent 25.5%, transparent 75%, rgba(61,43,31,0.05) 75%, rgba(61,43,31,0.05)),
    linear-gradient(60deg, rgba(61,43,31,0.05) 25%, transparent 25.5%, transparent 75%, rgba(61,43,31,0.05) 75%, rgba(61,43,31,0.05));
  background-size: 80px 140px;
  background-position: 0 0, 0 0, 40px 70px, 40px 70px, 0 0, 40px 70px;
}

/* Custom markers */
.custom-marker-wrapper {
  background: transparent;
  border: none;
}

.custom-marker {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold) 0%, var(--terracotta) 100%);
  border: 3px solid var(--white);
  box-shadow: 0 4px 14px rgba(61, 43, 31, 0.25);
  display: grid;
  place-items: center;
  transition: var(--transition);
}

.custom-marker:hover {
  transform: scale(1.15);
}

.custom-marker::after {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--white);
  border-radius: 50%;
}

.marker-cluster {
  background: transparent;
}

.cluster-marker {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--palm-green);
  color: var(--white);
  border: 3px solid var(--gold-light);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 4px 14px rgba(61, 43, 31, 0.2);
}

/* Location Side Panel */
.location-panel {
  position: absolute;
  top: calc(var(--header-height) + 1rem);
  right: 1.5rem;
  width: 400px;
  max-height: calc(100vh - var(--header-height) - 2rem);
  background: var(--sand-50);
  border: 1px solid rgba(191, 160, 112, 0.22);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.35s ease, opacity 0.35s ease;
}

body[dir="rtl"] .location-panel {
  right: auto;
  left: 1.5rem;
  transform: translateX(-120%);
}

.location-panel.open {
  transform: translateX(0);
  opacity: 1;
}

.location-panel-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid rgba(191, 160, 112, 0.25);
  color: var(--text-primary);
  font-size: 1.4rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 10;
  transition: var(--transition);
}

body[dir="rtl"] .location-panel-close {
  right: auto;
  left: 0.75rem;
}

.location-panel-close:hover {
  background: var(--sand-200);
}

.location-panel-hero {
  position: relative;
  width: 100%;
  height: 220px;
  overflow: hidden;
  border-bottom: 1px solid rgba(191, 160, 112, 0.18);
  background: var(--sand-900);
}

.location-panel-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.location-panel-hero iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.location-panel-body {
  padding: 1.25rem 1.5rem 1.5rem;
  overflow-y: auto;
}

.location-panel-body h3 {
  font-size: 1.5rem;
  margin-bottom: 0.6rem;
  color: var(--text-primary);
  font-weight: 700;
}

.location-panel-coords {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.location-panel-description {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 1rem;
}

.location-panel-description.collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.location-panel-more {
  color: var(--palm-green);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}

.location-panel-more:hover {
  color: var(--terracotta);
  text-decoration: underline;
}

.location-panel-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
}

.location-panel-tag {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 0.3rem 0.6rem;
  border-radius: 100px;
  background: var(--sand-200);
  color: var(--text-secondary);
}

.location-panel-section {
  margin-bottom: 1rem;
}

.location-panel-section h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin: 0 0 0.35rem;
  font-weight: 600;
}

.location-panel-section p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 0;
}

.location-panel-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}

/* Empty state panel */
.location-panel-empty {
  text-align: center;
  padding: 2rem 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.location-panel-empty h3 {
  margin-bottom: 0.5rem;
}

.location-panel-empty p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* Ad Slot */
.ad-slot {
  flex-shrink: 0;
  max-height: 15vh;
  min-height: 90px;
  margin: 0 1.25rem 1.25rem;
  padding: 0.75rem;
  background: rgba(240, 230, 212, 0.5);
  border: 1.5px dashed var(--sand-400);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}

.ad-slot-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.ad-slot-placeholder {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.ad-slot > * {
  max-width: 100%;
  max-height: 100%;
}

/* Floating hint */
.map-hint {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  gap: 0.75rem;
  padding: 0.6rem 1.1rem;
  background: rgba(255, 253, 248, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(191, 160, 112, 0.22);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.map-hint span {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  text-decoration: none;
}

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

.btn-primary:hover {
  background: var(--palm-green-dark);
  color: var(--white);
}

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

.btn-gold:hover {
  background: var(--sand-600);
  color: var(--white);
}

.btn-outline {
  background: transparent;
  color: var(--palm-green);
  border: 1.5px solid var(--palm-green);
}

.btn-outline:hover {
  background: var(--palm-green);
  color: var(--white);
}

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

.btn-sm {
  padding: 0.45rem 0.8rem;
  font-size: 0.85rem;
}

/* Cards */
.card {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  border: 1px solid rgba(191, 160, 112, 0.12);
}

.card-title {
  font-family: var(--font-heading);
  color: var(--text-primary);
  font-size: 1.3rem;
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--sand-200);
}

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

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

.form-control {
  width: 100%;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--sand-300);
  border-radius: var(--radius-md);
  background: var(--white);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-primary);
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 169, 110, 0.12);
}

textarea.form-control {
  min-height: 100px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.9rem;
}

/* Auth pages */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(circle at 20% 30%, rgba(201, 169, 110, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(181, 106, 69, 0.08) 0%, transparent 40%),
    var(--sand-100);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: rgba(255, 253, 248, 0.98);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  border: 1px solid rgba(191, 160, 112, 0.2);
}

.auth-card h2 {
  text-align: center;
  margin-bottom: 1.25rem;
  color: var(--text-primary);
}

.auth-footer {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.alert {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error {
  background: #fdf2f2;
  color: #b94e48;
  border: 1px solid #f5c6c6;
}

.alert-success {
  background: #f3f8f1;
  color: var(--palm-green);
  border: 1px solid #c6dcc0;
}

.alert-info {
  background: var(--sand-100);
  color: var(--text-primary);
  border: 1px solid var(--sand-300);
}

/* Plan page */
.plan-page {
  min-height: 100vh;
  padding-top: calc(var(--header-height) + 1.5rem);
  background: var(--sand-100);
}

.plan-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.plan-header h2 {
  margin: 0;
}

.plan-list {
  display: grid;
  gap: 1rem;
}

.plan-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: start;
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(191, 160, 112, 0.1);
}

.plan-item-img {
  width: 100px;
  height: 100px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--sand-200);
}

.plan-item-body h3 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.plan-item-body p {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.plan-item-meta {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.plan-item-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.plan-item .form-control {
  min-height: 60px;
  font-size: 0.85rem;
}

.history-list {
  display: grid;
  gap: 0.6rem;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--white);
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

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

.history-item small {
  color: var(--text-muted);
}

/* Admin */
.admin-header .header-inner {
  background: rgba(53, 69, 44, 0.92);
  border-color: rgba(255, 253, 248, 0.15);
}

.admin-header .brand-text h1,
.admin-header .main-nav a,
.admin-header .main-nav button,
.admin-header .mobile-menu-btn {
  color: var(--white);
}

.admin-header .language-switcher {
  border-color: rgba(255, 253, 248, 0.2);
}

.admin-header .language-switcher a {
  color: rgba(255, 253, 248, 0.75);
}

.admin-header .language-switcher a.active,
.admin-header .language-switcher a:hover {
  color: var(--white);
  background: rgba(255, 253, 248, 0.12);
}

.admin-page {
  min-height: 100vh;
  padding-top: calc(var(--header-height) + 1.5rem);
  background: var(--sand-100);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.admin-table th,
.admin-table td {
  padding: 0.85rem 1rem;
  text-align: start;
  border-bottom: 1px solid var(--sand-200);
}

.admin-table th {
  background: var(--palm-green-dark);
  color: var(--white);
  font-weight: 600;
  font-size: 0.85rem;
}

.admin-table tr:hover td {
  background: var(--sand-100);
}

.admin-table td {
  font-size: 0.9rem;
}

.admin-actions {
  display: flex;
  gap: 0.4rem;
}

.admin-form .card {
  max-width: 900px;
}

/* Footer */
.site-footer {
  background: var(--palm-green-dark);
  color: rgba(255, 253, 248, 0.8);
  padding: 1.25rem;
  text-align: center;
  font-size: 0.85rem;
}

.site-footer a {
  color: var(--gold-light);
}

/* Utilities */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.75rem; }
.mt-2 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.75rem; }
.mb-2 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }

/* Responsive */
@media (max-width: 1024px) {
  .location-panel {
    width: 340px;
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: 70px;
  }

  .header-inner {
    flex-wrap: wrap;
  }

  .main-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.2rem;
    padding-top: 0.6rem;
  }

  .main-nav.open {
    display: flex;
  }

  .main-nav a,
  .main-nav button {
    width: 100%;
    text-align: start;
    padding: 0.65rem 0.5rem;
  }

  .language-switcher {
    border-inline-start: none;
    padding-inline-start: 0;
    margin-inline-start: 0;
    justify-content: flex-start;
    padding-top: 0.5rem;
  }

  .mobile-menu-btn {
    display: block;
  }

  .location-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 65vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(110%);
  }

  body[dir="rtl"] .location-panel {
    left: 0;
    right: 0;
    transform: translateY(110%);
  }

  .location-panel.open {
    transform: translateY(0);
  }

  .location-panel-hero {
    height: 160px;
  }

  .map-hint {
    bottom: 1rem;
    padding: 0.5rem 0.9rem;
    font-size: 0.8rem;
  }

  .plan-item {
    grid-template-columns: 1fr;
  }

  .plan-item-img {
    width: 100%;
    height: 160px;
  }

  .plan-item-actions {
    flex-direction: row;
  }

  .admin-table {
    display: block;
    overflow-x: auto;
  }
}

@media (max-width: 480px) {
  .site-header {
    padding: 0.5rem;
  }

  .brand-text h1 {
    font-size: 1.05rem;
  }

  .brand-text span {
    font-size: 0.65rem;
  }

  .brand-icon {
    width: 34px;
    height: 34px;
    font-size: 0.95rem;
  }

  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.4rem; }

  .btn {
    padding: 0.55rem 0.85rem;
    font-size: 0.85rem;
  }
}

/* Toast notifications */
.app-toast {
  position: fixed;
  top: calc(var(--header-height) + 1rem);
  right: 1.5rem;
  z-index: 9999;
  max-width: 320px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
}

body[dir="rtl"] .app-toast {
  right: auto;
  left: 1.5rem;
}

@keyframes slideIn {
  from {
    transform: translateX(120%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
