/* ─── Variables ─────────────────────────────────────────────── */
:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.08);
  --approved: #10b981;
  --pending: #ef4444;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: rgba(0, 0, 0, 0.08);
  --text: #0f172a;
  --text-muted: #475569;
  --text-subtle: #94a3b8;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
  --radius: 16px;
  --radius-sm: 8px;
  --transition: 0.25s ease;
}

/* ─── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ─── Upload Screen ─────────────────────────────────────────── */
#upload-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 60% 40%, rgba(99,102,241,0.10) 0%, transparent 60%),
              radial-gradient(ellipse at 20% 80%, rgba(34,197,94,0.06) 0%, transparent 50%),
              var(--bg);
  padding: 24px;
}

.upload-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px;
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow);
  text-align: center;
}

.upload-logo {
  margin: 0 auto 24px;
  width: 64px;
  height: 64px;
}

.upload-logo svg { width: 100%; height: 100%; }

.upload-card h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 32px;
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed rgba(99, 102, 241, 0.4);
  border-radius: var(--radius);
  padding: 40px 24px;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--primary-light);
  margin-bottom: 24px;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.18);
  transform: translateY(-2px);
}

.drop-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  color: var(--primary);
}
.drop-icon svg { width: 100%; height: 100%; }

.drop-main {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.drop-sub {
  color: var(--text-subtle);
  font-size: 13px;
  margin-bottom: 16px;
}

.browse-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  font-family: inherit;
}
.browse-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.drop-hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-subtle);
}

/* Upload Error */
.upload-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: #f87171;
  font-size: 14px;
  margin-bottom: 16px;
  text-align: right;
}

/* Format Info */

/* ─── Map Screen ────────────────────────────────────────────── */
#map-screen {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 1000;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.map-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.count-badge {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.icon-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: rgba(99, 102, 241, 0.4);
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* Search */
.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 0 16px;
  position: relative;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
  width: 100%;
  max-width: 320px;
  transition: border-color var(--transition), background var(--transition);
}

.search-box:focus-within {
  border-color: rgba(99, 102, 241, 0.5);
  background: var(--surface);
}

.search-icon {
  width: 16px;
  height: 16px;
  color: var(--text-subtle);
  flex-shrink: 0;
}

#search-input {
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
  width: 100%;
  outline: none;
  direction: rtl;
}

#search-input::placeholder {
  color: var(--text-subtle);
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
  z-index: 2000;
}

.search-dropdown-item {
  padding: 9px 14px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition);
  text-align: right;
}

.search-dropdown-item:hover,
.search-dropdown-item.active {
  background: var(--primary-light);
  color: var(--primary);
}

.search-dropdown-item .match {
  color: var(--primary);
  font-weight: 700;
}

/* Legend */
.legend {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-left: 6px;
}
.legend-dot.approved { background: var(--approved); }
.legend-dot.pending { background: var(--pending); }

/* Map Container */
.map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  background: var(--bg);
}

/* Leaflet light overrides */
.leaflet-container {
  background: #e8edf2;
}

.leaflet-control-zoom a {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
.leaflet-control-zoom a:hover {
  background: var(--surface-2) !important;
}
.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.85) !important;
  color: var(--text-subtle) !important;
}
.leaflet-control-attribution a { color: var(--text-subtle) !important; }

/* Custom Popup */
.leaflet-popup-content-wrapper {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12) !important;
  color: var(--text) !important;
  font-family: inherit !important;
  direction: rtl;
}
.leaflet-popup-tip {
  background: var(--surface) !important;
}
.leaflet-popup-content {
  margin: 12px 16px !important;
  font-size: 14px !important;
  min-width: 160px;
}
.popup-name {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
}
.popup-status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 20px;
  display: inline-block;
  font-weight: 600;
}
.popup-status.approved {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}
.popup-status.not-approved {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* ─── Info Panel ────────────────────────────────────────────── */
.info-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 380px;
  height: 100%;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 500;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(0);
  transition: transform var(--transition);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.4);
}

.info-panel.hidden {
  display: flex !important;
  transform: translateX(100%);
  pointer-events: none;
}

.panel-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.close-panel-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.close-panel-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}
.close-panel-btn svg { width: 14px; height: 14px; }

.panel-content {
  padding: 20px 20px 32px;
  overflow-y: auto;
  flex: 1;
}

/* Panel sections */
.panel-brand {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.panel-brand-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.2;
}

.panel-section {
  margin-bottom: 20px;
}

.panel-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-subtle);
  margin-bottom: 10px;
}

.panel-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 14px;
}

.panel-row-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-subtle);
  margin-top: 1px;
}
.panel-row-icon svg { width: 100%; height: 100%; }

.panel-row-label {
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 90px;
}

.panel-row-value {
  color: var(--text);
  word-break: break-word;
}

.panel-row-value a {
  color: var(--primary);
  text-decoration: none;
}
.panel-row-value a:hover { text-decoration: underline; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-approved {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-not-approved {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Feature chips */
.features-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.feature-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
}

.feature-chip.on {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.feature-chip.off {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-subtle);
  border: 1px solid var(--border);
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-subtle);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

/* Branches */
.branches-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.branch-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.branch-num {
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Divider */
.panel-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ─── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .upload-card { padding: 28px 20px; }
  .upload-card h1 { font-size: 22px; }

  .info-panel {
    width: 100%;
    height: 60%;
    top: auto;
    bottom: 0;
    right: 0;
    border-right: none;
    border-top: 1px solid var(--border);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.4);
  }
  .info-panel.hidden {
    transform: translateY(100%);
  }

  .header-right { display: none; }
  .header-center { display: none; }
}
