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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  color: #1a1a1a;
  background: #f5f5f5;
}

body {
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: #fff;
  border-bottom: 2px solid #f6821f;
  z-index: 1000;
  flex-shrink: 0;
}

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

.cf-logo {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.app-title {
  font-size: 18px;
  font-weight: 600;
  color: #1a1a1a;
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s, opacity 0.15s;
}

.btn:hover {
  opacity: 0.9;
}

.btn-header {
  background: #f5f5f5;
  color: #1a1a1a;
  border: 1px solid #d0d0d0;
}

.btn-header:hover {
  background: #e8e8e8;
}

/* Banner (errors/warnings) */
.banner {
  padding: 10px 20px;
  font-size: 13px;
  line-height: 1.5;
  z-index: 999;
  flex-shrink: 0;
}

.banner.hidden {
  display: none;
}

.banner.error {
  background: #fef2f2;
  border-bottom: 1px solid #fca5a5;
  color: #991b1b;
}

.banner.warning {
  background: #fffbeb;
  border-bottom: 1px solid #fbbf24;
  color: #92400e;
}

.banner.success {
  background: #f0fdf4;
  border-bottom: 1px solid #86efac;
  color: #166534;
}

.banner-close {
  float: right;
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: inherit;
  padding: 0 4px;
}

/* Progress indicator */
.progress {
  padding: 8px 20px;
  background: #eff6ff;
  border-bottom: 1px solid #93c5fd;
  z-index: 999;
  flex-shrink: 0;
}

.progress.hidden {
  display: none;
}

.progress-text {
  font-size: 13px;
  color: #1e40af;
  margin-bottom: 4px;
}

.progress-bar {
  height: 4px;
  background: #dbeafe;
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #3b82f6;
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
  animation: indeterminate 1.5s ease-in-out infinite;
}

@keyframes indeterminate {
  0% { width: 0%; margin-left: 0; }
  50% { width: 60%; margin-left: 20%; }
  100% { width: 0%; margin-left: 100%; }
}

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

/* Footer */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 6px 20px;
  background: #fff;
  border-top: 1px solid #e5e5e5;
  font-size: 11px;
  color: #666;
  flex-shrink: 0;
  z-index: 1000;
}

.app-footer a {
  color: #f6821f;
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

/* Leaflet tooltip override for datacenter markers */
.dc-tooltip {
  background: rgba(246, 130, 31, 0.9);
  border: none;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 3px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.dc-tooltip::before {
  border-top-color: rgba(246, 130, 31, 0.9);
}

/* Overlay / Modal */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.overlay.hidden {
  display: none;
}

.overlay-content {
  background: #fff;
  border-radius: 8px;
  width: 90%;
  max-width: 540px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.overlay-content.overlay-wide {
  max-width: 720px;
}

.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e5e5;
  flex-shrink: 0;
}

.overlay-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
}

.overlay-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #666;
  padding: 0 4px;
  line-height: 1;
}

.overlay-close:hover {
  color: #1a1a1a;
}

.overlay-body {
  padding: 16px 20px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.6;
  color: #333;
}

.overlay-body h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 14px 0 6px;
  color: #1a1a1a;
}

.overlay-body p {
  margin-bottom: 12px;
}

.overlay-body ul {
  margin: 0 0 12px 20px;
}

.overlay-body pre {
  background: #f5f5f5;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 12px;
  overflow-x: auto;
  margin: 8px 0;
}

.overlay-body code {
  background: #f0f0f0;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}

/* Help table */
.help-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 14px;
  font-size: 12px;
}

.help-table th,
.help-table td {
  text-align: left;
  padding: 6px 10px;
  border: 1px solid #e5e5e5;
}

.help-table th {
  background: #f5f5f5;
  font-weight: 600;
  color: #1a1a1a;
}

/* Datacenter list — region grouped */
.dc-list-grid {
  margin-top: 10px;
}

.dc-region-heading {
  font-size: 13px;
  font-weight: 600;
  color: #f6821f;
  padding: 10px 0 4px;
  border-bottom: 1px solid #e5e5e5;
  margin-bottom: 6px;
}

.dc-region-heading:first-child {
  padding-top: 0;
}

.dc-region-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 2px 16px;
  margin-bottom: 8px;
}

.dc-list-item {
  font-size: 12px;
  padding: 3px 0;
  color: #333;
  border-bottom: 1px solid #f0f0f0;
}

.dc-list-item .dc-country {
  color: #888;
  font-size: 11px;
}

/* Responsive */
@media (max-width: 600px) {
  .app-header {
    flex-direction: column;
    gap: 8px;
    padding: 8px 12px;
  }

  .header-right {
    width: 100%;
    flex-wrap: wrap;
    justify-content: stretch;
  }

  .header-right .btn {
    flex: 1 1 auto;
    justify-content: center;
    min-width: 0;
  }
}
