:root {
  --teal: #1f3e99;
  --teal-dark: #00185d;
  --teal-light: #00289b;
  --accent: #1f3983;
  --bg: #f4f7f6;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --amber: #d97706;
}

* {
  font-family: "Vazirmatn", system-ui, sans-serif;
}

body {
  background-color: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
}

main {
  flex: 1 0 auto;
}

.text-teal {
  color: var(--accent) !important;
}

/* ---------- Header ---------- */
.app-header {
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(15, 118, 110, 0.25);
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.15);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #fff;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.brand-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
}

.brand-sub {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.85);
}

.badge-university {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
}

/* ---------- Sub nav / breadcrumb ---------- */
.sub-nav {
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.breadcrumb {
  font-size: 0.9rem;
  background: transparent;
}

.breadcrumb-item a {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}

.breadcrumb-item a:hover {
  text-decoration: underline;
}

.breadcrumb-item.active {
  color: var(--muted);
}

.breadcrumb-item + .breadcrumb-item::before {
  content: "›";
  color: var(--muted);
}

/* ---------- Search ---------- */
.search-wrap {
  position: relative;
}

.search-wrap i {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-wrap .form-control {
  padding-right: 42px;
  border-radius: 999px;
  border: 1px solid var(--border);
  height: 48px;
  background-color: var(--card);
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  transition: background-color 0.3s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-wrap .form-control:focus {
  border-color: var(--teal-light);
  box-shadow: 0 0 0 0.2rem rgba(20, 184, 166, 0.2);
}

/* ---------- Section title ---------- */
.section-title {
  font-weight: 800;
  margin-bottom: 0.35rem;
}

.section-sub {
  color: var(--muted);
  margin-bottom: 1.5rem;
}

/* ---------- Province & Unit cards ---------- */
.tile-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  height: 100%;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background-color 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  text-decoration: none;
  color: inherit;
}

.tile-card:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* عناوین بخش‌های نتیجه جستجو */
.result-heading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 1rem;
}

.result-heading .result-count {
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent);
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.tile-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(15, 118, 110, 0.15);
  border-color: var(--teal-light);
}

.tile-icon {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 14px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.tile-body {
  flex: 1;
  min-width: 0;
}

.tile-title {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
}

.tile-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.tile-count {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(217, 119, 6, 0.12);
  color: var(--amber);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.tile-arrow {
  color: var(--muted);
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* ---------- Detail (unit) ---------- */
.detail-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  height: 100%;
}

.detail-card-header {
  padding: 1rem 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.detail-card-header.supporters {
  background: rgba(15, 118, 110, 0.07);
  color: var(--accent);
}

.detail-card-header.terms {
  background: rgba(217, 119, 6, 0.08);
  color: var(--amber);
}

.detail-card-body {
  padding: 1.25rem;
}

/* Supporter item */
.supporter-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.supporter-item:last-child {
  margin-bottom: 0;
}

.supporter-name {
  font-weight: 700;
  font-size: 1rem;
}

.supporter-role {
  font-size: 0.8rem;
  color: var(--accent);
  background: rgba(15, 118, 110, 0.1);
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
}

.contact-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  padding: 0.35rem 0;
  color: var(--ink);
  text-decoration: none;
}

.contact-row i {
  color: var(--accent);
  width: 20px;
  text-align: center;
}

.contact-row.link:hover {
  color: var(--accent);
}

/* Term link */
.term-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 0.75rem;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  transition: all 0.15s ease;
}

.term-link:last-child {
  margin-bottom: 0;
}

.term-link:hover {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

.term-link .term-icon {
  color: var(--amber);
}

.term-link:hover .term-icon {
  color: #fff;
}

.term-link .term-go {
  margin-right: auto;
  font-size: 0.8rem;
}

.term-link .term-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ترم فعال (جاری) */
.term-link.term-active {
  border-color: var(--accent);
  border-width: 2px;
  background: rgba(15, 118, 110, 0.06);
  box-shadow: 0 2px 10px rgba(15, 118, 110, 0.12);
}

.term-link.term-active .term-icon {
  color: var(--accent);
}

.term-link.term-active:hover {
  background: var(--teal);
}

.term-link.term-active:hover .term-icon {
  color: #fff;
}

.term-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  background: var(--teal);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.1rem 0.55rem 0.1rem 0.35rem;
  border-radius: 999px;
  line-height: 1.6;
}

.term-badge .bi-dot {
  font-size: 1.1rem;
  margin-left: -0.15rem;
  animation: pulse-dot 1.4s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.term-link:hover .term-badge {
  background: #fff;
  color: var(--teal);
}

/* ---------- Back button ---------- */
.btn-back {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.btn-back:hover {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

/* ---------- Footer ---------- */
.app-footer {
  background: var(--card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

.empty-state i {
  font-size: 3rem;
  opacity: 0.4;
}

/* ---------- Animations ---------- */
.fade-in {
  animation: fadeIn 0.3s ease;
}

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

@media (max-width: 575.98px) {
  .brand-title {
    font-size: 1.25rem;
  }
  .badge-university {
    font-size: 0.75rem;
  }
  .theme-toggle {
    width: 38px;
    height: 38px;
    font-size: 1rem;
  }
}

/* =========================================================
   Dark Mode  (فعال با data-bs-theme="dark" روی تگ <html>)
   ========================================================= */
[data-bs-theme="dark"] {
  color-scheme: dark;
  --accent: #2dafd4;
  --bg: #0f172a;
  --card: #1e293b;
  --ink: #e5e7eb;
  --muted: #94a3b8;
  --border: #334155;
  --amber: #fbbf24;
}

[data-bs-theme="dark"] .tile-icon,
[data-bs-theme="dark"] .supporter-role {
  background: rgba(45, 212, 191, 0.12);
}

[data-bs-theme="dark"] .result-heading .result-count {
  background: rgba(45, 212, 191, 0.15);
}

[data-bs-theme="dark"] .detail-card-header.supporters {
  background: rgba(45, 212, 191, 0.08);
}

[data-bs-theme="dark"] .detail-card-header.terms {
  background: rgba(251, 191, 36, 0.1);
}

[data-bs-theme="dark"] .tile-count {
  background: rgba(251, 191, 36, 0.12);
}

[data-bs-theme="dark"] .term-link.term-active {
  background: rgba(45, 212, 191, 0.07);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

[data-bs-theme="dark"] .tile-card:hover {
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

[data-bs-theme="dark"] .search-wrap .form-control {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.search-wrap .form-control::placeholder {
  color: var(--muted);
}

.sub-nav,
.app-footer,
.detail-card,
.detail-card-header,
.supporter-item,
.term-link {
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* ---------- Theme toggle button ---------- */
.theme-toggle {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 0;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
}

.theme-toggle:active {
  transform: scale(0.92);
}

