/* ==========================================================
   მარშუტების სისტემა — გლობალური სტილები
   პალიტრა: ღამის ასფალტის მუქი ლურჯი + საგზაო ნიშნის ქარვისფერი
   ========================================================== */

:root {
  --navy-950: #0b1526;
  --navy-900: #101f38;
  --navy-800: #16294a;
  --navy-700: #1f3660;
  --navy-600: #2b4a80;
  --steel-300: #9fb4d4;
  --steel-100: #e7edf7;
  --amber-500: #f2a63a;
  --amber-600: #d98d1f;
  --route-forward: #2f6fed;   /* წასვლის მარშუტი — ლურჯი */
  --route-backward: #e6473f;  /* დაბრუნების მარშუტი — წითელი */
  --success: #2fae66;
  --danger: #e6473f;
  --white: #ffffff;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --shadow-card: 0 12px 30px -12px rgba(11, 21, 38, 0.35);
  --font-display: "Noto Sans Georgian", "BPG Arial", "Sylfaen", -apple-system, "Segoe UI", Arial, sans-serif;
  --font-body: "Noto Sans Georgian", "BPG Arial", "Sylfaen", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-body);
  color: var(--navy-900);
  background: var(--steel-100);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-display); margin: 0 0 .4em; color: var(--navy-900); }

a { color: var(--route-forward); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font-family: inherit; }

/* ---------- ღილაკები ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; }
.btn-primary { background: var(--amber-500); color: var(--navy-950); }
.btn-primary:hover { background: var(--amber-600); }
.btn-dark { background: var(--navy-800); color: var(--white); }
.btn-dark:hover { background: var(--navy-700); }
.btn-outline { background: transparent; border: 1.5px solid var(--navy-700); color: var(--navy-800); }
.btn-outline:hover { background: var(--navy-800); color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #c73832; }
.btn-forward { background: var(--route-forward); color: var(--white); }
.btn-backward { background: var(--route-backward); color: var(--white); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------- ავტორიზაციის გვერდი ---------- */
.auth-body {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 15%, rgba(242, 166, 58, .18), transparent 45%),
    linear-gradient(160deg, var(--navy-950), var(--navy-800));
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 40px 34px;
}
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-brand-icon { font-size: 40px; }
.auth-brand h1 { font-size: 21px; margin-top: 8px; }
.auth-brand p { color: var(--navy-600); font-size: 13.5px; margin: 4px 0 0; }
.auth-form { display: flex; flex-direction: column; gap: 16px; margin-top: 10px; }
.auth-form label { font-size: 13.5px; font-weight: 600; color: var(--navy-800); display: flex; flex-direction: column; gap: 6px; }
.auth-form input {
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1.5px solid #d8e0ee;
  font-size: 15px;
}
.auth-form input:focus { outline: none; border-color: var(--route-forward); }
.auth-form .btn { margin-top: 6px; }

.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 14px; }
.alert-error { background: #fdecea; color: #a3271f; border: 1px solid #f6c7c2; }
.alert-success { background: #e6f7ec; color: #196b3e; border: 1px solid #b9e6c9; }

/* ---------- ლეიაუტი: header + nav ---------- */
.app-header {
  background: var(--navy-950);
  color: var(--white);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 18px -6px rgba(0,0,0,.35);
}
.app-header .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.app-header .brand-icon { font-size: 22px; }
.app-header nav { display: flex; align-items: center; gap: 6px; }
.app-header nav a, .app-header nav .user-chip {
  color: var(--steel-300);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
}
.app-header nav a:hover { background: var(--navy-800); color: var(--white); text-decoration: none; }
.app-header nav a.active { background: var(--navy-800); color: var(--amber-500); }
.user-chip { color: var(--steel-300) !important; font-weight: 500 !important; }

.app-main { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }

/* ---------- ბარათები / ცხრილები ---------- */
.card {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 22px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.route-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.route-card {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color .15s ease, transform .12s ease;
}
.route-card:hover { transform: translateY(-2px); }
.route-card.selected { border-color: var(--amber-500); }
.route-card h3 { font-size: 16px; }
.route-card p { color: var(--navy-600); font-size: 13.5px; margin: 0; flex-grow: 1; }
.route-card .route-meta { display: flex; gap: 8px; font-size: 12px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700;
}
.badge-forward { background: rgba(47,111,237,.12); color: var(--route-forward); }
.badge-backward { background: rgba(230,71,63,.12); color: var(--route-backward); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
table th, table td { text-align: left; padding: 11px 10px; border-bottom: 1px solid #ecf0f7; }
table th { color: var(--navy-600); font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
table tr:last-child td { border-bottom: none; }
.table-actions { display: flex; gap: 8px; justify-content: flex-end; }
.table-actions form { display: inline-flex; margin: 0; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--navy-600); }
.empty-state .empty-icon { font-size: 38px; margin-bottom: 10px; }

/* ---------- ფორმები ---------- */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group label { font-size: 13.5px; font-weight: 600; color: var(--navy-800); }
.form-group input, .form-group textarea, .form-group select {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid #d8e0ee;
  font-size: 14.5px;
  width: 100%;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { outline: none; border-color: var(--route-forward); }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 160px; }

/* ---------- რუკის რედაქტორი (admin) ---------- */
.editor-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  align-items: start;
}
.editor-panel { display: flex; flex-direction: column; gap: 16px; }
.toolbar { display: flex; flex-direction: column; gap: 8px; }
.toolbar-group { display: flex; flex-direction: column; gap: 8px; padding: 14px; background: #f5f7fc; border-radius: var(--radius-sm); }
.toolbar-group .toolbar-title { font-size: 12.5px; font-weight: 700; text-transform: uppercase; color: var(--navy-600); letter-spacing: .03em; }
.mode-btn { justify-content: flex-start; }
.mode-btn.active { box-shadow: 0 0 0 3px rgba(242,166,58,.35) inset; }

#map-canvas {
  width: 100%;
  height: 640px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.map-hint { font-size: 12.5px; color: var(--navy-600); background: #f5f7fc; padding: 10px 12px; border-radius: var(--radius-sm); }

.audio-list { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.audio-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 11px; background: #f5f7fc; border-radius: var(--radius-sm); font-size: 13px;
}
.audio-list-item .audio-title { font-weight: 600; }
.audio-list-item button { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 13px; }

/* ---------- ინსტრუქტორის რუკის ხედი ---------- */
.instructor-map-wrap { position: relative; }
#instructor-map { width: 100%; height: 72vh; min-height: 460px; border-radius: var(--radius-md); box-shadow: var(--shadow-card); }
.tracking-hud {
  position: absolute; top: 16px; left: 16px; right: 16px;
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 10px; pointer-events: none;
}
.hud-pill {
  background: rgba(11,21,38,.88); color: var(--white); backdrop-filter: blur(4px);
  padding: 10px 16px; border-radius: 30px; font-size: 13.5px; font-weight: 600;
  display: flex; align-items: center; gap: 8px; pointer-events: auto;
}
.hud-pill.phase-forward { box-shadow: 0 0 0 2px var(--route-forward) inset; }
.hud-pill.phase-backward { box-shadow: 0 0 0 2px var(--route-backward) inset; }
.hud-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--route-forward); }
.hud-pill.phase-backward .hud-dot { background: var(--route-backward); }
.hud-stop-btn { pointer-events: auto; }

.now-playing {
  position: absolute; bottom: 16px; left: 16px; right: 16px;
  background: rgba(11,21,38,.9); color: var(--white); padding: 12px 18px;
  border-radius: var(--radius-sm); font-size: 14px; display: none; align-items: center; gap: 10px;
}
.now-playing.show { display: flex; }
.now-playing .pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--amber-500); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1);} 50% { opacity: .4; transform: scale(1.5);} }

.gps-warning { background: #fdecea; color: #a3271f; padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13.5px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .editor-layout { grid-template-columns: 1fr; }
  #map-canvas { height: 420px; }
}
@media (max-width: 640px) {
  .app-header { padding: 0 14px; }
  .app-header .brand span.brand-text { display: none; }
  .app-main { padding: 18px 12px 40px; }
  .auth-card { padding: 30px 22px; }
  table { font-size: 13px; }
  table th:nth-child(3), table td:nth-child(3) { display: none; }
  .card-header { flex-direction: column; align-items: flex-start; }
  .hud-pill span.hud-label-long { display: none; }
}
