/* ===== الألوان ===== */
:root {
  --green: #0f6b5c;
  --gold: #c9a227;
  --bg: #f5f5f5;
  --border: #dddddd;
  --gray: #666666;
}

/* ===== الأساسيات ===== */
body {
  margin: 0;
  font-family: "Tajawal", Tahoma, sans-serif;
  background: var(--bg);
  color: #222222;
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px;
}

a {
  color: var(--green);
}

/* ===== الهيدر والقائمة ===== */
.header {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: bold;
  color: var(--green);
  margin-bottom: 8px;
}

/* الشعار: دائرة خضراء */
.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--gold);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nav a {
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: #333333;
}

/* الصفحة الحالية */
.nav a.active {
  background: var(--green);
  color: white;
}

/* ===== الأزرار ===== */
.btn {
  display: inline-block;
  background: var(--green);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 16px;
  text-decoration: none;
  cursor: pointer;
}

/* ===== البطاقات ===== */
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.cards .card {
  margin-bottom: 0;
}

.card h3 {
  margin-top: 0;
  color: var(--green);
}

/* رسالة الصفحة الفارغة */
.empty {
  text-align: center;
  color: var(--gray);
  padding: 30px 16px;
}

/* ===== حقول الإدخال ===== */
input, select {
  width: 100%;
  box-sizing: border-box;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 16px;
  margin-bottom: 12px;
}

label {
  display: block;
  margin-bottom: 4px;
}

/* ===== صفحة الأسئلة: أزرار المراحل ===== */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tab {
  background: white;
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 15px;
}

/* ===== صفحة المساعد ===== */
.messages {
  height: 350px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  padding: 12px;
  margin-bottom: 12px;
}

.msg {
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  max-width: 80%;
  white-space: pre-line; /* إظهار السطور الجديدة في الإجابة */
}

.msg.user {
  background: var(--green);
  color: white;
  margin-left: auto;
}

.msg.bot {
  background: #e8f1ef;
  margin-right: auto;
}

.chat-form {
  display: flex;
  gap: 8px;
}

.chat-form input {
  margin-bottom: 0;
}

/* ===== صفحة الخرائط ===== */

/* "من" و"إلى" والزر في سطر واحد */
.route-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.route-form .field {
  flex: 1;
  min-width: 150px;
}

.route-form select {
  margin-bottom: 0;
}

/* النتيجة بجانب الخريطة */
.map-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 12px;
}

#route-result {
  margin-bottom: 0;
}

#route-result h3 {
  margin-bottom: 12px;
}

.hint {
  color: var(--gray);
}

/* مربعا المسافة والوقت */
.stats {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.stat {
  flex: 1;
  background: #e8f1ef;
  border-radius: 6px;
  padding: 8px;
  text-align: center;
  font-size: 14px;
}

.stat strong {
  display: block;
  font-size: 20px;
  color: var(--green);
}

#map {
  height: 450px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* في الجوال: النتيجة فوق الخريطة */
@media (max-width: 700px) {
  .map-layout {
    grid-template-columns: 1fr;
  }

  #map {
    height: 350px;
  }

  .route-form .btn {
    width: 100%;
  }
}

/* ===== صفحة الدخول ===== */
.login-box {
  max-width: 380px;
  margin: 0 auto;
}

.error {
  color: #c62828;
}

/* ===== الفوتر ===== */
.footer {
  text-align: center;
  color: var(--gray);
  padding: 20px;
  font-size: 14px;
}

/* ===== صفحة الإعدادات: قائمة المواقع ===== */
.list {
  list-style: none;
  padding: 0;
}

.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  word-break: break-all;
}

.btn-small {
  background: white;
  color: #c62828;
  border: 1px solid #c62828;
  border-radius: 6px;
  padding: 4px 10px;
  font-family: inherit;
  cursor: pointer;
}

/* ===== صفحة المساعد: المصادر تحت الإجابة ===== */
.sources {
  margin-top: 8px;
  font-size: 14px;
}

.sources a {
  display: block;
}
