/* 
 * Plánovač cest - Hybrid Design (V5)
 * Kombinace nejlepších prvků z různých verzí
 */

/* ===== PROMĚNNÉ ===== */
:root {
  /* Hlavní barvy Mapy.cz */
  --primary-color: #00AA00;
  --primary-hover: #008800;
  --primary-light: #E6F7E6;
  
  --success-color: #00AA00;
  --danger-color: #dc3545;
  --warning-color: #ffc107;
  
  /* Neutrální barvy */
  --dark-color: #212529;
  --text-color: #212529;
  --text-muted: #6c757d;
  --border-color: #dee2e6;
  --light-bg: #f8f9fa;
  
  --sidebar-width: 400px;
  --transition-speed: 200ms;
  
  /* Jemné stíny */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* ===== RESET & BASE ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-color);
  background-color: var(--light-bg);
  overflow: hidden;
}

/* ===== KONTEJNER ===== */
.container {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: white;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
  transition: transform var(--transition-speed) ease;
}

.sidebar-header {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(135deg, var(--primary-color), #008800);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-header h1 {
  font-size: 1.2rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: white;
}

.sidebar-header h1 i {
  color: white;
}

.close-btn {
  display: none;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 6px;
  transition: background var(--transition-speed);
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
}

/* ===== FORMULÁŘ - HYBRID ===== */
.form-group {
  margin-bottom: 0.625rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 500;
  color: var(--dark-color);
  font-size: 0.8rem;
}

.form-group label i {
  margin-right: 0.35rem;
  color: var(--primary-color);
  font-size: 0.8rem;
}

.form-group input[type="text"],
.form-group input[type="time"],
.form-group input[type="number"] {
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.9rem;
  transition: all var(--transition-speed);
  background: white;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ===== GRID LAYOUT (Z V3) ===== */
.form-grid-2 {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 0.625rem;
  margin-bottom: 0.625rem;
}

/* ===== AUTOCOMPLETE ===== */
.autocomplete-wrapper {
  position: relative;
}

.autocomplete-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 6px 6px;
  max-height: 280px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  box-shadow: var(--shadow-md);
}

.autocomplete-results.active {
  display: block;
}

.autocomplete-item {
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--light-bg);
  transition: background var(--transition-speed);
  font-size: 0.9rem;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover {
  background: var(--primary-light);
}

.autocomplete-item i {
  margin-right: 0.5rem;
  color: var(--primary-color);
  width: 14px;
  text-align: center;
  font-size: 0.85rem;
}

.autocomplete-item .item-label {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-left: 0.4rem;
}

.autocomplete-item .item-location {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-left: 0.25rem;
}

.autocomplete-item .item-location::before {
  content: "• ";
}

/* ===== WAYPOINTS - ACCORDION STYLE (Z V4 + V2) ===== */
#waypointsContainer {
  margin-bottom: 0.625rem;
}

.waypoint-group {
  margin-bottom: 0.5rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  transition: all var(--transition-speed);
  cursor: pointer;
}

.waypoint-group:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

.waypoint-group.drag-over {
  border-color: var(--primary-color);
  background: var(--primary-light);
}

/* Accordion hlavička */
.waypoint-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--light-bg);
  cursor: pointer;
  transition: background var(--transition-speed);
  border: none;
  width: 100%;
  text-align: left;
}

.waypoint-header:hover {
  background: var(--primary-light);
}

.waypoint-header.active {
  background: var(--primary-light);
  border-bottom: 1px solid var(--border-color);
}

.drag-handle {
  color: var(--text-muted);
  cursor: grab;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.drag-handle:active {
  cursor: grabbing;
}

.waypoint-title {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.waypoint-title-main {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--dark-color);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.waypoint-title-main i {
  color: var(--primary-color);
  font-size: 0.75rem;
}

.waypoint-preview {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.waypoint-break-preview {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-right: 0.5rem;
}

.waypoint-toggle {
  font-size: 0.875rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Accordion obsah */
.waypoint-content {
  padding: 0.625rem;
  background: white;
  border-top: 1px solid var(--border-color);
}

.waypoint-content.collapsed {
  display: none;
}

/* Inline fixace (Z V2) */
.waypoint-inline-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

.waypoint-inline-controls input[type="checkbox"] {
  width: 0.875rem;
  height: 0.875rem;
  cursor: pointer;
  accent-color: var(--primary-color);
  flex-shrink: 0;
}

.waypoint-inline-controls label {
  cursor: pointer;
  margin: 0;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.waypoint-inline-controls input[type="time"] {
  flex: 1;
  padding: 0.375rem 0.5rem;
  font-size: 0.75rem;
}

.waypoint-inline-controls input[type="number"] {
  width: 3.5rem;
  padding: 0.375rem 0.5rem;
  font-size: 0.75rem;
  text-align: center;
}

.waypoint-inline-controls .separator {
  color: var(--text-muted);
  flex-shrink: 0;
}

.remove-waypoint {
  width: 100%;
  background: white;
  color: var(--danger-color);
  border: 1px solid #fecaca;
  padding: 0.375rem 0.625rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all var(--transition-speed);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

.remove-waypoint:hover {
  background: #fef2f2;
  border-color: var(--danger-color);
}

.remove-waypoint i {
  font-size: 0.75rem;
}

/* ===== TLAČÍTKA - HYBRID ===== */
.btn {
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-speed);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  justify-content: center;
}

.btn i {
  font-size: 0.875rem;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: white;
  color: var(--dark-color);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--light-bg);
  border-color: var(--primary-color);
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

#addWaypoint {
  width: 100%;
  margin-bottom: 0.625rem;
  border: 2px dashed var(--border-color);
  background: white;
}

#addWaypoint:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: var(--primary-light);
}

/* ===== VÝSLEDKY ===== */
.results {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--border-color);
}

.results h2 {
  font-size: 1.15rem;
  margin-bottom: 0.9rem;
  color: var(--dark-color);
  font-weight: 600;
}

.summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.625rem;
  margin-bottom: 1rem;
}

.summary-item {
  padding: 0.75rem;
  background: var(--primary-light);
  border-radius: 8px;
  border: 1px solid rgba(0, 170, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.summary-item i {
  font-size: 1.3rem;
  color: var(--primary-color);
}

.summary-item span {
  flex: 1;
  font-size: 0.9rem;
}

.summary-item strong {
  color: var(--primary-color);
  font-size: 1rem;
}

/* ===== TABULKA ===== */
.schedule-table {
  overflow-x: auto;
  margin-bottom: 0.9rem;
  border-radius: 8px;
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  box-shadow: var(--shadow-sm);
}

thead {
  background: var(--dark-color);
  color: white;
}

th {
  padding: 0.6rem 0.65rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.85rem;
}

td {
  padding: 0.6rem 0.65rem;
  border-bottom: 1px solid var(--light-bg);
  font-size: 0.9rem;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--light-bg);
}

.place-cell {
  font-weight: 500;
}

.row-start {
  background: rgba(0, 170, 0, 0.08);
}

.row-start:hover {
  background: rgba(0, 170, 0, 0.12);
}

.row-waypoint {
  background: rgba(0, 0, 0, 0.02);
}

.row-waypoint:hover {
  background: rgba(0, 0, 0, 0.04);
}

.row-waypoint-fixed {
  background: rgba(255, 193, 7, 0.1);
}

.row-waypoint-fixed:hover {
  background: rgba(255, 193, 7, 0.15);
}

.row-end {
  background: rgba(220, 53, 69, 0.08);
}

.row-end:hover {
  background: rgba(220, 53, 69, 0.12);
}

/* ===== EXPORT AKCE ===== */
.export-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.export-actions .btn {
  flex: 1;
  min-width: 110px;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
}

/* ===== MAPA ===== */
.map-container {
  flex: 1;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
}

/* ===== FLOATING ACTION BUTTON (FAB) ===== */
.fab {
  display: none;
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 56px;
  height: 56px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  z-index: 999;
  transition: all var(--transition-speed);
}

.fab:hover {
  background: var(--primary-hover);
  transform: scale(1.1);
}

.fab:active {
  transform: scale(0.95);
}

/* ===== NOTIFIKACE ===== */
#notifications {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 380px;
}

.notification {
  padding: 0.85rem 1.1rem;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  animation: slideIn var(--transition-speed) ease;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 0.9rem;
}

.notification i {
  font-size: 1.15rem;
}

.notification-error {
  background: var(--danger-color);
  color: white;
}

.notification-warning {
  background: var(--warning-color);
  color: var(--dark-color);
}

.notification-success {
  background: var(--success-color);
  color: white;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ===== LOADING SPINNER ===== */
.loading-spinner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== SCROLLBAR ===== */
.sidebar-content::-webkit-scrollbar {
  width: 8px;
}

.sidebar-content::-webkit-scrollbar-track {
  background: var(--light-bg);
}

.sidebar-content::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== RESPONZIVITA ===== */

/* Tablet (768px - 991px) */
@media (max-width: 991px) {
  :root {
    --sidebar-width: 350px;
  }
}

/* Mobil (< 768px) */
@media (max-width: 767px) {
  .container {
    flex-direction: column;
  }
  
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 90%;
    max-width: 380px;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  
  .sidebar.active {
    transform: translateX(0);
  }
  
  .close-btn {
    display: block;
  }
  
  .fab {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .map-container {
    width: 100%;
    height: 100vh;
  }
  
  #notifications {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }
  
  .summary {
    grid-template-columns: 1fr;
  }
  
  .export-actions {
    flex-direction: column;
  }
  
  .export-actions .btn {
    width: 100%;
  }
  
  table {
    font-size: 0.85rem;
  }
  
  th, td {
    padding: 0.5rem;
  }
  
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
  
  .form-grid-2 .form-group:first-child {
    display: block;
  }
}

/* Desktop large (> 1400px) */
@media (min-width: 1400px) {
  :root {
    --sidebar-width: 450px;
  }
}

/* ===== PRINT STYLY ===== */
@media print {
  body > * {
    display: none !important;
  }
  
  .container {
    display: block !important;
  }
  
  .map-container,
  .sidebar-header,
  .fab,
  #notifications,
  #loadingSpinner {
    display: none !important;
  }
  
  .sidebar {
    display: block !important;
    position: static !important;
    width: 100% !important;
    border: none !important;
    background: white !important;
    padding: 20px !important;
  }
  
  .sidebar-content > form,
  .sidebar-content > form ~ * {
    display: none !important;
  }
  
  .sidebar-content {
    display: block !important;
    padding: 0 !important;
    overflow: visible !important;
  }
  
  #results {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    page-break-after: avoid;
  }
  
  .export-actions {
    display: none !important;
  }
  
  #results::before {
    content: "📋 Plán cesty - Itinerář";
    display: block;
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 20px;
    text-align: center;
    color: #000;
  }
  
  #results h2 {
    font-size: 24px;
    margin-bottom: 20px;
    color: #000;
    border-bottom: 2px solid #000;
    padding-bottom: 10px;
  }
  
  .summary {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
    page-break-inside: avoid;
  }
  
  .summary-item {
    padding: 10px !important;
    border: 1px solid #000 !important;
    background: white !important;
  }
  
  .summary-item i {
    color: #000 !important;
  }
  
  .schedule-table {
    overflow: visible !important;
    margin-bottom: 20px;
  }
  
  table {
    width: 100% !important;
    border-collapse: collapse !important;
    page-break-inside: auto;
    background: white !important;
    box-shadow: none !important;
  }
  
  thead {
    background: #333 !important;
    color: white !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  
  th {
    padding: 10px !important;
    text-align: left !important;
    font-weight: bold !important;
    border: 1px solid #000 !important;
    color: white !important;
  }
  
  td {
    padding: 10px !important;
    border: 1px solid #000 !important;
    page-break-inside: avoid;
  }
  
  tbody tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }
  
  .place-cell {
    font-weight: bold !important;
  }
}

.print-container {
  display: none;
}

@media print {
  body > *:not(.print-container) {
    display: none !important;
  }
  
  .print-container {
    display: block !important;
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 20px !important;
  }
  
  .print-container h1 {
    font-size: 24px;
    margin-bottom: 20px;
    text-align: center;
  }
  
  .print-container .summary {
    margin: 20px 0;
    padding: 15px;
    background: #f5f5f5;
    border: 1px solid #ddd;
  }
  
  .print-container table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
  }
  
  .print-container th,
  .print-container td {
    padding: 8px;
    border: 1px solid #333;
    text-align: left;
  }
  
  .print-container th {
    background: #f0f0f0;
    font-weight: bold;
  }
  
  .print-container .print-date {
    margin-top: 30px;
    text-align: right;
    font-size: 12px;
    color: #666;
  }
  
  .print-container * {
    box-shadow: none !important;
  }
}