/* ============================================================
   IP Information Dashboard — Custom Styles
   Glassmorphism, animations, light/dark theme overrides
   ============================================================ */

/* ---- IP Search Input ---- */
.ip-search-input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f3f4f6;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ip-search-input::placeholder {
  color: #6b7280;
}

.ip-search-input:focus {
  outline: none;
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.ip-search-input.invalid {
  border-color: rgba(239, 68, 68, 0.5);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

html:not(.dark) .ip-search-input {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0, 0, 0, 0.12);
  color: #111827;
}

html:not(.dark) .ip-search-input::placeholder {
  color: #9ca3af;
}

/* ---- Base & Background ---- */
body {
  background: #0f0f1a;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(6, 182, 212, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 60% 80%, rgba(139, 92, 246, 0.08) 0%, transparent 50%);
  background-attachment: fixed;
  transition: background 0.4s ease;
}

html:not(.dark) body {
  background: #f0f4ff;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(6, 182, 212, 0.06) 0%, transparent 50%);
}

/* ---- Glassmorphism Cards ---- */
.glass-card {
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.glass-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.14);
}

html:not(.dark) .glass-card {
  background: rgba(255, 255, 255, 0.75);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

html:not(.dark) .glass-card:hover {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border-color: rgba(99, 102, 241, 0.2);
}

/* ---- Navbar ---- */
.glass-nav {
  background: rgba(15, 15, 26, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

html:not(.dark) .glass-nav {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(0, 0, 0, 0.08) !important;
}

/* ---- Stat Cards (injected by JS) ---- */
.stat-card {
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 0.875rem;
  padding: 1rem 1.25rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  animation: slideUp 0.4s ease-out forwards;
  opacity: 0;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
}

html:not(.dark) .stat-card {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(0, 0, 0, 0.06);
}

html:not(.dark) .stat-card:hover {
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.1);
}

.stat-card .stat-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.625rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.stat-card .stat-label {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  margin-bottom: 0.25rem;
}

.stat-card .stat-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f3f4f6;
  word-break: break-word;
  line-height: 1.4;
}

html:not(.dark) .stat-card .stat-value {
  color: #1f2937;
}

/* ---- Buttons ---- */
.btn-primary {
  padding: 0.5rem 1rem;
  border-radius: 0.625rem;
  font-size: 0.875rem;
  font-weight: 500;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  padding: 0.5rem 1rem;
  border-radius: 0.625rem;
  font-size: 0.875rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.06);
  color: #e5e7eb;
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

html:not(.dark) .btn-secondary {
  background: rgba(0, 0, 0, 0.04);
  color: #374151;
  border-color: rgba(0, 0, 0, 0.1);
}

html:not(.dark) .btn-secondary:hover:not(:disabled) {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.3);
}

.btn-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.625rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #9ca3af;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #e5e7eb;
}

html:not(.dark) .btn-icon {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.08);
  color: #6b7280;
}

/* ---- Info Pills ---- */
.info-pill {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.625rem 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

html:not(.dark) .info-pill {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.06);
}

html:not(.dark) .info-pill span:last-child {
  color: #1f2937 !important;
}

/* ---- Loading Spinner ---- */
.spinner {
  width: 3rem;
  height: 3rem;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ---- Refresh Icon Spin ---- */
.spinning {
  animation: spin 0.8s linear infinite;
}

/* ---- Leaflet Map Overrides ---- */
#map .leaflet-control-zoom a {
  background: rgba(30, 30, 46, 0.9) !important;
  color: #e5e7eb !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

#map .leaflet-control-attribution {
  background: rgba(15, 15, 26, 0.8) !important;
  color: #9ca3af !important;
  font-size: 10px;
}

/* ---- Light Mode Text Overrides ---- */
html:not(.dark) h1,
html:not(.dark) h2,
html:not(.dark) .text-white {
  color: #111827 !important;
}

html:not(.dark) .text-gray-400 {
  color: #6b7280 !important;
}

html:not(.dark) .text-gray-500 {
  color: #9ca3af !important;
}

html:not(.dark) footer .text-gray-500,
html:not(.dark) footer .text-gray-600 {
  color: #9ca3af !important;
}

html:not(.dark) #connection-status {
  background: rgba(34, 197, 94, 0.1) !important;
}

html:not(.dark) #public-ip {
  color: #111827 !important;
}

/* ---- Animations ---- */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---- Toast Visible State ---- */
#toast.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.4);
  border-radius: 3px;
}
