/* Base layout */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #0f172a;
  color: #e5e7eb;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Map */

.map-wrapper {
  flex: 1;
  position: relative;
}

#map {
  position: absolute;
  inset: 0;
}

.map-toolbar {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    z-index: 1000;
  }
  
  .map-toolbar .btn {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    background: rgba(15, 23, 42, 0.9);
    border-radius: 0.375rem;
  }

  .map-toolbar .btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;   /* align content left */
    text-align: left;
    gap: 0.35rem;                   /* space between icon + text */
    padding-left: 0.5rem;           /* optional: tiny left padding */
  }

  .map-toolbar .btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .path-node-marker {
    width: 20px;
    height: 20px;
    border-radius: 999px;
    border: 2px solid #eab308;
    background-color: rgba(234, 179, 8, 0.15);
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.6);
  }

/* Sidebar */

.sidebar {
    width: 420px;
    max-width: 100%;
    background: #020617;
    border-left: 1px solid #1f2937;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
  }

.app-title {
  font-size: 1.15rem;
  margin: 0 0 0.25rem;
  text-align: left;
}

/* Panels */

.panel {
  background: #020617;
  border: 1px solid #1f2937;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
}

.panel-header {
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

/* Info rows / buttons */

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}

.inline-label {
  font-size: 0.75rem;
}

.buttons-row {
  display: flex;
  gap: 0.5rem;
  margin: 0.35rem 0;
  flex-wrap: wrap;
}

.course-controls {
  display: flex;
  gap: 0.5rem;
  margin: 0.25rem 0;
}

.course-controls select {
  flex: 1;
  padding: 0.2rem 0.3rem;
  font-size: 0.8rem;
  border-radius: 0.25rem;
  border: 1px solid #4b5563;
  background: #020617;
  color: #e5e7eb;
}

.mode-toggle {
    display: flex;
    gap: 0.25rem;
  }
  
  .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
  }
  
  .lang-switcher {
    position: relative;
  }
  
  .lang-button {
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
    border-radius: 999px;
    border: 1px solid #4b5563;
    background: #020617;
    color: #e5e7eb;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
  }
  
  .lang-button:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
  }
  
  .lang-menu {
    position: absolute;
    right: 0;
    top: 120%;
    background: #020617;
    border: 1px solid #4b5563;
    border-radius: 0.5rem;
    padding: 0.25rem;
    display: none;
    min-width: 7rem;
    z-index: 1200;
  }
  
  .lang-menu.open {
    display: block;
  }
  
  .lang-option {
    width: 100%;
    text-align: left;
    padding: 0.25rem 0.4rem;
    border-radius: 0.375rem;
    border: none;
    background: transparent;
    color: #e5e7eb;
    cursor: pointer;
    font-size: 0.8rem;
  }
  
  .lang-option:hover {
    background: rgba(148, 163, 184, 0.2);
  }
  
  .lang-option {
    display: flex;
    align-items: center;
    gap: 0.4rem;
  }
  
  .lang-flag {
    font-size: 1rem;
    line-height: 1;
  }
  
  .lang-button span {
    display: inline-block;
    vertical-align: middle;
  }

  .lang-flag-icon {
    width: 22px;
    height: auto;
    border-radius: 3px;
  }
  
  .lang-menu-flag {
    width: 20px;
    height: auto;
    margin-right: 6px;
    border-radius: 3px;
  }
/* Buttons */
.btn-icon svg {
    width: 100%;
    height: 100%;
    display: block;
  }
  .btn-icon {
    width: 1.1rem;
    height: 1.1rem;
    margin-right: 0.3rem;
    vertical-align: middle;
  }
.btn {
  border: 1px solid #4b5563;
  background: #111827;
  color: #e5e7eb;
  padding: 0.25rem 0.5rem;
  border-radius: 0.35rem;
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
}

.btn:hover {
  background: #1f2937;
}

.btn-small {
  font-size: 0.76rem;
  padding: 0.2rem 0.45rem;
}


.toolbar-btn-green {
    color: #03ff60;
  }
  .toolbar-btn-red {
    color: #ef4444; /* red-500 */
  }


.btn-icon {
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  font-size: 0.85rem;
}

.btn-danger {
  border-color: #b91c1c;
  color: #fecaca;
}

.btn-danger:hover {
  background: #7f1d1d;
}

.btn-active {
  border-color: #22c55e;
  color: #bbf7d0;
}

/* Status */

.status-ok {
  color: #22c55e;
}

.status-bad {
  color: #f97373;
}

/* Targets panel */

.targets-panel {
  max-height: 40vh;
}

.targets-header {
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

.scroll-area {
  max-height: 24vh;
  overflow-y: auto;
}

/* Target rows */

.target-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  font-size: 0.8rem;
}

.target-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.target-label {
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.target-sub {
  color: #6b7280;
  font-size: 0.75rem;
}

.target-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

/* Paths panel */

.paths-panel {
  max-height: 30vh;
}

.paths-header {
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

.path-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  font-size: 0.8rem;
}

.path-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.path-label {
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.path-sub {
  color: #6b7280;
  font-size: 0.75rem;
}

/* Marker labels & handles */

.target-start-label {
  background: rgba(15, 23, 42, 0.9);
  border-radius: 999px;
  padding: 0.1rem 0.35rem;
  border: 1px solid #f97316;
  color: #f97316;
  font-size: 0.7rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}

.target-handle-marker {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fecaca;
  border: 2px solid #991b1b;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}

.small-input {
    width: 3.5rem;
    padding: 0.15rem 0.25rem;
    font-size: 0.8rem;
    border-radius: 0.25rem;
    border: 1px solid #4b5563;
    background: #020617;
    color: #e5e7eb;
  }

/* Path waypoint handle */

.path-handle-marker {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #9ca3af;
  border: 2px solid #4b5563;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}

/* Handle selection highlights */

.target-handle-marker.path-select-from,
.path-node-marker.path-select-from {
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.9);
  border-color: #22c55e;
}

.target-handle-marker.path-select-to,
.path-node-marker.path-select-to {
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.9);
  border-color: #3b82f6;
}

.target-handle-marker.path-select-selected,
.path-node-marker.path-select-selected {
  box-shadow: 0 0 8px rgba(234, 179, 8, 0.9);
  border-color: #eab308;
}

/* Disabled view button */

.view-disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}

/* Small tweaks */

label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

input[type="checkbox"] {
  cursor: pointer;
}

.path-color-input {
    width: 1.6rem;
    height: 1.6rem;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
  }

  
/* Gathering point handle (reuses target handle highlight classes) */
.gathering-handle-marker {
    background: #bfdbfe;        /* light blue */
    border-color: #1d4ed8;      /* blue border */
  }

/* =========================
   Mobile layout
   ========================= */
   @media (max-width: 768px) {
    .app-container {
      flex-direction: column;
    }
  
    .map-wrapper {
      flex: none;
      position: relative;
      height: 55vh; /* map gets upper ~55% of the screen */
    }
  
    #map {
      position: absolute;
      inset: 0;
    }
  
    .sidebar {
      width: 100%;
      max-width: 100%;
      border-left: none;
      border-top: 1px solid #1f2937;
      padding: 0.5rem;
      flex: none;
      max-height: 45vh; /* lower ~45% scrollable controls */
      overflow-y: auto;
    }
  
    .panel {
      padding: 0.4rem 0.55rem;
    }
  
    .buttons-row {
      gap: 0.35rem;
    }
  
    .btn {
      font-size: 0.75rem;
      padding: 0.2rem 0.45rem;
    }
  
    .btn-icon {
      width: 1.4rem;
      height: 1.4rem;
      font-size: 0.8rem;
    }
  
    .targets-panel,
    .paths-panel {
      max-height: none;
    }
  
    .scroll-area {
      max-height: 20vh; /* prevents list from taking everything */
    }
  
    .app-title {
      font-size: 1rem;
      margin-bottom: 0.25rem;
    }
  
    .info-row {
      font-size: 0.75rem;
    }
  
    .target-row,
    .path-row {
      font-size: 0.75rem;
    }
  
    .target-sub,
    .path-sub {
      font-size: 0.7rem;
    }
  }
  


  /* ===== Tabs ===== */

.tab-header {
    display: flex;
    border-bottom: 1px solid #1f2937;
    margin-bottom: 0.5rem;
  }
  
  .tab-button {
    flex: 1 1 0;
    padding: 0.4rem 0.6rem;
    background: #0f172a;
    border: none;
    cursor: pointer;
    color: #e5e7eb;
    font-size: 0.85rem;
    border-right: 1px solid #1f2937;
  }
  
  .tab-button:last-child {
    border-right: none;
  }
  
  .tab-button.active {
    background: #1e293b;
    font-weight: 600;
    border-bottom: 2px solid #3b82f6;
  }
  
  .tab-content {
    width: 100%;
  }
  
  .tab-panel {
    display: none;
  }
  
  .tab-panel.active {
    display: block;
  }
  

  /* === Auth & admin UI === */

/* === Auth bar === */

.auth-bar {
  position: fixed;
  top: 0.5rem;
  left: 3.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  background: rgba(15, 23, 42, 0.92);
  color: #e5e7eb;
  font-size: 0.8rem;
  z-index: 2100;
}

.auth-error {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: #fecaca;
}

/* === Login gate overlay === */
.auth-blocker {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000; /* BELOW the login modal */
}

.auth-blocker.hidden {
  display: none !important;
}

.auth-blocker-inner {
  background: #020617;
  color: #e5e7eb;
  padding: 1rem 1.5rem;
  border-radius: 0.75rem;
  max-width: 360px;
  width: calc(100% - 3rem);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
  text-align: center;
  font-size: 0.9rem;
}

.auth-blocker-inner p {
  margin: 0 0 0.75rem;
}

.auth-blocker-actions {
  margin-top: 0.6rem;
  display: flex;
  justify-content: flex-end;
}
.auth-bar #authStatus {
  display: none;
}

/* === Modals (login + admin) === */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000; /* ABOVE the blocker */
}

.modal.hidden {
  display: none !important;
}

.modal-content {
  position: relative;
  background: #020617;
  color: #e5e7eb;
  padding: 1rem 1.25rem 1.1rem;
  border-radius: 0.75rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
  max-width: 420px;
  width: 100%;
  font-size: 0.9rem;
}

.modal-content h2 {
  margin: 0 0 0.6rem;
  font-size: 1.1rem;
}

.modal-content h3 {
  margin: 0.75rem 0 0.4rem;
  font-size: 0.95rem;
}

.modal-subtitle {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: #9ca3af;
}

.modal-content label {
  display: block;
  margin-bottom: 0.5rem;
}

.modal-content input[type="text"],
.modal-content input[type="password"] {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border-radius: 0.375rem;
  border: 1px solid #4b5563;
  background: #020617;
  color: inherit;
  margin-top: 0.15rem;
  font-size: 0.85rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.75rem;
  gap: 0.5rem;
}

.modal-close {
  position: absolute;
  top: 0.3rem;
  right: 0.5rem;
  border: none;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  font-size: 1rem;
}

.modal-close:hover {
  color: #e5e7eb;
}

/* Admin table */

.admin-create-user {
  margin-bottom: 0.75rem;
}

.admin-checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.admin-users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-top: 0.4rem;
}

.admin-users-table th,
.admin-users-table td {
  border-bottom: 1px solid #1f2937;
  padding: 0.3rem 0.25rem;
}

.admin-tag {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 9999px;
  background: #f97316;
  color: #111827;
  font-size: 0.7rem;
  font-weight: 600;
}


.admin-create-club {
  margin-bottom: 0.75rem;
}

.admin-clubs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-top: 0.4rem;
}

.admin-clubs-table th,
.admin-clubs-table td {
  border-bottom: 1px solid #1f2937;
  padding: 0.3rem 0.25rem;
}