/* ========================================
   Time Zone Finder - Open Source Edition
   Modern, Premium Design System
   ======================================== */

/* --- CSS Variables --- */
:root {
  --color-primary: #6366f1;
  --color-primary-dark: #4f46e5;
  --color-primary-light: #818cf8;
  --color-secondary: #0ea5e9;
  --color-accent: #10b981;
  --color-warning: #f59e0b;

  --color-bg-dark: #0f172a;
  --color-bg-card: rgba(15, 23, 42, 0.85);
  --color-bg-card-solid: #1e293b;
  --color-surface: rgba(30, 41, 59, 0.9);

  --color-text-primary: #f8fafc;
  --color-text-secondary: #94a3b8;
  --color-text-muted: #64748b;

  --color-border: rgba(148, 163, 184, 0.2);
  --color-glow: rgba(99, 102, 241, 0.4);

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 30px var(--color-glow);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
}

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

html,
body {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-family);
  background: var(--color-bg-dark);
  color: var(--color-text-primary);
  line-height: 1.6;
}

/* --- Map Container --- */
#mapDiv {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

/* --- Header --- */
.header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: linear-gradient(to bottom, var(--color-bg-card), transparent);
  padding: 1rem 1.5rem;
  pointer-events: none;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1400px;
  margin: 0 auto;
  pointer-events: auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 32px;
  height: 32px;
  color: var(--color-primary-light);
  filter: drop-shadow(0 0 8px var(--color-glow));
}

.logo h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text-primary);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* --- Map Controls (under Leaflet zoom) --- */
.map-controls {
  position: absolute;
  top: 90px;
  /* Position below Leaflet zoom controls */
  right: 10px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-control-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-md);
}

.map-control-btn:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md), 0 0 15px var(--color-glow);
}

.map-control-btn svg {
  width: 18px;
  height: 18px;
  color: var(--color-text-primary);
  transition: color var(--transition-fast);
}

.map-control-btn:hover svg {
  color: white;
}

/* --- Collapsible Search --- */
.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-toggle {
  z-index: 10;
}

.search-wrapper.expanded .search-toggle {
  opacity: 0;
  pointer-events: none;
}

.search-container {
  position: absolute;
  right: 0;
  top: 0;
  width: 0;
  opacity: 0;
  overflow: hidden;
  transition: all var(--transition-normal);
}

.search-wrapper.expanded .search-container {
  width: 280px;
  opacity: 1;
  overflow: visible;
}

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

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

.search-input {
  width: 100%;
  padding: 0.65rem 2.5rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-family: var(--font-family);
  font-size: 0.875rem;
  color: var(--color-text-primary);
  outline: none;
  transition: all var(--transition-fast);
  backdrop-filter: blur(10px);
}

.search-input::placeholder {
  color: var(--color-text-muted);
}

.search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.search-input:focus+.search-icon,
.search-input:not(:placeholder-shown)+.search-icon {
  color: var(--color-primary-light);
}

.search-close {
  position: absolute;
  right: 8px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.search-close:hover {
  background: var(--color-border);
}

.search-close svg {
  width: 14px;
  height: 14px;
  color: var(--color-text-muted);
}

.search-close:hover svg {
  color: var(--color-text-primary);
}

/* Search Results Dropdown */
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  background: var(--color-bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  list-style: none;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all var(--transition-fast);
}

.search-results.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.search-results li {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition-fast);
}

.search-results li:last-child {
  border-bottom: none;
}

.search-results li:hover,
.search-results li.focused {
  background: var(--color-surface);
}

.search-results li .result-name {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-primary);
  margin-bottom: 0.15rem;
}

.search-results li .result-detail {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-results .no-results {
  padding: 1rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.search-results .searching {
  padding: 1rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.search-results .searching::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border: 2px solid var(--color-text-muted);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* --- Info Panel --- */
.info-panel {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: var(--color-bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  min-width: 320px;
  max-width: 500px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  transition: all var(--transition-normal);
  animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.info-panel:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-lg), 0 0 40px var(--color-glow);
}

.info-panel.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
  pointer-events: none;
}

.info-content {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.info-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.info-icon svg {
  width: 24px;
  height: 24px;
  color: white;
}

.info-text {
  flex: 1;
  min-width: 0;
}

.info-text h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.info-text p {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.time-display {
  flex-shrink: 0;
  text-align: right;
  padding-left: 1rem;
  border-left: 1px solid var(--color-border);
}

.current-time {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary-light);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.time-label {
  display: block;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.close-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-card-solid);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  transition: all var(--transition-fast);
}

.info-panel:hover .close-btn {
  opacity: 1;
}

.close-btn:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.close-btn svg {
  width: 12px;
  height: 12px;
  color: var(--color-text-secondary);
}

.close-btn:hover svg {
  color: white;
}

/* --- Leaflet Customizations --- */
.leaflet-container {
  background: var(--color-bg-dark);
  font-family: var(--font-family);
}

.leaflet-control-zoom {
  border: none !important;
  box-shadow: var(--shadow-md) !important;
}

.leaflet-control-zoom a {
  background: var(--color-bg-card) !important;
  backdrop-filter: blur(10px);
  color: var(--color-text-primary) !important;
  border: 1px solid var(--color-border) !important;
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  font-size: 18px !important;
  transition: all var(--transition-fast);
}

.leaflet-control-zoom a:hover {
  background: var(--color-primary) !important;
  color: white !important;
  border-color: var(--color-primary) !important;
}

.leaflet-control-zoom-in {
  border-radius: var(--radius-sm) var(--radius-sm) 0 0 !important;
}

.leaflet-control-zoom-out {
  border-radius: 0 0 var(--radius-sm) var(--radius-sm) !important;
  border-top: none !important;
}

.leaflet-control-attribution {
  background: var(--color-bg-card) !important;
  backdrop-filter: blur(10px);
  color: var(--color-text-muted) !important;
  padding: 4px 8px !important;
  border-radius: var(--radius-sm) 0 0 0;
  font-size: 0.65rem !important;
}

.leaflet-control-attribution a {
  color: var(--color-primary-light) !important;
}

/* Custom marker */
.timezone-marker {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3), 0 0 20px var(--color-glow);
  transition: all var(--transition-fast);
}

.timezone-marker:hover {
  transform: scale(1.2);
}

/* Popup styling */
.leaflet-popup-content-wrapper {
  background: var(--color-bg-card) !important;
  backdrop-filter: blur(20px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg) !important;
  color: var(--color-text-primary) !important;
}

.leaflet-popup-tip {
  background: var(--color-bg-card) !important;
  border: 1px solid var(--color-border);
}

.leaflet-popup-close-button {
  color: var(--color-text-muted) !important;
}

.leaflet-popup-close-button:hover {
  color: var(--color-primary-light) !important;
}

/* --- Footer (collapsible) --- */
.footer {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--color-bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  overflow: hidden;
  transition: all var(--transition-normal);
}

.footer:hover,
.footer.expanded {
  width: auto;
  height: auto;
  padding: 0.5rem 1rem;
  justify-content: flex-start;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md), 0 0 15px var(--color-glow);
}

.footer-heart {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
  animation: heartbeat 1.5s ease-in-out infinite;
}

.footer-text {
  white-space: nowrap;
  opacity: 0;
  margin-left: 0;
  transition: all var(--transition-normal);
}

.footer:hover .footer-text,
.footer.expanded .footer-text {
  opacity: 1;
  margin-left: 0.5rem;
}

@keyframes heartbeat {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.15);
  }
}

.footer a {
  color: var(--color-primary-light);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition-fast);
}

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


/* --- Responsive Design --- */
@media (max-width: 768px) {
  .search-wrapper.expanded .search-container {
    position: fixed;
    top: 0.75rem;
    left: 1rem;
    right: 1rem;
    width: auto;
    transform: none;
  }
}

@media (max-width: 600px) {
  .header {
    padding: 0.75rem 1rem;
  }

  .logo h1 {
    font-size: 1rem;
  }

  .info-panel {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    transform: none;
    min-width: auto;
    max-width: none;
  }

  @keyframes slideUp {
    from {
      opacity: 0;
      transform: translateY(20px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .info-panel.hidden {
    transform: translateY(20px);
  }

  .info-content {
    flex-wrap: wrap;
  }

  .time-display {
    width: 100%;
    text-align: center;
    padding-left: 0;
    padding-top: 0.75rem;
    margin-top: 0.75rem;
    border-left: none;
    border-top: 1px solid var(--color-border);
  }
}