/* Modern Dark / Sleek GIS Theme System */
:root {
  --bg-dark: #0f172a;
  --bg-panel: #1e293b;
  --bg-card: #334155;
  --bg-card-hover: #475569;
  --border-color: #334155;
  --border-focus: #3b82f6;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.25);
  
  --status-approved: #22c55e;
  --status-refused: #ef4444;
  --status-inflight: #f59e0b;
  --status-withdrawn: #64748b;
  
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

/* App Full Layout */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Top Header */
.app-header {
  height: 64px;
  background-color: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 16px;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.flag-icon {
  font-size: 28px;
}

.brand-text h1 {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text .sub-text {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Stats Pill */
.header-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.6);
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.stat-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
}

.stat-label {
  color: var(--text-muted);
}

.stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: #38bdf8;
}

/* Search Bar */
.header-search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  max-width: 680px;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input-wrapper input {
  width: 100%;
  height: 38px;
  padding: 0 36px 0 38px;
  background-color: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.88rem;
  font-family: inherit;
  transition: all 0.2s ease;
}

.search-input-wrapper input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.icon-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 14px;
  line-height: 1;
  border-radius: 50%;
}

.icon-btn:hover {
  color: var(--text-main);
}

.search-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Custom Select & Buttons */
.select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.control-icon {
  position: absolute;
  left: 10px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

select {
  height: 38px;
  background-color: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 0 12px;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
}

.select-wrapper select {
  padding-left: 32px;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

select:focus {
  outline: none;
  border-color: var(--border-focus);
}

.btn {
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--bg-card-hover);
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--primary);
  color: #60a5fa;
  width: 100%;
  justify-content: center;
}

.btn-outline:hover {
  background-color: var(--primary-glow);
}

/* Main Sidebar & Map Layout */
.app-main {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
  height: calc(100vh - 64px);
  min-height: 0;
}

/* Sidebar Styling */
.app-sidebar {
  width: 380px;
  background-color: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 500;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

.app-sidebar.collapsed {
  margin-left: -380px;
}

.sidebar-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 4px;
}

.filter-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.filter-group select {
  width: 100%;
}

.filter-checkbox {
  margin-top: 4px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input {
  display: none;
}

.checkbox-custom {
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-dark);
  position: relative;
  transition: all 0.15s ease;
}

.checkbox-label input:checked + .checkbox-custom {
  background-color: var(--primary);
  border-color: var(--primary);
}

.checkbox-label input:checked + .checkbox-custom::after {
  content: '✓';
  position: absolute;
  color: #fff;
  font-size: 11px;
  top: -1px;
  left: 3px;
  font-weight: bold;
}

.action-bar {
  margin-top: 12px;
}

/* Feed List Section */
.feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: rgba(15, 23, 42, 0.4);
  padding: 10px 16px;
}

.feed-summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.8rem;
  font-weight: 600;
}

.coords-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
}

.feed-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Proposal Card Design */
.proposal-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}

.proposal-card:hover {
  border-color: #64748b;
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.proposal-card.card-hover {
  border-color: #38bdf8 !important;
  background-color: #334155 !important;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35) !important;
}

.proposal-card.selected-card {
  border-color: #facc15 !important;
  background-color: #1e293b !important;
  box-shadow: 0 0 16px rgba(250, 204, 21, 0.3) !important;
  border-left: 4px solid #facc15 !important;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 8px;
}

.card-ref {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 700;
  color: #38bdf8;
}

.card-dist {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.card-title {
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text-main);
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.card-council {
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-approved { background-color: #15803d; color: #ffffff; border: 1px solid #22c55e; }
.badge-refused { background-color: #b91c1c; color: #ffffff; border: 1px solid #ef4444; }
.badge-inflight { background-color: #b45309; color: #ffffff; border: 1px solid #f59e0b; }
.badge-withdrawn { background-color: #475569; color: #ffffff; border: 1px solid #64748b; }
.badge-unresolved { background-color: #334155; color: #ffffff; border: 1px dashed #94a3b8; font-weight: 700; }

/* Card Actions */
.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.link-btn {
  font-size: 0.75rem;
  color: #60a5fa;
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.link-btn:hover {
  text-decoration: underline;
}

/* Map Canvas Container */
.app-map-container {
  flex: 1;
  position: relative;
  height: 100%;
}

#map {
  width: 100%;
  height: 100%;
  background-color: #0b1120;
}

/* Floating Map Legend */
.map-legend {
  position: absolute;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
}

.glass-panel {
  background: rgba(30, 41, 59, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
}

.legend-header {
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.legend-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.legend-item .badge {
  width: 10px;
  height: 10px;
  padding: 0;
  border-radius: 50%;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 1rem;
  color: var(--text-main);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 0.8rem;
  line-height: 1.4;
}

/* Loading Spinners */
.spinner-inline {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hidden {
  display: none !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-panel);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}
