:root {
  /* Primary Colors */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #60a5fa;

  /* Status Colors */
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  /* UI Colors */
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-elevated: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --shadow: rgba(0, 0, 0, 0.3);

  /* Module Colors */
  --module-point: #8b5cf6;
  --module-area: #3b82f6;
  --module-route: #06b6d4;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1200px;
  margin: 0 auto;
}

/* Header */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
}

.icon-btn:hover {
  background: var(--border);
  transform: scale(1.05);
}

.icon-btn:active {
  transform: scale(0.95);
}

/* Install Banner */
.install-banner {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
  }

  to {
    transform: translateY(0);
  }
}

.install-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.install-btn {
  background: white;
  color: var(--primary);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
}

.install-btn:hover {
  transform: scale(1.05);
}

.dismiss-btn {
  background: transparent;
  border: 1px solid white;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
}

/* Module Container */
.module-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 70px;
  /* Space for bottom nav */
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 1200px;
  margin: 0 auto;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 0.5rem 0;
  z-index: 100;
}

.nav-item {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.5rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.2s;
  font-size: 0.75rem;
  font-weight: 500;
}

.nav-item svg {
  transition: transform 0.2s;
}

.nav-item:hover {
  color: var(--primary-light);
}

.nav-item:hover svg {
  transform: scale(1.1);
}

.nav-item.active {
  color: var(--primary);
  position: relative;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 3px 3px;
}

/* Side Panels */
.side-panel {
  position: fixed;
  top: 0;
  width: 90%;
  max-width: 400px;
  height: 100vh;
  background: var(--bg);
  transition: transform 0.3s ease;
  z-index: 200;
  overflow-y: auto;
  box-shadow: 0 0 12px var(--shadow);
  display: flex;
  flex-direction: column;
}

.side-panel-left {
  left: 0;
  transform: translateX(-100%);
}

.side-panel-left.active {
  transform: translateX(0);
}

.side-panel-right {
  right: 0;
  transform: translateX(100%);
}

.side-panel-right.active {
  transform: translateX(0);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

.panel-header h2 {
  font-size: 1.25rem;
  margin: 0;
}

.panel-header .icon-btn {
  font-size: 2rem;
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border: none;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel-content {
  flex: 1;
  padding: 1rem;
}

.panel-search {
  margin-bottom: 1rem;
}

.panel-search input {
  width: 100%;
  padding: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
}

.panel-filters {
  margin-bottom: 1rem;
}

.panel-filters select {
  width: 100%;
  padding: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
}

/* History List */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.history-item:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.history-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.history-item-module {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}

.history-item-module.point {
  background: rgba(139, 92, 246, 0.2);
  color: var(--module-point);
}

.history-item-module.area {
  background: rgba(59, 130, 246, 0.2);
  color: var(--module-area);
}

.history-item-module.route {
  background: rgba(6, 182, 212, 0.2);
  color: var(--module-route);
}

.history-item-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.history-item-details {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.history-item-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Overlay */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 150;
}

.overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* Loading */
.loading {
  text-align: center;
  padding: 3rem 1rem;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

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

/* Common Utilities */
.hidden {
  display: none !important;
}

input[type="text"],
input[type="number"],
input[type="search"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
}

button.primary-btn {
  width: 100%;
  padding: 0.875rem;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--primary);
  color: white;
}

button.primary-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

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

button.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

button.secondary-btn {
  width: 100%;
  padding: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-card);
  color: var(--text);
}

button.secondary-btn:hover {
  background: var(--border);
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

/* Location Suggestions */
.suggestions-list {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 4px 8px var(--shadow);
}

.suggestion-item {
  padding: 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}

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

.suggestion-item:hover {
  background: var(--bg-elevated);
}

.form-group {
  position: relative;
}

/* Responsive */
@media (min-width: 768px) {
  .app-logo {
    font-size: 2rem;
  }

  .side-panel {
    width: 100%;
    max-width: 480px;
  }

  .panel-header .icon-btn {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }
}

/* Map Container */
.map-container {
  width: 100%;
  height: 400px;
  border-radius: 12px;
  overflow: hidden;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
}

@media (min-width: 768px) {
  .map-container {
    height: 500px;
  }
}

/* Accessibility */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.nav-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

/* Skip to main content link for screen readers */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary);
  color: white;
  padding: 0.5rem 1rem;
  text-decoration: none;
  z-index: 1000;
}

.skip-link:focus {
  top: 0;
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print styles */
@media print {

  .app-header,
  .bottom-nav,
  .side-panel,
  .overlay,
  .install-banner {
    display: none !important;
  }

  .module-container {
    padding-bottom: 0 !important;
  }
}

/* iOS Safe Area */
@supports (padding: max(0px)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .app-header .header-content {
    padding-top: max(1rem, env(safe-area-inset-top));
  }

  .bottom-nav {
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  }

  .side-panel {
    padding-bottom: env(safe-area-inset-bottom);
  }
}