/*
Theme Name: Bắc Ninh Mới
Theme URI: https://bacninhmoi.com
Author: BacNinhMoi
Author URI: https://bacninhmoi.com
Description: Theme bản đồ hành chính Bắc Ninh với Leaflet - tra cứu phường xã, ranh giới địa giới hành chính
Version: 1.0.0
License: GNU General Public License v2 or later
Text Domain: bacninh-moi
Tags: map, leaflet, administrative, vietnam, bac-ninh
*/

/* ============================
   CSS Variables & Reset
   ============================ */
:root {
  --primary: #c0392b;
  --primary-dark: #96281b;
  --primary-light: #e74c3c;
  --secondary: #2c3e50;
  --accent: #f39c12;
  --bg: #f5f6fa;
  --bg-card: #ffffff;
  --text: #2c3e50;
  --text-muted: #7f8c8d;
  --border: #dfe6e9;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-hover: 0 6px 24px rgba(0,0,0,0.14);
  --radius: 10px;
  --radius-sm: 6px;
  --font: 'Be Vietnam Pro', 'Segoe UI', sans-serif;
  --header-height: 60px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }

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

/* ============================
   Header
   ============================ */
#site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  height: var(--header-height);
  display: flex;
  align-items: center;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 20px;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
  white-space: nowrap;
}
.site-logo:hover { color: #fff; text-decoration: none; }
.site-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

#site-nav { flex: 1; }
#site-nav ul { list-style: none; display: flex; gap: 4px; }
#site-nav a {
  color: rgba(255,255,255,0.85);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: background 0.2s, color 0.2s;
}
#site-nav a:hover, #site-nav a.active {
  background: rgba(255,255,255,0.2);
  color: #fff;
  text-decoration: none;
}

.header-search {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 5px 14px;
  gap: 8px;
  min-width: 220px;
}
.header-search input {
  background: none;
  border: none;
  outline: none;
  color: #fff;
  font-size: 0.9rem;
  width: 100%;
}
.header-search input::placeholder { color: rgba(255,255,255,0.6); }
.header-search svg { color: rgba(255,255,255,0.7); flex-shrink: 0; }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
}

/* ============================
   Breadcrumb
   ============================ */
.breadcrumb-bar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  font-size: 0.85rem;
}
.breadcrumb-bar .container {
  max-width: 1400px;
  margin: 0 auto;
}
.breadcrumb-bar ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.breadcrumb-bar li + li::before { content: '›'; margin-right: 4px; color: var(--text-muted); }
.breadcrumb-bar a { color: var(--primary); }
.breadcrumb-bar li:last-child { color: var(--text-muted); }

/* ============================
   Layout
   ============================ */
.page-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px;
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: start;
}

.content-grid.full-width { grid-template-columns: 1fr; }

/* ============================
   Cards
   ============================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow-hover); }

.card-header {
  background: var(--primary);
  color: #fff;
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-body { padding: 20px; }

/* ============================
   Province / Unit Page Hero
   ============================ */
.province-hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: 32px 20px;
  position: relative;
  overflow: hidden;
}
.province-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="80" cy="20" r="40" fill="rgba(255,255,255,0.04)"/><circle cx="20" cy="80" r="30" fill="rgba(255,255,255,0.03)"/></svg>') no-repeat;
  background-size: cover;
}
.province-hero .container { max-width: 1400px; margin: 0 auto; position: relative; }
.province-hero h1 { font-size: 2rem; font-weight: 700; margin-bottom: 8px; }
.province-hero .subtitle { opacity: 0.85; font-size: 1rem; }

/* ============================
   Stats Grid
   ============================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.stat-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  text-align: center;
  border-top: 3px solid var(--primary);
}
.stat-item .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}
.stat-item .stat-unit { font-size: 0.78rem; color: var(--text-muted); }
.stat-item .stat-label { font-size: 0.82rem; margin-top: 4px; color: var(--text); }

/* ============================
   Leaflet Map
   ============================ */
#map-container {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

#leaflet-map {
  height: 520px;
  width: 100%;
  background: #e8f4f8;
}

.map-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.map-btn {
  width: 36px;
  height: 36px;
  background: #fff;
  border: none;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: background 0.2s;
  color: var(--text);
}
.map-btn:hover { background: var(--primary); color: #fff; }

.map-legend {
  position: absolute;
  bottom: 24px;
  left: 12px;
  z-index: 500;
  background: rgba(255,255,255,0.95);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.8rem;
  box-shadow: var(--shadow);
}
.map-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.map-legend .swatch {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.1);
}

/* ============================
   Unit List / Table
   ============================ */
.unit-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}

.filter-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.unit-search-box {
  flex: 1;
  min-width: 200px;
  padding: 7px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}
.unit-search-box:focus { border-color: var(--primary); }

.units-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.unit-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: all 0.2s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}
.unit-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.unit-type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-phuong { background: #ffeaa7; color: #e67e22; }
.badge-xa { background: #d1fae5; color: #065f46; }
.badge-thi-tran { background: #dbeafe; color: #1e3a5f; }

.unit-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.unit-meta {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.unit-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.btn-sm {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  border: 1.5px solid var(--border);
  background: #fff;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-sm:hover, .btn-sm.primary { background: var(--primary); color: #fff; border-color: var(--primary); text-decoration: none; }

/* ============================
   Table View
   ============================ */
.table-responsive { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.data-table th {
  background: var(--secondary);
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: var(--header-height);
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:hover td { background: #f8f9ff; }
.data-table tr:nth-child(even) td { background: #fafbfc; }
.data-table tr:nth-child(even):hover td { background: #f0f3ff; }

/* ============================
   Detail Page
   ============================ */
.detail-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 16px 0;
}

.info-row {
  display: flex;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  font-size: 0.9rem;
}
.info-row:last-child { border-bottom: none; }
.info-row .label { color: var(--text-muted); width: 160px; flex-shrink: 0; }
.info-row .value { font-weight: 600; color: var(--text); }

.merger-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.merger-tag {
  background: #fff3f3;
  border: 1px solid #fca5a5;
  color: var(--primary);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.82rem;
}

/* ============================
   UBND Page
   ============================ */
.ubnd-card {
  background: linear-gradient(135deg, #fff 60%, #fff5f5 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.ubnd-address {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}
.ubnd-meta { display: flex; flex-wrap: wrap; gap: 16px; font-size: 0.9rem; }
.ubnd-meta-item { display: flex; gap: 6px; align-items: center; color: var(--text-muted); }
.ubnd-meta-item strong { color: var(--text); }

/* ============================
   Sidebar
   ============================ */
.sidebar { display: flex; flex-direction: column; gap: 16px; }

.sidebar-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.sidebar-section h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: var(--secondary);
  padding: 10px 16px;
  margin: 0;
}
.sidebar-list { list-style: none; padding: 0; }
.sidebar-list li a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 0.88rem;
  transition: background 0.15s, color 0.15s;
}
.sidebar-list li:last-child a { border-bottom: none; }
.sidebar-list li a:hover { background: #fff5f5; color: var(--primary); text-decoration: none; }
.sidebar-list li a .count {
  background: var(--bg);
  color: var(--text-muted);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.78rem;
}

/* ============================
   Pagination
   ============================ */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 20px 0;
  flex-wrap: wrap;
}
.page-link {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
  transition: all 0.2s;
  text-decoration: none;
}
.page-link:hover, .page-link.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  text-decoration: none;
}

/* ============================
   View Toggle
   ============================ */
.view-toggle {
  display: flex;
  gap: 4px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.view-toggle button {
  padding: 6px 12px;
  border: none;
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s, color 0.2s;
  color: var(--text-muted);
}
.view-toggle button.active { background: var(--primary); color: #fff; }

/* ============================
   Footer
   ============================ */
#site-footer {
  background: var(--secondary);
  color: rgba(255,255,255,0.75);
  padding: 40px 20px 20px;
  margin-top: 48px;
}
.footer-grid {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}
.footer-brand .logo { color: #fff; font-size: 1.2rem; font-weight: 700; margin-bottom: 12px; }
.footer-brand p { font-size: 0.85rem; line-height: 1.7; }
.footer-col h4 { color: #fff; font-size: 0.9rem; margin-bottom: 14px; font-weight: 600; }
.footer-col ul { list-style: none; }
.footer-col ul li { margin-bottom: 8px; }
.footer-col ul li a { color: rgba(255,255,255,0.65); font-size: 0.85rem; }
.footer-col ul li a:hover { color: #fff; text-decoration: none; }
.footer-bottom {
  max-width: 1400px;
  margin: 0 auto;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 20px;
  font-size: 0.82rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: gap;
  gap: 12px;
}

/* ============================
   Loading / Skeleton
   ============================ */
.skeleton {
  background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ============================
   Responsive
   ============================ */
@media (max-width: 1100px) {
  .content-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .province-hero h1 { font-size: 1.4rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  #site-nav { display: none; }
  #site-nav.open { display: flex; position: fixed; inset: var(--header-height) 0 0 0; background: var(--primary-dark); z-index: 999; padding: 20px; flex-direction: column; }
  #site-nav.open ul { flex-direction: column; gap: 4px; }
  .nav-toggle { display: flex; }
  .footer-grid { grid-template-columns: 1fr; }
  .units-grid { grid-template-columns: 1fr; }
  #leaflet-map { height: 380px; }
  .header-search { display: none; }
  .data-table { font-size: 0.78rem; }
}

@media (max-width: 480px) {
  .page-wrapper { padding: 16px 12px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-item { padding: 12px; }
  .stat-item .stat-value { font-size: 1.2rem; }
}
