/* ================================
   الأساس: تصميم الهاتف (Mobile First)
   ترتيب طبيعي: البيانات فوق - الخريطة وسط - الأزرار تحت
   ================================ */
.container {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "fields"
      "map"
      "buttons";
    height: 100vh;
    overflow-y: auto;
    background-color: #32353a;
}

.fields-panel {
  grid-area: fields;
}

.map-wrapper {
  grid-area: map;
  position: relative;
}

.buttons-panel {
  grid-area: buttons;
}

.sidebar {
  width: 100%;
  padding: 15px 20px;
  box-sizing: border-box;
  background: #32353a;
  color: #c18a32;
  display: flex;
  flex-direction: column;
  align-items: flex-end; /* الأزرار والحقول على اليمين */
}

.sidebar h2 {
  margin-bottom: 15px;
  width: 100%;
  text-align: right;
  text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5); 
}

.sidebar label,
.sidebar input,
.sidebar select,
.sidebar button {
  display: block;
  width: 100%;
  margin-bottom: 10px;
  text-align: right;
  direction: rtl;
  border-radius: 5px;
}

.sidebar label {
  color: #fff7e6;
  font-size: 14px;
  text-align: right;
  display: block;
  margin-bottom: 5px;
}

input, select, textarea {
    background-color: #fff7e6 !important;
    color: #000000 !important;
    border: 1px solid #fff7e6;
    padding: 5px;
    width: 100%;
    box-sizing: border-box;
    appearance: none;
}

input:-webkit-autofill,
select:-webkit-autofill,
textarea:-webkit-autofill {
    -webkit-box-shadow: 0 0 0px 1000px #fff7e6 inset !important;
    -webkit-text-fill-color: #000000 !important;
}

/* الخريطة على الهاتف: طولية، بحجم يشبه شاشة الهاتف، زوايا دائرية خفيفة */

.map-wrapper {
  width: calc(100% - 20px);
  height: 70vh;
  margin: 10px auto;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  background-color: #32353a;
  border: 2px solid #c18a32;
}

#map {
  width: 100%;
  height: 100%;
}

/* Leaflet كايحط خلفية رمادية فاتحة افتراضياً على العنصر الفرعي تاعو،
   لازم نبدلوها هنا باش تطابق خلفية #map */
.leaflet-container {
  background-color: #32353a;
}

button {
  padding: 10px;
  background-color: #c18a32;
  color: #fff7e6;
  border: none;
  cursor: pointer;
  margin-bottom: 8px;
  border-radius: 5px;
}

button:hover {
  background-color: #c18a32b1;
}

select, input {
  color: #1a1918;
}

/* ================================
   الحاسوب: تصميم جانبي (Desktop)
   الخريطة كبيرة على اليسار - البيانات والأزرار على اليمين
   ================================ */
@media (min-width: 769px) {
  html, body {
    height: auto;
    min-height: 100%;
  }

  .container {
    display: grid;
    grid-template-columns: 75% 25%;
    grid-template-rows: 1fr auto;
    grid-template-areas:
      "map fields"
      "map buttons";
    min-height: 100vh;
    height: auto;
    overflow-y: visible;
  }

  .fields-panel {
    grid-area: fields;
    border-left: 1px solid #fff7e6;
  }

  .buttons-panel {
    grid-area: buttons;
    padding: 25px 20px;
    box-sizing: border-box;
    border-left: 1px solid #fff7e6;
    justify-content: flex-end;
    border-top: none;
    padding-top: 20px;
    height: auto;
  }

  .map-wrapper {
    grid-area: map;
    width: 100%;
    height: 100%;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

.fields-panel {
    align-items: center !important;
}

.fields-panel h2 {
    width: 100%;
    text-align: center;
    margin-bottom: 15px;
    color: #c18a32;
    font-size: 28px;
}

.geoplan-stats {
    width: 100%;
    max-width: 300px;
    margin: 25px auto;
    padding: 25px 18px 18px;
    background: rgba(193,138,50,.08);
    border: 1px solid #c18a32;
    border-radius: 12px;
    box-sizing: border-box;
    position: relative;
}

.stats-title {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: #32353a;
    padding: 0 12px;
    color: #c18a32;
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5); 
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.stat-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    direction: rtl;
    gap: 10px;
    margin: 10px 0;
}

.stat-label {
    color: #fff7e6;
    flex: 1;
    text-align: right;
}

.stat-number {
    color: #c18a32;
    font-size: 18px;
    font-weight: bold;
    flex: 0 0 auto;
}

.map-export-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(20, 20, 20, 0.55);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 9999;
    border-radius: inherit;
}

.map-export-spinner {
    width: 42px;
    height: 42px;
    border: 4px solid rgba(255, 255, 255, 0.25);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: map-export-spin 0.8s linear infinite;
}

.map-export-text {
    color: #ffffff;
    font-size: 15px;
    font-weight: bold;
    text-align: center;
}

@keyframes map-export-spin {
    to { transform: rotate(360deg); }
}