:root {
  --primary: #107c41;
  --primary-hover: #0b5e31;
  --primary-light: #e8f5e9;
  --accent: #d32f2f;
  --accent-hover: #b71c1c;
  --bg: #f4f6f8;
  --card-bg: #ffffff;
  --text-main: #1a1a1a;
  --text-muted: #555555;
  --border: #d0d7de;
  --focus-ring: #005fb8;
  --active-field-bg: #fffde7;
  --active-field-border: #f57f17;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.4;
  padding-bottom: 120px; /* Space for floating bottom bar */
}

header {
  background-color: var(--primary);
  color: #ffffff;
  padding: 12px 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.header-container {
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-title h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.logo-title p {
  font-size: 0.85rem;
  opacity: 0.9;
}

.badge-no-login {
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.main-container {
  max-width: 700px;
  margin: 16px auto;
  padding: 0 14px;
}

/* KAFELKI / KARTY */
.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--border);
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 480px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
}

input[type="text"],
input[type="date"],
select {
  height: 48px;
  padding: 8px 12px;
  font-size: 1.1rem;
  font-weight: 600;
  border: 2px solid var(--border);
  border-radius: 8px;
  background-color: #fff;
  color: var(--text-main);
  transition: all 0.2s;
  text-transform: uppercase;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--focus-ring);
  background-color: #f0f7ff;
}

/* Wyróżnienie aktywnej komórki pod kątem dyktowania */
input.active-field {
  border-color: var(--active-field-border) !important;
  background-color: var(--active-field-bg) !important;
  box-shadow: 0 0 0 3px rgba(245, 127, 23, 0.3) !important;
}

/* PUNKTY BAZY (START, PRZEŁADUNEK I POWRÓT) */
.depot-card-editable {
  background: #fdfefe;
  border: 2px solid #81c784;
  border-left: 6px solid #2e7d32;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.depot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.depot-card-editable .depot-title {
  font-weight: 800;
  font-size: 1.05rem;
  color: #1b5e20;
  display: flex;
  align-items: center;
  gap: 6px;
}

.depot-address {
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 12px;
  font-weight: 500;
}

/* PRZYCISKI TYPU W BAZIE RABEN (KOLOROWE, DUŻE) */
.depot-buttons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.depot-btn {
  min-height: 48px;
  padding: 10px 8px;
  font-size: 0.95rem;
  font-weight: 800;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: all 0.15s ease-in-out;
}

/* 1. ZAŁADUNEK - NIEBIESKI */
.depot-btn-zaladunek {
  border: 2px solid #1976d2;
  background: #ffffff;
  color: #1565c0;
}
.depot-btn-zaladunek.selected {
  background: #1565c0;
  color: #ffffff;
  box-shadow: 0 3px 8px rgba(21, 101, 192, 0.4);
}

/* 2. ROZŁADUNEK - ZIELONY */
.depot-btn-rozladunek {
  border: 2px solid #2e7d32;
  background: #ffffff;
  color: #1b5e20;
}
.depot-btn-rozladunek.selected {
  background: #2e7d32;
  color: #ffffff;
  box-shadow: 0 3px 8px rgba(46, 125, 50, 0.4);
}

/* 3. POSTÓJ - POMARAŃCZOWY */
.depot-btn-postoj {
  border: 2px solid #f57f17;
  background: #ffffff;
  color: #e65100;
}
.depot-btn-postoj.selected {
  background: #ef6c00;
  color: #ffffff;
  box-shadow: 0 3px 8px rgba(239, 108, 0, 0.4);
}

/* 4. ROZŁADUNEK + POSTÓJ - FIOLETOWY */
.depot-btn-rozladunek-postoj {
  border: 2px solid #7b1fa2;
  background: #ffffff;
  color: #4a148c;
}
.depot-btn-rozladunek-postoj.selected {
  background: #7b1fa2;
  color: #ffffff;
  box-shadow: 0 3px 8px rgba(123, 31, 162, 0.4);
}

.depot-route-group {
  margin-top: 8px;
  background: #f8f9fa;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}

/* KARTA PUNKTU TRASY */
.point-card {
  border-left: 5px solid var(--primary);
  position: relative;
}

.point-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.point-number {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
}

.btn-remove-point {
  background: #ffebee;
  color: #c62828;
  border: 1px solid #ffcdd2;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-quick-raben {
  background: #e8f5e9;
  color: #1b5e20;
  border: 1px solid #a5d6a7;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s;
}

.btn-quick-raben:active {
  background: #c8e6c9;
}


/* PRZYCISKI FLAG (ROZŁADUNEK / ZAŁADUNEK / POSTÓJ) */
.flags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.flag-btn {
  flex: 1 1 calc(33.333% - 8px);
  min-height: 44px;
  padding: 8px 6px;
  font-size: 0.9rem;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: #444;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.flag-btn.selected-rozladunek {
  background: #e8f5e9;
  border-color: #2e7d32;
  color: #1b5e20;
}

.flag-btn.selected-zaladunek {
  background: #e3f2fd;
  border-color: #1565c0;
  color: #0d47a1;
}

.flag-btn.selected-postoj {
  background: #fff8e1;
  border-color: #f57f17;
  color: #e65100;
}

.flag-btn.selected-alert {
  background: #ffebee;
  border-color: #c62828;
  color: #b71c1c;
}

/* DWA PRZYCISKI DODAWANIA: KLIENT LUB BAZA RABEN */
.add-buttons-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 480px) {
  .add-buttons-container {
    grid-template-columns: 1fr;
  }
}

.btn-add-action {
  min-height: 52px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn-add-action:active {
  transform: scale(0.98);
}

.btn-add-client {
  background: #ffffff;
  color: var(--primary);
  border: 2px dashed var(--primary);
}
.btn-add-client:active {
  background: var(--primary-light);
}

.btn-add-raben {
  background: #e8f5e9;
  color: #1b5e20;
  border: 2px solid #81c784;
}
.btn-add-raben:active {
  background: #c8e6c9;
}

/* PRZYCISK FINALNY: ZAPISZ I WYŚLIJ */
.btn-save-final {
  width: 100%;
  min-height: 60px;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(16, 124, 65, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: transform 0.1s, background 0.2s;
}

.btn-save-final:active {
  transform: scale(0.98);
  background: var(--primary-hover);
}

/* PŁYWAJĄCY DOLNY PASEK STEROWANIA I GŁOSU */
.floating-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
  padding: 10px 14px;
  z-index: 200;
}

.bottom-bar-inner {
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.nav-btn {
  flex: 1;
  min-height: 52px;
  background: #eceff1;
  color: #263238;
  border: 1px solid #cfd8dc;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}

.nav-btn:active {
  background: #cfd8dc;
}

/* DUŻY PRZYCISK MIKROFONU */
.mic-btn {
  flex: 1.4;
  min-height: 56px;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 28px;
  font-size: 1.05rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(211, 47, 47, 0.35);
  transition: all 0.2s;
}

.mic-btn.recording {
  background: #d50000;
  animation: pulse-mic 1.2s infinite;
  box-shadow: 0 0 0 6px rgba(213, 0, 0, 0.3);
}

@keyframes pulse-mic {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.bottom-bar-header {
  max-width: 700px;
  margin: 0 auto 8px auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.active-field-indicator {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 700;
  color: #b78103;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-toggle-keyboard {
  background: #f1f3f4;
  border: 1px solid #cfd8dc;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #37474f;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: all 0.2s;
}

.btn-toggle-keyboard.active {
  background: #e3f2fd;
  border-color: #1976d2;
  color: #0d47a1;
  box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
}

/* MODAL SUKCESU */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.show {
  display: flex;
}

.modal-content {
  background: #fff;
  border-radius: 16px;
  max-width: 500px;
  width: 100%;
  padding: 24px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.modal-icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
}

.modal-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 10px;
}

.modal-text {
  font-size: 1rem;
  color: #444;
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-btn {
  display: block;
  width: 100%;
  min-height: 50px;
  line-height: 50px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  margin-bottom: 10px;
  cursor: pointer;
  border: none;
}

.modal-btn-download {
  background: #1565c0;
  color: #fff;
}

.modal-btn-close {
  background: #eceff1;
  color: #37474f;
}
