/* ====================================================================
   DPA Racing Walkie — hlavní styly
   Tmavé, "tactical" téma. Oranžový accent. Žádné kýčovité gradienty.
   ==================================================================== */

:root {
  --bg: #0E1116;
  --surface: rgba(26, 31, 38, 0.85);
  --surface-solid: #1A1F26;
  --primary: #FF6B35;
  --primary-dim: rgba(255, 107, 53, 0.12);
  --text: #F0F4F8;
  --text-muted: #8B95A1;
  --success: #10B981;
  --danger: #EF4444;
  --warning: #F59E0B;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast: 150ms;
  --t-med: 200ms;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; }

a { color: var(--primary); }

.text-muted { color: var(--text-muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ==================== LOGIN ==================== */
.login-body {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.bg-gradient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 600px 400px at 30% 20%, rgba(255, 107, 53, 0.10), transparent 60%),
    radial-gradient(ellipse 500px 400px at 75% 80%, rgba(66, 212, 244, 0.05), transparent 60%);
}

.login-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}

.login-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 24px;
}

.logo-mark {
  width: 110px;
  height: auto;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
}

.logo-img {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 4px 16px rgba(255, 107, 53, 0.25));
}

.login-title {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-subtitle {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.users-online {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 6px 12px;
  background: rgba(34, 197, 94, 0.10);
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  color: #86EFAC;
}
.users-online-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #22C55E;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: pulse-dot 2s ease-out infinite;
}
@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
  70%  { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
.users-online--empty {
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.3);
  color: var(--text-muted);
}
.users-online--empty .users-online-dot {
  background: #94A3B8;
  animation: none;
  box-shadow: none;
}
.users-online--error {
  background: rgba(239, 68, 68, 0.10);
  border-color: rgba(239, 68, 68, 0.35);
  color: #FCA5A5;
}
.users-online--error .users-online-dot {
  background: #EF4444;
  animation: none;
  box-shadow: none;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.field-input {
  background: #0B0E13;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 16px;
  padding: 12px 14px;
  outline: none;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}

.field-input:focus {
  border-color: var(--primary);
  background: #0D1117;
}

.error-slot {
  display: none;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #FCA5A5;
  font-size: 14px;
}

.login-footer {
  text-align: center;
  margin-top: 20px;
}

.login-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

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

/* ==================== BUTTONS ==================== */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-solid);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
}
.btn:hover { background: #222833; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #110A05;
}
.btn-primary:hover { background: #ff7f52; border-color: #ff7f52; }

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #f55a5a; }

.btn-secondary { /* default style */ }

.btn-full { width: 100%; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.btn-ghost:hover { background: rgba(255,255,255,0.05); }
.btn-ghost.btn-danger {
  border-color: rgba(239, 68, 68, 0.5);
  color: #FCA5A5;
  background: transparent;
}
.btn-ghost.btn-danger:hover { background: rgba(239, 68, 68, 0.15); }

/* Loading spinner v btn */
.btn-spinner {
  display: none;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.btn.is-loading .btn-label { opacity: 0.4; }
.btn.is-loading .btn-spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== APP LAYOUT ==================== */
.app-body {
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  touch-action: manipulation;
}

#map {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: #0B0E13;
}

/* Leaflet zoom control — zdrátujeme k našemu tématu */
.leaflet-container { background: #0B0E13; }
.leaflet-control-zoom {
  top: 76px !important;
  right: 12px !important;
  margin: 0 !important;
  border-radius: var(--radius-md) !important;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.leaflet-control-zoom a {
  background: var(--surface-solid) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
.leaflet-control-zoom a:hover { background: #2a303a !important; }
.leaflet-control-attribution {
  background: rgba(14, 17, 22, 0.75) !important;
  color: var(--text-muted) !important;
  font-size: 10px !important;
  backdrop-filter: blur(4px);
}
.leaflet-control-attribution a { color: var(--text-muted) !important; }

/* Top bar */
.top-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 14px;
  padding-top: calc(14px + env(safe-area-inset-top));
  pointer-events: none;
}
.top-bar > * { pointer-events: auto; }
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  box-shadow: var(--shadow-sm);
}
.icon-btn:hover { background: rgba(40, 46, 56, 0.85); }
.icon-btn:active { transform: scale(0.94); }

.me-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #0E1116;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.2);
}

/* PTT tlačítko */
.ptt-btn {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 1000;
  min-height: 80px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--primary);
  color: #110A05;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(255, 107, 53, 0.35), var(--shadow-md);
  transition: transform var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.ptt-btn:active,
.ptt-btn.ptt-btn--recording {
  transform: scale(0.98);
  background: #ff7f52;
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4), 0 0 0 4px rgba(255, 107, 53, 0.2);
}
.ptt-btn--receiving {
  background: var(--warning);
  color: #1A0F00;
  box-shadow: 0 10px 28px rgba(245, 158, 11, 0.35), var(--shadow-md);
  animation: pttPulse 1.5s ease-in-out infinite;
}
.ptt-btn--error {
  background: var(--danger);
  color: #fff;
}
.ptt-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

@keyframes pttPulse {
  0%, 100% { box-shadow: 0 10px 28px rgba(245, 158, 11, 0.35), 0 0 0 0 rgba(245, 158, 11, 0.5); }
  50%      { box-shadow: 0 10px 28px rgba(245, 158, 11, 0.35), 0 0 0 10px rgba(245, 158, 11, 0); }
}

/* Speaker banner nad PTT */
.speaker-banner {
  position: fixed;
  left: 50%;
  bottom: calc(104px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 1000;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--warning);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
}

/* ==================== MARKERY ==================== */
.user-marker-wrap { background: transparent !important; border: 0 !important; }

.user-marker {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--marker-color, #FF6B35);
  color: var(--marker-text, #fff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 3px solid rgba(14, 17, 22, 0.9);
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
  transition: transform var(--t-fast) var(--ease);
  position: relative;
}
.user-marker-initials { line-height: 1; }
.user-marker--inactive {
  opacity: 0.5;
  filter: grayscale(1);
}
.user-marker--speaking {
  animation: markerPulse 1.5s ease-in-out infinite;
}
.user-marker--speaking::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--warning);
  animation: markerPulseRing 1.5s ease-in-out infinite;
}
@keyframes markerPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.1); }
}
@keyframes markerPulseRing {
  0%   { opacity: 0.9; transform: scale(0.9); }
  100% { opacity: 0; transform: scale(1.4); }
}

/* Stop markery trasy */
.stop-marker-wrap { background: transparent !important; border: 0 !important; }
.stop-marker {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #0E1116;
  border: 2px solid var(--primary);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}
.stop-marker-label {
  position: absolute;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
}

/* Leaflet tooltip override */
.leaflet-tooltip {
  background: var(--surface-solid) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  font-size: 12px !important;
  padding: 4px 8px !important;
  border-radius: 6px !important;
  box-shadow: var(--shadow-sm) !important;
}
.leaflet-tooltip-top:before { border-top-color: var(--border) !important; }

/* ==================== TOAST ==================== */
.toast-container {
  position: fixed;
  left: 50%;
  top: calc(80px + env(safe-area-inset-top));
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 90vw;
}

.toast {
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease);
  pointer-events: auto;
  max-width: 100%;
  text-align: center;
}
.toast--in { opacity: 1; transform: translateY(0); }
.toast--success { border-color: rgba(16, 185, 129, 0.4); color: #6EE7B7; }
.toast--error   { border-color: rgba(239, 68, 68, 0.4);  color: #FCA5A5; }
.toast--info    { /* default */ }

/* ==================== BOTTOM SHEET ==================== */
.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: rgba(0, 0, 0, 0);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: background var(--t-med) var(--ease);
}
.sheet-overlay--in { background: rgba(0, 0, 0, 0.5); }

.sheet {
  width: 100%;
  max-width: 520px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 8px 20px 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  max-height: 80vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 220ms var(--ease);
  box-shadow: var(--shadow-lg);
}
.sheet--in { transform: translateY(0); }

.sheet-handle {
  width: 42px; height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  margin: 6px auto 14px;
  cursor: grab;
}

.sheet-header { margin-bottom: 16px; }
.sheet-title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.sheet-sub {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.section-title {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.settings-section { margin-top: 18px; }

/* Trasy */
.route-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.route-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 14px 16px;
  background: #0E1318;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.route-item:hover { background: #141922; border-color: var(--border-strong); }
.route-item:active { transform: scale(0.995); }
.route-item-title {
  font-size: 15px;
  font-weight: 600;
}
.route-item-desc {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-primary);
  opacity: 0.85;
}
.route-item-warning {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.12);
  border-radius: 10px;
  color: #FCA5A5;
  font-size: 12.5px;
  line-height: 1.4;
  font-weight: 500;
}
.route-item-warning svg { flex-shrink: 0; margin-top: 1px; color: #EF4444; }
.route-item--warning { border-color: rgba(239, 68, 68, 0.35); }
.route-item--warning:hover { border-color: rgba(239, 68, 68, 0.6); }
.route-item-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.route-item-maps {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(66, 133, 244, 0.12);
  border: 1px solid rgba(66, 133, 244, 0.5);
  border-radius: 10px;
  color: #8AB4F8;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.route-item-maps:hover {
  background: rgba(66, 133, 244, 0.2);
  border-color: rgba(66, 133, 244, 0.8);
}
.route-item-maps svg { flex-shrink: 0; }

.route-item--active {
  background: rgba(255, 107, 53, 0.08);
  border-color: var(--primary);
}
.route-item--active:hover {
  background: rgba(255, 107, 53, 0.14);
  border-color: var(--primary);
}
.route-item--active .route-item-title::after {
  content: ' ✓';
  color: var(--primary);
}

/* Uživatelé */
.user-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #0E1318;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.user-chip {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.user-row-main {
  flex: 1;
  min-width: 0;
}
.user-row-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-row-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex; align-items: center; gap: 6px;
}
.user-row-actions { flex-shrink: 0; }

.gps-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block;
}
.gps-dot--on { background: var(--success); }
.gps-dot--off { background: var(--text-muted); }

.badge {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  margin-left: 6px;
  vertical-align: middle;
}
.badge--admin {
  background: var(--primary-dim);
  color: var(--primary);
  border: 1px solid rgba(255, 107, 53, 0.3);
}

/* Switch row */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #0E1318;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  cursor: pointer;
}
.switch-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 40px; height: 22px;
  background: #222833;
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
  flex-shrink: 0;
}
.switch-row input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--t-fast) var(--ease);
}
.switch-row input[type="checkbox"]:checked {
  background: var(--primary);
}
.switch-row input[type="checkbox"]:checked::after {
  transform: translateX(18px);
}

/* ==================== MODAL ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1800;
  background: rgba(0,0,0,0);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  transition: background var(--t-med) var(--ease);
}
.modal-overlay--in { background: rgba(0,0,0,0.6); }

.modal {
  width: 100%;
  max-width: 400px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-lg);
  transform: translateY(10px);
  opacity: 0;
  transition: transform var(--t-med) var(--ease), opacity var(--t-med) var(--ease);
}
.modal-overlay--in .modal {
  transform: translateY(0);
  opacity: 1;
}

.modal-title {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 700;
}
.modal-body {
  font-size: 14px;
  color: var(--text);
}
.modal-body p { margin: 0 0 8px; }
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
  flex-wrap: wrap;
}
