/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-dark: #0f172a;
  --bg-gradient: linear-gradient(135deg, #0b0f19 0%, #1e1b4b 50%, #0f172a 100%);
  --panel-bg: rgba(30, 41, 59, 0.75);
  --panel-border: rgba(255, 255, 255, 0.1);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --primary-red: #ef4444;
  --primary-red-hover: #dc2626;
  --primary-red-glow: rgba(239, 68, 68, 0.35);
  
  --matched-green: #10b981;
  --matched-green-hover: #059669;
  --matched-green-glow: rgba(16, 185, 129, 0.35);
  
  --accent-indigo: #6366f1;
  --accent-indigo-hover: #4f46e5;
  --accent-indigo-glow: rgba(99, 102, 241, 0.35);
  
  --warning-amber: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --warning-border: rgba(245, 158, 11, 0.3);
  
  --font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow-lg: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.2);
}

body {
  font-family: var(--font-family);
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

.app-container {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 40px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 1;
}

/* Header Section */
.app-header {
  text-align: center;
  padding: 20px 0 10px 0;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--accent-indigo);
  padding: 6px 14px;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.brand-badge svg {
  fill: currentColor;
}

.app-header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.header-subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 680px;
  margin: 0 auto;
}

.header-subtitle code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  color: #a5b4fc;
}

/* Card Panels */
.card-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Controls Section */
.controls-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-label-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.input-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-hint {
  font-size: 0.825rem;
  color: var(--text-dim);
}

.holdings-textarea {
  width: 100%;
  min-height: 140px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  color: var(--text-main);
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.holdings-textarea:focus {
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.holdings-textarea::placeholder {
  color: var(--text-dim);
  opacity: 0.8;
}

/* Action Buttons */
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-indigo) 0%, var(--accent-indigo-hover) 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--accent-indigo-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--accent-indigo-glow);
  background: linear-gradient(135deg, #6366f1 0%, #4338ca 100%);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-outline:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--primary-red);
  border-color: rgba(239, 68, 68, 0.4);
  transform: translateY(-2px);
}

/* Results / Status Panel */
.results-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeIn 0.3s ease-out forwards;
}

.results-panel.hidden {
  display: none;
}

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

.status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.status-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 50px;
  font-weight: 700;
  font-size: 1rem;
}

.status-count-badge.success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--matched-green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-count-badge.warning {
  background: var(--warning-bg);
  color: var(--warning-amber);
  border: 1px solid var(--warning-border);
}

.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.branch-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
  padding: 6px 14px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.branch-tag:hover {
  background: rgba(16, 185, 129, 0.25);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.branch-tag .tag-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--matched-green);
  box-shadow: 0 0 8px var(--matched-green);
}

/* Warning Message */
.warning-box {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  color: #fcd34d;
  font-size: 0.925rem;
}

.warning-box.hidden {
  display: none;
}

.warning-icon {
  flex-shrink: 0;
  margin-top: 2px;
}

/* Map Section */
.map-section {
  padding: 0;
  overflow: hidden;
  position: relative;
}

.map-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(15, 23, 42, 0.4);
}

.map-title {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.map-legend {
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
}

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

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-dot.red {
  background: var(--primary-red);
  box-shadow: 0 0 8px var(--primary-red-glow);
}

.legend-dot.green {
  background: var(--matched-green);
  box-shadow: 0 0 8px var(--matched-green-glow);
}

.map-container {
  width: 100%;
  height: 550px;
  background: #111827;
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
  z-index: 1;
}

/* Leaflet Customization */
.leaflet-popup-content-wrapper {
  background: #1e293b !important;
  color: #f8fafc !important;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
  padding: 4px !important;
}

.leaflet-popup-tip {
  background: #1e293b !important;
}

.leaflet-popup-close-button {
  color: #94a3b8 !important;
  padding: 8px !important;
}

.popup-card {
  padding: 10px 12px;
  min-width: 220px;
}

.popup-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.725rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.popup-badge.badge-matched {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.popup-badge.badge-unmatched {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.popup-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
  line-height: 1.3;
}

.popup-info {
  font-size: 0.85rem;
  color: #cbd5e1;
  margin-bottom: 10px;
}

.popup-address {
  margin-bottom: 2px;
}

.popup-postal {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.popup-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #818cf8;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.2s ease;
}

.popup-link:hover {
  color: #a5b4fc;
  text-decoration: underline;
}

/* Custom Marker Pins */
.custom-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.custom-pin:hover {
  transform: scale(1.25);
  z-index: 1000 !important;
}

.pin-svg {
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.4));
}

.pin-red .pin-svg {
  color: var(--primary-red);
}

.pin-green .pin-svg {
  color: var(--matched-green);
}

.pulse-ring {
  position: absolute;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.4);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: pulse 2s infinite;
  pointer-events: none;
}

@keyframes pulse {
  0% {
    transform: translate(-50%, -50%) scale(0.6);
    opacity: 0.9;
  }
  100% {
    transform: translate(-50%, -50%) scale(2.2);
    opacity: 0;
  }
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 20px 0 10px 0;
  color: var(--text-dim);
  font-size: 0.875rem;
}

.app-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.app-footer a:hover {
  color: var(--text-main);
  text-decoration: underline;
}

/* Responsive Layout */
@media (max-width: 768px) {
  .app-header h1 {
    font-size: 1.85rem;
  }
  
  .app-container {
    padding: 16px 12px 24px 12px;
  }
  
  .card-panel {
    padding: 16px;
  }
  
  .button-row {
    flex-direction: column;
    width: 100%;
  }
  
  .btn {
    width: 100%;
  }
  
  .map-container {
    height: 420px;
  }
}
