/* ============================================================
   Jordan Travel Wiki — Modern Professional Design System
   Responsive · RTL-aware · Light/Dark theme support
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  /* Brand palette — warm desert + deep teal */
  --brand-50:  #fdf6ec;
  --brand-100: #f9e8cf;
  --brand-200: #f0d3a3;
  --brand-300: #e5b96f;
  --brand-400: #d99c3f;
  --brand-500: #c97f2a;   /* primary */
  --brand-600: #a9641f;
  --brand-700: #874d1c;
  --brand-800: #6b3d1c;
  --brand-900: #57331a;

  --teal-500: #0e7c7b;
  --teal-600: #0b6362;

  /* Surfaces */
  --bg-body:      #f4f5f7;
  --bg-surface:   #ffffff;
  --bg-surface-2: #fafbfc;
  --bg-muted:     #eef1f4;
  --bg-accent:    #fdf3e3;

  /* Text */
  --text-primary:   #1f2933;
  --text-secondary: #5b6770;
  --text-muted:     #7b8794;
  --text-on-accent: #ffffff;

  /* Borders & shadows */
  --border:        #e1e5ea;
  --border-strong: #c9d0d8;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow-md: 0 4px 12px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.12);

  /* Link */
  --link: #0b6f8f;
  --link-hover: #095a74;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Spacing scale */
  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem; --sp-4: 1rem;
  --sp-5: 1.5rem; --sp-6: 2rem;  --sp-7: 3rem;   --sp-8: 4rem;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Noto Sans Arabic", "PingFang SC", "Microsoft YaHei", "Noto Sans KR", sans-serif;
  --font-serif: Georgia, "Times New Roman", "Noto Serif", "Noto Naskh Arabic", serif;
  --font-mono: "SF Mono", "Cascadia Code", Consolas, monospace;

  --container: 1200px;
  --sidebar-w: 264px;
}

/* Dark theme */
[data-theme="dark"] {
  --bg-body: #101418;
  --bg-surface: #171c22;
  --bg-surface-2: #1d242c;
  --bg-muted: #232b34;
  --bg-accent: #2a2118;
  --text-primary: #e6e9ed;
  --text-secondary: #aab3bd;
  --text-muted: #7d8894;
  --border: #2c3540;
  --border-strong: #3a4552;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,.45);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.55);
  --link: #5fb6d6;
  --link-hover: #8ccbe4;
  --brand-500: #e0a04a;
  --brand-600: #eab06a;
  --brand-700: #f2c48a;
  --text-on-accent: #1a1206;
}

/* System theme preference (default when no explicit choice) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-body: #101418;
    --bg-surface: #171c22;
    --bg-surface-2: #1b222a;
    --bg-muted: #232b34;
    --bg-accent: #2a2118;
    --text-primary: #e6e9ed;
    --text-secondary: #aab3bd;
    --text-muted: #7d8894;
    --border: #2c3540;
    --border-strong: #3a4552;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,.45);
    --shadow-lg: 0 12px 32px rgba(0,0,0,.55);
    --link: #5fb3d6;
    --link-hover: #7c8be4;
    --brand-500: #e0a04a;
    --brand-600: #eab06a;
    --brand-700: #f2c48a;
    --text-on-accent: #1a1206;
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-body);
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
}
img { max-width: 100%; height: auto; }
a { color: var(--link); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--link-hover); text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-serif); line-height: 1.25; color: var(--text-primary); }
h1 { font-size: 2rem; font-weight: 700; margin: 0 0 var(--sp-4); }
h2 { font-size: 1.45rem; font-weight: 700; margin: var(--sp-6) 0 var(--sp-3); }
h3 { font-size: 1.15rem; font-weight: 600; margin: var(--sp-5) 0 var(--sp-2); }
p { margin: 0 0 var(--sp-4); }
code { font-family: var(--font-mono); background: var(--bg-muted); padding: .1em .35em; border-radius: 4px; font-size: .9em; }

.wrap { max-width: var(--container); margin: 0 auto; padding: 0 var(--sp-4); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.topbar .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4); padding: 12px var(--sp-4); flex-wrap: wrap;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-serif); font-size: 1.3rem; font-weight: 700;
  color: var(--text-primary); letter-spacing: -.01em;
}
.brand:hover { text-decoration: none; color: var(--brand-600); }
.brand .brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: var(--text-on-accent); font-size: 1.05rem; font-weight: 800;
  box-shadow: var(--shadow-sm);
}
.topbar-actions { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }

.searchform { display: flex; gap: 0; }
.searchform input[type=search] {
  border: 1px solid var(--border-strong); border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  padding: 9px 14px; min-width: 220px; font-size: .95rem;
  background: var(--bg-surface-2); color: var(--text-primary);
  outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.searchform input[type=search]:focus { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(201,127,42,.18); }
.searchform button {
  background: var(--brand-500); color: var(--text-on-accent);
  border: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 9px 18px; cursor: pointer; font-weight: 600; font-size: .95rem;
  transition: background .15s ease;
}
.searchform button:hover { background: var(--brand-600); }
[dir=rtl] .searchform input[type=search] { border-right: 1px solid var(--border-strong); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
[dir=rtl] .searchform button { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }

/* Theme toggle */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--bg-muted); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px;
}
.theme-toggle button {
  border: 0; background: transparent; cursor: pointer;
  padding: 6px 10px; border-radius: 999px; font-size: .85rem;
  color: var(--text-secondary); transition: all .18s ease;
  display: inline-flex; align-items: center; gap: 4px;
}
.theme-toggle button.active { background: var(--brand-500); color: var(--text-on-accent); font-weight: 600; box-shadow: var(--shadow-sm); }

/* ---------- Layout ---------- */
.layout { display: flex; gap: var(--sp-6); padding-top: var(--sp-6); padding-bottom: var(--sp-8); align-items: flex-start; }

/* ---------- Sidebar ---------- */
.sidebar { width: var(--sidebar-w); flex-shrink: 0; position: sticky; top: 76px; }
.sidebar .panel {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--sp-4); margin-bottom: var(--sp-4);
  box-shadow: var(--shadow-sm);
}
.sidebar .panel-title {
  display: block; font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-muted);
  margin-bottom: var(--sp-2); padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
}
.sidebar nav a {
  display: block; padding: 6px 10px; font-size: .92rem; color: var(--text-secondary);
  border-radius: var(--radius-sm); margin-bottom: 1px; line-height: 1.4;
}
.sidebar nav a:hover { background: var(--bg-muted); color: var(--text-primary); text-decoration: none; }
.sidebar nav a.active { background: var(--bg-accent); color: var(--brand-700); font-weight: 600; }

/* Language dropdown (redesigned: one compact dropdown instead of the old flat list) */
.lang-dropdown { position: relative; }
.lang-dropdown-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 9px 12px; font-size: .92rem; font-weight: 600;
  background: var(--bg-surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); color: var(--text-primary); cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.lang-dropdown-btn:hover { border-color: var(--brand-500); }
.lang-dropdown-btn:focus-visible {
  outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(201,127,42,.18);
}
.lang-dd-current { display: inline-flex; align-items: center; gap: 6px; }
.lang-dd-caret { font-size: .8em; color: var(--text-muted); transition: transform .18s ease; }
.lang-dropdown-btn[aria-expanded="true"] .lang-dd-caret { transform: rotate(180deg); }
.lang-dropdown-menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60;
  list-style: none; margin: 0; padding: 5px; overflow-y: auto;
  background: var(--bg-surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); box-shadow: 0 8px 24px rgba(0,0,0,.12);
  max-height: 420px;
}
.lang-dropdown-menu li { margin: 0; padding: 0; }
.lang-dropdown-menu a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-sm); font-size: .9rem;
  color: var(--text-secondary); text-decoration: none;
}
.lang-dropdown-menu a:hover { background: var(--bg-muted); color: var(--text-primary); }
.lang-dropdown-menu li.active a { background: var(--bg-accent); color: var(--brand-700); font-weight: 600; }
.lang-dropdown-menu li.active a[aria-current="true"] { cursor: default; }
.lang-dd-check { color: var(--brand-600); font-weight: 700; }
[dir=rtl] .lang-dropdown-menu { left: auto; right: 0; }

/* Sidebar promo */
.sidebar-promo {
  background: linear-gradient(135deg, var(--bg-accent), var(--brand-100));
  border: 1px solid var(--brand-300); border-radius: var(--radius-md);
  padding: var(--sp-4); font-size: .9rem;
}
.sidebar-promo a { font-weight: 600; color: var(--brand-700); }
.sidebar-promo a:hover { text-decoration: underline; }

/* ---------- Content ---------- */
.content {
  flex: 1; min-width: 0;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--sp-6) var(--sp-7);
  box-shadow: var(--shadow-sm);
}
.lead { font-size: 1.1rem; color: var(--text-secondary); line-height: 1.6; }

/* Breadcrumbs */
.crumbs { font-size: .85rem; color: var(--text-muted); margin-bottom: var(--sp-4); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.crumbs a { color: var(--text-secondary); }
.crumbs a:hover { color: var(--link); }
.crumbs .sep { color: var(--text-muted); }

/* Hero image */
.article-hero {
  margin: 0 0 var(--sp-5); border-radius: var(--radius-md); overflow: hidden;
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  background: var(--bg-muted);
}
.article-hero img { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.article-hero figcaption { padding: 10px 14px; color: var(--text-muted); font-size: .82rem; background: var(--bg-surface-2); }

/* Article body */
.articlebody { font-size: 1.02rem; }
.articlebody p { margin: 0 0 1.1em; }
.articlebody h2 { border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.articlebody ul, .articlebody ol { margin: 0 0 1.1em; padding-left: 1.4em; }
[dir=rtl] .articlebody ul, [dir=rtl] .articlebody ol { padding-left: 0; padding-right: 1.4em; }
.articlebody li { margin-bottom: .4em; }

/* FAQ items */
.faq-item {
  background: var(--bg-surface-2); border-left: 4px solid var(--brand-500);
  border-radius: var(--radius-sm); padding: 14px 18px; margin: 0 0 14px;
  white-space: pre-wrap;
}
.faq-item .q { color: var(--brand-600); font-weight: 700; }
[dir=rtl] .faq-item { border-left: 0; border-right: 4px solid var(--brand-500); }

/* Keyword link */
.kw-link { border-bottom: 1px dotted var(--link); }
.kw-link:hover { border-bottom-style: solid; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--sp-4); margin-top: var(--sp-5); }
.card {
  display: block; background: var(--bg-surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 18px 20px; color: inherit;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.card:hover { border-color: var(--brand-500); box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; color: inherit; }
.card h2 { font-size: 1.08rem; margin: 0 0 6px; color: var(--text-primary); }
.card p { margin: 0; font-size: .9rem; color: var(--text-secondary); }
.card .meta { font-size: .8rem; color: var(--text-muted); }

/* Search hits */
.searchhit { border-bottom: 1px solid var(--border); padding: 12px 0; }
.searchhit h2 { margin: 0 0 4px; font-size: 1.1rem; }

/* Related */
.related { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.related li { padding: 10px 14px; background: var(--bg-surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.related a { font-weight: 500; }

/* Pills (directory filters) */
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.pill {
  padding: 6px 14px; border: 1px solid var(--border-strong); border-radius: 999px;
  font-size: .85rem; cursor: pointer; background: var(--bg-surface-2); color: var(--text-secondary);
  transition: all .15s ease;
}
.pill:hover { border-color: var(--brand-500); color: var(--brand-600); }
.pill.active { background: var(--brand-500); border-color: var(--brand-500); color: var(--text-on-accent); font-weight: 600; }
.dir-count { color: var(--text-muted); font-size: .85rem; }

/* ---------- Footer ---------- */
.footer { background: var(--bg-surface); border-top: 1px solid var(--border); padding: var(--sp-6) 0; margin-top: var(--sp-8); }
.footer .wrap { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4); flex-wrap: wrap; }
.footer p { margin: 0; font-size: .88rem; color: var(--text-muted); }
.footer a { color: var(--text-secondary); }
.footer a:hover { color: var(--link); }

/* ---------- Admin ---------- */
.admin-table { width: 100%; border-collapse: collapse; background: var(--bg-surface); }
.admin-table th, .admin-table td { border: 1px solid var(--border); padding: 10px 12px; text-align: left; font-size: .9rem; }
.admin-table th { background: var(--bg-muted); font-weight: 600; }
[dir=rtl] .admin-table th, [dir=rtl] .admin-table td { text-align: right; }
.admin-form label { display: block; margin: 14px 0 4px; font-weight: 600; font-size: .9rem; }
.admin-form input[type=text], .admin-form input[type=password], .admin-form select, .admin-form textarea {
  width: 100%; padding: 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-family: inherit; font-size: .95rem; background: var(--bg-surface-2); color: var(--text-primary);
}
.admin-form input:focus, .admin-form textarea:focus, .admin-form select:focus { border-color: var(--brand-500); outline: none; box-shadow: 0 0 0 3px rgba(201,123,42,.15); }
.admin-form textarea { min-height: 220px; }
.admin-form fieldset { border: 1px solid var(--border); border-radius: var(--radius-md); margin-top: 18px; padding: 16px; background: var(--bg-surface-2); }
.admin-form legend { font-weight: 700; padding: 0 8px; }
.btn {
  display: inline-block; background: var(--brand-500); color: var(--text-on-accent);
  border: 0; border-radius: var(--radius-sm); padding: 10px 22px; cursor: pointer;
  font-size: .95rem; font-weight: 600; margin-top: 10px; transition: background .15s ease;
}
.btn:hover { background: var(--brand-600); text-decoration: none; color: var(--text-on-accent); }
.btn-secondary { background: var(--text-secondary); }
.btn-secondary:hover { background: var(--text-primary); }
.btn-danger { background: #b32424; }
.btn-danger:hover { background: #8f1c1c; }
.notice { background: #e6f4ea; border: 1px solid #7cc48a; color: #1d5c2e; padding: 12px 16px; border-radius: var(--radius-sm); margin: 12px 0; }
.notice-error { background: #fdecea; border-color: #e0a0a0; color: #8f1c1c; }
[data-theme="dark"] .notice { background: #1d2b22; border-color: #2f5c3a; color: #9fd8ab; }
[data-theme="dark"] .notice-error { background: #331f1d; border-color: #6e302c; color: #f0b3ad; }

/* Admin top nav */
.admin-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.admin-nav a { padding: 6px 12px; border-radius: var(--radius-sm); font-size: .9rem; color: var(--text-secondary); }
.admin-nav a:hover { background: var(--bg-muted); text-decoration: none; color: var(--text-primary); }
.admin-nav a.active { background: var(--bg-accent); color: var(--brand-700); font-weight: 600; }

/* ---------- Section hubs (restructured navigation) ---------- */
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--sp-4); margin-top: var(--sp-5); }
.hub-tile {
  display: flex; flex-direction: column; gap: 6px;
  background: linear-gradient(160deg, var(--bg-surface-2), var(--bg-surface));
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 18px 20px; color: inherit;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.hub-tile:hover { border-color: var(--brand-500); box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; color: inherit; }
.hub-tile h2 { font-family: var(--font-sans); font-size: 1.02rem; font-weight: 700; margin: 0; color: var(--text-primary); }
.hub-tile p { margin: 0; font-size: .85rem; line-height: 1.5; color: var(--text-secondary); }
.hub-tile .hub-meta { font-size: .78rem; font-weight: 600; color: var(--brand-600); text-transform: uppercase; letter-spacing: .04em; margin-top: auto; padding-top: 6px; }
[data-theme="dark"] .hub-tile .hub-meta { color: var(--brand-500); }

/* Breadcrumb chips */
.crumb { font-size: .85rem; color: var(--text-muted); margin-bottom: var(--sp-4); }
.crumb a { color: var(--text-secondary); }
.crumb a:hover { color: var(--link); }

/* Pagination (max 8 items per listing page) */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-top: var(--sp-6); padding-top: var(--sp-4); border-top: 1px solid var(--border); flex-wrap: wrap; }
.pager-btn {
  display: inline-block; background: var(--bg-surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 16px; font-size: .9rem; font-weight: 600;
  color: var(--text-secondary); transition: all .15s ease;
}
.pager-btn:hover { border-color: var(--brand-500); color: var(--brand-600); text-decoration: none; box-shadow: var(--shadow-sm); }
.pager-info { font-size: .85rem; color: var(--text-muted); }
.pager-nums { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pager-num { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg-surface-2); color: var(--text-secondary); font-size: .9rem; font-weight: 600; transition: all .15s ease; }
.pager-num:hover { border-color: var(--brand-500); color: var(--brand-600); text-decoration: none; box-shadow: var(--shadow-sm); }
.pager-num.active { background: var(--brand-500); border-color: var(--brand-500); color: #fff; cursor: default; }
.pager-dots { color: var(--text-muted); padding: 0 2px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; position: static; }
  .content { padding: var(--sp-5); }
}
@media (max-width: 600px) {
  .topbar .wrap { flex-direction: column; align-items: stretch; }
  .searchform input[type=search] { min-width: 0; flex: 1; }
  .content { padding: var(--sp-4); border-radius: var(--radius-md); }
  h1 { font-size: 1.6rem; }
  .cards { grid-template-columns: 1fr; }
  .hub-grid { grid-template-columns: 1fr; }
  .theme-toggle { align-self: flex-start; }
  .pager { flex-direction: column; align-items: stretch; text-align: center; }
}