* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --green: #2e7d32;
  --green-bg: #e8f5e9;
  --orange: #e65100;
  --orange-bg: #fff3e0;
  --gray: #666;
  --gray-light: #f5f5f5;
  --gray-border: #e0e0e0;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-light);
  color: #333;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* --- LOGIN --- */

#login-screen {
  min-height: 100vh;
}

.login-bg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: url('/images/sign_in_background.jpg') no-repeat center center;
  background-size: cover;
  padding: 20px;
  position: relative;
}

.login-card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  padding: 30px 45px;
  width: 400px;
  max-width: 90vw;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  text-align: center;
}

.login-logo {
  display: block;
  margin: 0 auto 25px;
  max-width: 200px;
  height: auto;
}

.login-card form input[type="text"],
.login-card form input[type="password"] {
  width: 100%;
  padding: 9px 20px;
  border: none;
  border-radius: 100px;
  background: #ccc;
  font-size: 16px;
  height: 40px;
  margin-bottom: 12px;
  outline: none;
  text-align: center;
  color: #333;
}

.login-card form input::placeholder {
  color: #666;
  text-align: center;
}

.login-card form input:focus {
  background: #bbb;
}

/* Pole hesla s tlačítkem pro zobrazení */
.password-wrap {
  position: relative;
}

.password-wrap input {
  /* symetrický padding, aby text zůstal vycentrovaný i s ikonou */
  padding-left: 44px;
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  top: 20px; /* střed 40px vysokého inputu (margin-bottom je pod ním) */
  right: 14px;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  color: #333;
  opacity: 0.55;
  transition: opacity 0.2s;
}

.password-toggle:hover,
.password-toggle[aria-pressed="true"] {
  opacity: 1;
}

/* --- Ladící okno (debug) --- */
#dbg-toggle {
  position: fixed;
  bottom: 12px;
  right: 12px;
  z-index: 99999;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #222;
  color: #fff;
  font-size: 20px;
  line-height: 44px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  opacity: 0.85;
  padding: 0;
}

#dbg-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  background: #e53935;
  color: #fff;
  border-radius: 9px;
  font-size: 11px;
  line-height: 18px;
  padding: 0 4px;
  display: none;
  box-sizing: border-box;
}

#dbg-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99998;
  height: 45vh;
  background: #1e1e1e;
  color: #ddd;
  display: none;
  flex-direction: column;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.5);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
}

#dbg-panel.dbg-open {
  display: flex;
}

#dbg-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #2d2d2d;
  border-bottom: 1px solid #444;
  font-weight: 600;
}

#dbg-head button {
  margin-left: 6px;
  background: #444;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}

#dbg-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
  -webkit-overflow-scrolling: touch;
}

.dbg-row {
  white-space: pre-wrap;
  word-break: break-word;
  padding: 2px 0;
  border-bottom: 1px solid #2a2a2a;
}

.dbg-error { color: #ff8a80; }
.dbg-warn { color: #ffd180; }
.dbg-log { color: #b0bec5; }
.dbg-pending { color: #80cbc4; }

/* API ladici panel — stejne jako #dbg-panel, jen vlastni IDs */
#dbg-api-toggle {
  position: fixed;
  bottom: 12px;
  right: 68px; /* vlevo od 🐞 */
  z-index: 99999;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #222;
  color: #fff;
  font-size: 20px;
  line-height: 44px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  opacity: 0.85;
  padding: 0;
}

#dbg-api-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  background: #1a73e8;
  color: #fff;
  border-radius: 9px;
  font-size: 11px;
  line-height: 18px;
  padding: 0 4px;
  display: none;
  box-sizing: border-box;
}

#dbg-api-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99998;
  height: 45vh;
  background: #1e1e1e;
  color: #ddd;
  display: none;
  flex-direction: column;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.5);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
}

#dbg-api-panel.dbg-open {
  display: flex;
}

#dbg-api-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #2d2d2d;
  border-bottom: 1px solid #444;
  font-weight: 600;
}

#dbg-api-head button {
  margin-left: 6px;
  background: #444;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}

#dbg-api-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
  -webkit-overflow-scrolling: touch;
}

.dbg-api-row {
  white-space: pre-wrap;
  word-break: break-word;
  padding: 2px 0;
  border-bottom: 1px solid #2a2a2a;
  cursor: pointer;
}

.dbg-api-row:hover {
  background: #2a2a2a;
}

.dbg-api-details {
  margin: 4px 0 8px;
  padding: 8px 10px;
  background: #111;
  color: #cfd8dc;
  border-left: 3px solid #1a73e8;
  border-radius: 3px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 40vh;
  overflow-y: auto;
}

.btn-login {
  display: block;
  width: 100%;
  height: 40px;
  border: none;
  border-radius: 100px;
  background: #0094d2;
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.2s;
}

.btn-login:hover {
  background: #007bb5;
}

.btn-login:disabled,
.btn-login.btn-loading {
  background: #5aa9c8;
  cursor: progress;
  position: relative;
}

.btn-login.btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 14px;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

.login-footer {
  margin-top: 20px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.8rem;
}

.login-footer a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
}

.login-footer a:hover {
  color: #fff;
}

/* --- FORMS --- */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray);
  margin-bottom: 6px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--gray-border);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s;
  background: #fff;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
}

/* --- BUTTONS --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-full {
  width: 100%;
}

.btn-small {
  padding: 6px 14px;
  font-size: 0.85rem;
  background: rgba(255,255,255,0.2);
  color: #fff;
  border-radius: 6px;
}

.btn-small:hover {
  background: rgba(255,255,255,0.3);
}

/* --- ERRORS --- */

.error {
  background: #fdecea;
  color: #c62828;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

/* --- TOPBAR --- */

.topbar {
  background: var(--primary);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.topbar h1 {
  font-size: 1.2rem;
  font-weight: 700;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.detail-nav button {
  font-size: 1.4rem;
  line-height: 1;
  padding: 2px 12px;
}

.detail-nav button:disabled {
  opacity: 0.35;
  cursor: default;
}

.detail-nav button:disabled:hover {
  background: rgba(255,255,255,0.2);
}

/* --- FILTERS --- */

.filters {
  background: #fff;
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  border-bottom: 1px solid var(--gray-border);
}

.filters .form-group {
  flex: 1;
  min-width: 200px;
  margin-bottom: 0;
}

.filters .form-group.date-range {
  flex-basis: 100%;
}

/* Period buttons */

.period-buttons {
  display: flex;
  gap: 4px;
}

.btn-period {
  flex: 1;
  padding: 8px 6px;
  border: 2px solid var(--gray-border);
  border-radius: 8px;
  background: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-period:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-period.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Date range nav */

.date-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hide-zero-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 0.85rem;
  color: #555;
  cursor: pointer;
  user-select: none;
}

.hidden-count-hint {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: #888;
  text-align: center;
  font-style: italic;
}

.date-nav input[type="date"] {
  flex: 1;
  padding: 10px 12px;
  border: 2px solid var(--gray-border);
  border-radius: 8px;
  font-size: 0.9rem;
}

.date-nav input[type="date"]:focus {
  outline: none;
  border-color: var(--primary);
}

.date-sep {
  color: var(--gray);
  font-weight: 600;
}

.btn-nav {
  width: 40px;
  height: 40px;
  border: 2px solid var(--gray-border);
  border-radius: 8px;
  background: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-nav:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* --- SUMMARY --- */

.summary {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid var(--gray-border);
}

.summary-item {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 0;
}

.summary-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  margin-bottom: 2px;
}

.summary-sluzebni {
  background: var(--green-bg);
  color: var(--green);
}

.summary-soukroma {
  background: var(--orange-bg);
  color: var(--orange);
}

.summary-celkem {
  background: var(--gray-light);
  color: #333;
}

/* --- TRIPS LIST --- */

.trips-list {
  padding: 12px 16px;
}

.placeholder {
  text-align: center;
  color: var(--gray);
  padding: 40px 20px;
  font-size: 0.95rem;
}

.trip-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--green);
}

.trip-card.soukroma {
  border-left-color: var(--orange);
}

.trip-date {
  font-size: 0.8rem;
  color: var(--gray);
  margin-bottom: 6px;
}

.trip-route {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.trip-route .arrow {
  color: var(--gray);
  margin: 0 6px;
}

.trip-details {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--gray);
}

.trip-km {
  font-weight: 700;
  color: #333;
}

.trip-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.trip-badge.sluzebni {
  background: var(--green-bg);
  color: var(--green);
}

.trip-badge.soukroma {
  background: var(--orange-bg);
  color: var(--orange);
}

/* --- LOADING --- */

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px;
  color: var(--gray);
}

.loading[hidden] {
  display: none;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- SCREEN VISIBILITY --- */

.screen[hidden] {
  display: none !important;
}

/* --- MEZERA V JÍZDÁCH --- */

.trip-gap-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff0f0;
  border: 2px dashed #e53935;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
  color: #c62828;
}

.trip-gap-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.trip-gap-text {
  font-weight: 600;
  flex: 1;
}

.trip-gap-km {
  font-size: 0.85rem;
  opacity: 0.8;
}

/* --- TRIP CARD WRAPPER + TOGGLE --- */

.trip-card-wrapper {
  display: flex;
  overflow: hidden;
  border-radius: 12px;
  margin-bottom: 12px;
}

.trip-card-wrapper .trip-card {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
  border-radius: 12px 0 0 12px;
  cursor: pointer;
}

.btn-toggle-type {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 90px;
  min-width: 90px;
  padding: 8px;
  border: none;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  writing-mode: vertical-lr;
  text-orientation: mixed;
  letter-spacing: 1px;
}

.btn-toggle-type.soukroma {
  background: #fff0d4;
  color: #e88a00;
}

.btn-toggle-type.soukroma:hover,
.btn-toggle-type.soukroma:active {
  background: #e88a00;
  color: #fff;
}

.btn-toggle-type.sluzebni {
  background: #d4f0db;
  color: #34a853;
}

.btn-toggle-type.sluzebni:hover,
.btn-toggle-type.sluzebni:active {
  background: #34a853;
  color: #fff;
}

.btn-toggle-type.locked {
  background: #f0f0f0;
  color: #aaa;
  cursor: not-allowed;
  font-size: 1.2rem;
  writing-mode: horizontal-tb;
}

.btn-toggle-type.busy {
  cursor: progress;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.15);
}

.btn-toggle-type.locked:hover,
.btn-toggle-type.locked:active {
  background: #f0f0f0;
  color: #aaa;
}

/* Mobile: swipe to reveal */
@media (max-width: 768px) {
  .trip-card-wrapper {
    position: relative;
    overflow: hidden;
  }

  .trip-card-wrapper .trip-card {
    border-radius: 12px;
    transition: transform 0.25s ease;
    z-index: 1;
    position: relative;
    touch-action: pan-y; /* povolí jen vertikální scroll, horizontální zachytí JS */
    /* Peek: 16px volného místa napravo, kde se objeví okraj tlačítka */
    margin-right: 16px;
  }

  .trip-card-wrapper.swiped .trip-card {
    transform: translateX(-90px);
  }

  .btn-toggle-type {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 90px;
    border-radius: 0 12px 12px 0;
    writing-mode: horizontal-tb;
    z-index: 0;
    font-size: 0.75rem;
  }
}

/* --- DETAIL JÍZDY --- */

.detail-info {
  padding: 16px;
  background: #fff;
  border-bottom: 1px solid var(--gray-border);
}

.detail-row {
  margin-bottom: 8px;
}

.detail-row:last-child {
  margin-bottom: 0;
}

.detail-type-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Akční tlačítko přepnutí typu — orámované, se slovesem: jasně odlišené od badge (stavu) */
.detail-type-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 10px 18px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: #fff;
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.detail-type-btn:hover,
.detail-type-btn:active {
  background: var(--primary);
  color: #fff;
}

.detail-type-btn.busy {
  cursor: progress;
  opacity: 0.6;
}

.detail-locked {
  color: var(--gray);
  font-size: 0.9rem;
}

.map-wrapper {
  position: relative;
  width: 100%;
}

.map-container {
  height: 60vh;
  min-height: 300px;
  width: 100%;
}

.map-lock-btn {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--gray-border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  white-space: nowrap;
}

.map-container .placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--gray);
}

/* Leaflet marker dots */
.marker-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.marker-dot.start {
  background: #34a853;
}

.marker-dot.end {
  background: #ea4335;
}

#detail-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px;
  color: var(--gray);
}

#detail-loading[hidden] {
  display: none;
}

/* --- MODE SCREEN (řidič) --- */

.mode-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  min-height: 100vh;
  padding: 40px 24px;
  background: var(--gray-light);
}

.mode-top {
  text-align: center;
  width: 100%;
}

.mode-title {
  font-size: 1.4rem;
  color: var(--primary);
  margin-bottom: 16px;
}

.mode-vehicle-select {
  width: 100%;
  max-width: 320px;
  padding: 10px 14px;
  border: 2px solid var(--gray-border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
}

.mode-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.mode-toggle {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.25s;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  -webkit-tap-highlight-color: transparent;
}

.mode-toggle:active {
  transform: scale(0.94);
}

.mode-icon {
  font-size: 2.8rem;
  line-height: 1;
}

.mode-label {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: #fff;
}

.mode-sluzebni {
  background: var(--green);
}

.mode-soukroma {
  background: var(--orange);
}

.mode-hint {
  font-size: 0.85rem;
  color: var(--gray);
}

.mode-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.mode-link {
  color: var(--primary);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
}

.mode-link:hover {
  text-decoration: underline;
}

.mode-logout {
  background: rgba(0,0,0,0.08);
  color: var(--gray);
  font-size: 0.85rem;
}

/* --- RESPONSIVE --- */

@media (max-width: 480px) {
  .filters {
    flex-direction: column;
  }

  .topbar h1 {
    font-size: 1rem;
  }

.date-nav {
    gap: 4px;
  }

  .date-nav input[type="date"] {
    padding: 8px 4px;
    font-size: 0.8rem;
    min-width: 0;
  }

  .btn-nav {
    width: 34px;
    height: 34px;
    min-width: 34px;
    font-size: 1rem;
  }

  .date-sep {
    display: none;
  }
}
