/* Global base */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body { font-family: system-ui, sans-serif; }
/* Visibility helpers */
.hidden { display: none !important; }

/* Utility spacing (initial minimal set) */
.mt-4 { margin-top: 4px; }
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mb-4 { margin-bottom: 4px; }
.mb-6 { margin-bottom: 6px; }
.mb-8 { margin-bottom: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.items-center { align-items: center; }
.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.text-small { font-size: 12px; }
.text-tiny { font-size: 11px; }
.bold { font-weight: bold; }
.muted { color: #666; }
.clickable { cursor: pointer; }

/* Buttons */
.btn { background: #3498db; color: #fff; border: 0; border-radius: 4px; padding: 6px 10px; font-size: 12px; cursor: pointer; font-family: inherit; }
.btn:disabled { background: #8fbfe3; cursor: not-allowed; }
.btn-small { padding: 2px 6px; font-size: 11px; }
.btn-danger { background: #e74c3c; }
.btn-success { background: #2ecc71; }
.btn-secondary { background: #9b59b6; }
.btn-cancel { background: #7f8c8d; }

/* Text / color helpers */
.danger { color: #c0392b; }
.warning { color: #d35400; }
.info { color: #2c3e50; }
.success { color: #2e7d32; }

/* Minimal map attribution control (replaces default Leaflet attribution) */
.map-attrib-control {
  background: transparent;
  box-shadow: none;
  border: 0;
  padding: 0 4px;
  margin: 4px;
  font-size: 10px;
  line-height: 1.2;
  color: #666;
}
.map-attrib-control a { color: inherit; text-decoration: none; }
.map-attrib-control a:hover { text-decoration: underline; }

/* Additional spacing / layout */
.mr-6 { margin-right: 6px; }
.mb-6 { margin-bottom: 6px; }
.mb-10 { margin-bottom: 10px; }
.mt-10 { margin-top: 10px; }
.ml-8 { margin-left: 8px; }

/* Panel specific extensions */
.panel-title { font-weight: bold; margin-bottom: 6px; }
.panel-section-divider { margin-top: 10px; padding-top: 8px; border-top: 1px solid #eee; }
.controller-line { color: #333; display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.my-units-line { color: #555; display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.cooldown-label { font-size: 11px; color: #666; }
.note-text { font-size: 11px; color: #666; margin-top: 4px; }
.help-text { font-size: 12px; color: #555; }
.movement-preview { font-size: 12px; color: #555; margin-bottom: 6px; }
.qty-input { width: 70px; padding: 2px 4px; }
.contest-active { color: #c0392b; margin-bottom: 6px; }
.contest-countdown { font-size: 12px; color: #a93226; margin-top: 2px; }
.participants-box { margin-top: 6px; background: #fff5f5; border: 1px solid #f5c6cb; border-radius: 4px; padding: 6px; }
.participants-header { font-weight: bold; font-size: 12px; color: #8e2b2b; margin-bottom: 4px; }
.participants-list { display: grid; grid-template-columns: 1fr auto; gap: 4px; }
.grid-span-2 { grid-column: 1 / span 2; }
.movement-item { margin-bottom: 6px; }
.unit-row { display: flex; justify-content: space-between; font-size: 12px; padding: 4px 0; cursor: pointer; }
.unit-row .qty { font-weight: bold; }
.unit-row.deployed .qty { color: #28a745; }
.unit-row.transit .qty { color: #ffc107; }


/* Panels */
.panel { background: #fff; border-radius: 4px; box-shadow: 0 0 6px rgba(0,0,0,0.3); font-family: sans-serif; }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.panel-section { margin-top: 8px; }
.panel-floating { position: fixed; z-index: 1001; padding: 8px 10px; }

/* Toasts */
.toast-container { position: fixed; right: 10px; bottom: 10px; z-index: 2000; display: flex; flex-direction: column; gap: 6px; }
.toast { background: #3498db; color: #fff; padding: 8px 10px; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.2); font-size: 12px; max-width: 280px; font-family: sans-serif; }
.toast.success { background: #2ecc71; }
.toast.error { background: #e74c3c; }

/* Spinner */
.spinner-row { display: flex; align-items: center; gap: 8px; color: #333; }
.spinner { width: 14px; height: 14px; border: 2px solid #3498db; border-top-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; }

/* Loading overlay */
.loading-overlay { position: fixed; inset: 0; background: #f5f7fa; display: flex; align-items: center; justify-content: center; z-index: 3000; }
.loading-card { background: white; padding: 16px 18px; border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.12); min-width: 260px; }
.loading-title { font-weight: 700; color: #2c3e50; font-size: 14px; }
.loading-subtitle { color: #666; font-size: 12px; margin-top: 2px; }
/* Optional: a secondary note line in the loading card */
.loading-note { color: #777; font-size: 11px; margin-top: 6px; }

/* Map page (index.html) */
#map { width: 100vw; height: 100vh; position: absolute; top: 0; left: 0; }
#info {
  position: fixed;
  top: 10px;
  right: 10px;
  background: white;
  padding: 8px 12px;
  border-radius: 4px;
  box-shadow: 0 0 6px rgba(0,0,0,0.3);
  font-family: sans-serif;
  z-index: 1001;
  min-width: 200px;
  max-width: 250px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  display: block;
  visibility: visible;
}
@media (max-height: 600px) {
  #info { max-height: calc(100vh - 300px); }
}

#userbar {
  position: fixed;
  left: 10px;
  top: 10px;
  z-index: 1002;
  background: white;
  padding: 6px 10px;
  border-radius: 4px;
  box-shadow: 0 0 6px rgba(0,0,0,0.3);
  font-family: sans-serif;
  display: flex;
  gap: 8px;
  align-items: center;
}
#userLabel { font-size: 12px; color: #333; }
#userbar button { font-size: 12px; padding: 4px 8px; }

/* Panel floating (was inline styles) */
.panel-floating { position: fixed; z-index: 1001; padding: 8px 10px; right: 10px; top: 80px; max-width: 280px; max-height: 50vh; overflow-y: auto; }

/* Units toggle button (previous inline) */
.btn-units-toggle { font-size: 12px; padding: 4px 8px; }

/* Flag image styling (replacing inline styles) */
.flag-img { width: 20px; height: 15px; margin-left: 5px; vertical-align: middle; border: 1px solid #ddd; }

/* Region flag markers on the map */
.region-flag-icon { pointer-events: none; }
.region-flag { width: 24px; height: 18px; box-shadow: 0 0 3px rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.85); border-radius: 2px; background: rgba(255,255,255,0.6); }

/* Spinner keyframes used by panels */
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Movement arrow batch badge */
.arrow-badge-wrapper { pointer-events: none; }
.arrow-badge { background: rgba(52,152,219,0.9); color: #fff; font-size: 11px; line-height: 14px; padding: 0 4px; border-radius: 10px; font-weight: 600; box-shadow: 0 0 4px rgba(0,0,0,0.3); }

/* Auth page (auth.html) */
body.auth { display: grid; place-items: center; height: 100vh; margin: 0; background: #f5f7fa; }
.auth-card { background: white; padding: 20px; border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.08); width: 320px; }
.auth-card h1 { font-size: 18px; margin: 0 0 12px; }
.auth-card label { display: block; font-size: 12px; margin: 8px 0 4px; color: #444; }
.auth-card input, .auth-card select { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
.auth-card button { width: 100%; margin-top: 12px; padding: 10px; background: #3498db; border: 0; color: white; border-radius: 6px; font-weight: 600; cursor: pointer; }
.auth-card button:disabled { background: #8fbfe3; cursor: not-allowed; }
.auth-row { display: flex; gap: 8px; }
.auth-row > * { flex: 1; }
.auth-muted { color: #666; font-size: 12px; margin-top: 8px; text-align: center; }
.auth-error { color: #c0392b; font-size: 12px; margin-top: 8px; min-height: 16px; }
#modeLogin { background: #2ecc71; }
#modeRegister { background: #9b59b6; }

/* Stacked Units panel under Region Info (#info) */
#info .units-panel-section { margin-top: 12px; padding-top: 10px; border-top: 1px solid #eee; }

/* Socket health banner */
.socket-health-banner { position: fixed; top: 8px; left: 50%; transform: translateX(-50%); background: #c0392b; color: #fff; padding: 6px 14px; font-size: 13px; border-radius: 4px; box-shadow: 0 2px 6px rgba(0,0,0,0.25); z-index: 2000; transition: opacity .25s, transform .25s; opacity: 0; pointer-events: none; }
.socket-health-banner.visible { opacity: 0.95; }
.socket-health-banner.hidden { opacity: 0; }
