/* ============================================================
   Image GeoTag & Metadata Tool - Premium Dark Mode UI
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ---- CSS Variables ---- */
:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #0f0f23;
  --bg-surface: #161631;
  --bg-card: #1c1c3a;
  --bg-hover: #24244a;
  --bg-input: #12122a;

  --text-primary: #e8e8f0;
  --text-secondary: #9595b5;
  --text-muted: #606080;

  --accent-primary: #00d4ff;
  --accent-secondary: #7c5cff;
  --accent-success: #00e88f;
  --accent-warning: #ffd93d;
  --accent-danger: #ff6b6b;
  --accent-pink: #ff6bcc;

  --gradient-primary: linear-gradient(135deg, #00d4ff 0%, #7c5cff 100%);
  --gradient-accent: linear-gradient(135deg, #7c5cff 0%, #ff6bcc 100%);
  --gradient-success: linear-gradient(135deg, #00e88f 0%, #00d4ff 100%);

  --border-color: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(0, 212, 255, 0.3);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(0, 212, 255, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

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

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

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* ---- Header ---- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: rgba(15, 15, 35, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
}

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

.header-brand .logo {
  width: 38px;
  height: 38px;
  background: #fff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  overflow: hidden;
}

.header-brand h1 {
  font-size: 1.2rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-brand .badge {
  font-size: 0.65rem;
  background: var(--bg-hover);
  color: var(--accent-primary);
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
  border: 1px solid rgba(0, 212, 255, 0.2);
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.stat-item .count {
  color: var(--accent-primary);
  font-weight: 600;
}

/* ---- Global Settings Bar ---- */
.settings-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 28px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.setting-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.setting-group label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.setting-group input[type="text"],
.setting-group input[type="password"] {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: var(--font-family);
  outline: none;
  transition: border-color var(--transition);
  width: 180px;
}

.setting-group input:focus {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
}

.settings-bar .divider {
  width: 1px;
  height: 24px;
  background: var(--border-color);
  margin: 0 4px;
}

.api-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-hover);
  border-radius: 11px;
  transition: var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  bottom: 3px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: white;
}

.toggle-switch input:checked + .danger-slider {
  background: var(--accent-danger);
}

.btn-apply-global {
  background: var(--gradient-primary);
  border: none;
  color: #0a0a1a;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-apply-global:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

/* ---- Upload Zone ---- */
.upload-zone {
  padding: 20px 28px;
}

.drop-zone {
  border: 2px dashed var(--border-hover);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-secondary);
  position: relative;
  overflow: hidden;
}

.drop-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity var(--transition);
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent-primary);
  background: var(--bg-surface);
}

.drop-zone:hover::before,
.drop-zone.dragover::before {
  opacity: 0.03;
}

.drop-zone .icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  display: block;
}

.drop-zone h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.drop-zone p {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.drop-zone .file-types {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 8px;
}

.drop-zone input[type="file"] {
  display: none;
}

.drop-zone.compact {
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: center;
}

.drop-zone.compact .icon {
  font-size: 1.5rem;
  margin-bottom: 0;
}

.drop-zone.compact h3 {
  margin-bottom: 0;
}

.drop-zone.compact p,
.drop-zone.compact .file-types {
  display: none;
}

/* ---- Main Content Layout ---- */
.main-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  min-height: calc(100vh - 280px);
}

/* ---- Left Panel (Image list + Metadata form) ---- */
.left-panel {
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.panel-header h2 {
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-actions {
  display: flex;
  gap: 6px;
}

.btn-icon {
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-icon:hover {
  background: var(--accent-primary);
  color: var(--bg-primary);
  border-color: var(--accent-primary);
}

/* ---- Image Grid ---- */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
  padding: 12px;
  overflow-y: auto;
  max-height: 280px;
  min-height: 120px;
}

.image-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition);
}

.image-thumb:hover {
  border-color: var(--accent-primary);
  transform: scale(1.03);
}

.image-thumb.selected {
  border-color: var(--accent-primary);
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.3);
}

.image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-thumb .overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  font-size: 0.6rem;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.image-thumb .gps-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  background: var(--accent-success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  opacity: 0;
  transition: var(--transition);
}

.image-thumb .gps-badge.active {
  opacity: 1;
}

.image-thumb .remove-btn {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  background: rgba(255, 107, 107, 0.85);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 10px;
  cursor: pointer;
  opacity: 0;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-thumb:hover .remove-btn {
  opacity: 1;
}

.image-grid-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.image-grid-empty .icon {
  font-size: 2rem;
  margin-bottom: 8px;
  display: block;
}

/* ---- Metadata Form ---- */
.metadata-form {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
  border-top: 1px solid var(--border-color);
}

.metadata-form .form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.metadata-form .form-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.metadata-form .form-header .selected-file {
  font-size: 0.72rem;
  color: var(--accent-primary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: var(--font-family);
  outline: none;
  transition: border-color var(--transition);
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.1);
}

.form-group textarea {
  min-height: 60px;
}

.form-group .hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.form-disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ---- Right Panel (Map + GPS controls) ---- */
.right-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Map container */
#map {
  flex: 1;
  min-height: 350px;
  z-index: 1;
}

/* Override Leaflet styles */
.leaflet-container {
  background: var(--bg-secondary) !important;
  font-family: var(--font-family) !important;
}

.leaflet-popup-content-wrapper {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-lg) !important;
}

.leaflet-popup-tip {
  background: var(--bg-card) !important;
}

.custom-marker, .image-marker {
  background: none !important;
  border: none !important;
}

/* ---- GPS Controls ---- */
.gps-controls {
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

.gps-controls h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.gps-coords-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.gps-coords-row input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: var(--font-family);
  outline: none;
  transition: border-color var(--transition);
}

.gps-coords-row input:focus {
  border-color: var(--accent-primary);
}

.search-box {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.search-box input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: var(--font-family);
  outline: none;
  transition: border-color var(--transition);
}

.search-box input:focus {
  border-color: var(--accent-primary);
}

.search-box button {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.85rem;
}

.search-box button:hover {
  background: var(--accent-primary);
  color: var(--bg-primary);
}

.search-results {
  max-height: 120px;
  overflow-y: auto;
  margin-bottom: 10px;
}

.search-result-item {
  padding: 6px 10px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.search-result-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.gps-apply-mode {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.gps-apply-mode label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.gps-apply-mode input[type="radio"] {
  accent-color: var(--accent-primary);
}

.btn-apply-gps {
  width: 100%;
  background: var(--gradient-success);
  border: none;
  color: var(--bg-primary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-apply-gps:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(0, 232, 143, 0.2);
}

.btn-apply-gps:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ---- Action Bar (Footer) ---- */
.action-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  background: rgba(15, 15, 35, 0.9);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  position: sticky;
  bottom: 0;
  z-index: 1000;
  flex-wrap: wrap;
}

.btn-action {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  font-family: var(--font-family);
}

.btn-action:hover {
  transform: translateY(-1px);
}

.btn-action:active {
  transform: translateY(0);
}

.btn-action.primary {
  background: var(--gradient-primary);
  color: var(--bg-primary);
}

.btn-action.primary:hover {
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.25);
}

.btn-action.success {
  background: var(--gradient-success);
  color: var(--bg-primary);
}

.btn-action.success:hover {
  box-shadow: 0 0 20px rgba(0, 232, 143, 0.25);
}

.btn-action.accent {
  background: var(--gradient-accent);
  color: white;
}

.btn-action.accent:hover {
  box-shadow: 0 0 20px rgba(124, 92, 255, 0.25);
}

.btn-action.danger {
  background: transparent;
  color: var(--accent-danger);
  border-color: var(--accent-danger);
}

.btn-action.danger:hover {
  background: var(--accent-danger);
  color: white;
}

.btn-action:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Progress bar */
.progress-container {
  flex: 1;
  min-width: 200px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-hover);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 3px;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.progress-container.hidden {
  visibility: hidden;
}

/* ---- Toast Notifications ---- */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 0.82rem;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease;
  max-width: 360px;
  backdrop-filter: blur(8px);
}

.toast.success { border-left: 3px solid var(--accent-success); }
.toast.error { border-left: 3px solid var(--accent-danger); }
.toast.info { border-left: 3px solid var(--accent-primary); }
.toast.warning { border-left: 3px solid var(--accent-warning); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

.toast.removing {
  animation: slideOut 0.25s ease forwards;
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 24px;
  max-width: 500px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform var(--transition);
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal h3 {
  font-size: 1rem;
  margin-bottom: 16px;
}

.modal .modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

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

  .left-panel {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  #map {
    min-height: 300px;
  }

  .settings-bar {
    padding: 10px 16px;
    gap: 8px;
  }

  .setting-group input[type="text"],
  .setting-group input[type="password"] {
    width: 140px;
  }
}

@media (max-width: 640px) {
  .header {
    padding: 12px 16px;
  }

  .header-brand h1 {
    font-size: 1rem;
  }

  .upload-zone {
    padding: 12px 16px;
  }

  .drop-zone {
    padding: 24px;
  }

  .action-bar {
    padding: 10px 16px;
    gap: 6px;
  }

  .btn-action {
    padding: 7px 12px;
    font-size: 0.75rem;
  }

  .image-grid {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  }

  .setting-group input[type="text"],
  .setting-group input[type="password"] {
    width: 120px;
  }

  .gps-apply-mode {
    flex-direction: column;
    gap: 6px;
  }
}

/* ---- Utility Classes ---- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-accent { color: var(--accent-primary); }
.text-success { color: var(--accent-success); }
.text-danger { color: var(--accent-danger); }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.gap-2 { gap: 8px; }

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

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

/* Select all checkbox styling */
.select-all-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  margin-bottom: 4px;
}

.select-all-row label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.select-all-row input[type="checkbox"] {
  accent-color: var(--accent-primary);
}

/* ---- Project Context Bar ---- */
.project-context-bar {
  padding: 10px 28px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  animation: slideDown 0.3s ease;
}

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

.context-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.context-row:last-child {
  margin-bottom: 0;
}

.context-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-ctx {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-ctx:hover {
  background: var(--accent-primary);
  color: var(--bg-primary);
  border-color: var(--accent-primary);
}

.btn-ctx-danger:hover {
  background: var(--accent-danger);
  border-color: var(--accent-danger);
}

/* Select dropdown (settings) */
.setting-select {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  color: var(--text-primary);
  font-size: 0.78rem;
  font-family: var(--font-family);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239595b5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

.setting-select:focus {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
}

.setting-select option {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* ---- Provider Management Bar ---- */
.provider-bar {
  padding: 10px 28px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  animation: slideDown 0.3s ease;
}

.provider-bar-inner {
  display: flex;
  align-items: stretch;
  gap: 10px;
  flex-wrap: wrap;
}

.provider-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 230px;
  transition: border-color var(--transition);
}

.provider-card:hover {
  border-color: rgba(0, 212, 255, 0.2);
}

.provider-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.provider-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background var(--transition), box-shadow var(--transition);
}

.provider-dot.ok {
  background: var(--accent-success);
  box-shadow: 0 0 8px rgba(0, 232, 143, 0.5);
}

.provider-dot.error {
  background: var(--accent-danger);
  box-shadow: 0 0 8px rgba(255, 107, 107, 0.5);
}

.provider-dot.testing {
  background: var(--accent-warning);
  animation: dotPulse 1s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.provider-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.provider-last-used {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-left: auto;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.provider-card-body {
  display: flex;
  align-items: center;
  gap: 8px;
}

.provider-key-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text-primary);
  font-size: 0.78rem;
  font-family: var(--font-family);
  outline: none;
  transition: border-color var(--transition);
  min-width: 0;
}

.provider-key-input:focus {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
}

.btn-test-provider {
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  font-family: var(--font-family);
}

.btn-test-provider:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.btn-test-provider:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.provider-mode-card {
  min-width: 220px;
  flex: 0 0 auto;
}

.provider-select {
  width: 100%;
}

.provider-9router-card {
  min-width: 280px;
}

.provider-url-input {
  font-size: 0.72rem;
  color: var(--text-muted);
}
