* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

h1 {
  margin: 0;
  font-size: 28px;
}

h2 {
  margin-top: 0;
  font-size: 20px;
}

p {
  margin: 8px 0 0;
  color: #94a3b8;
}

.card {
  background: #111827;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.35);
}

.hidden {
  display: none;
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.filter-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-row input,
.filter-row select {
  min-width: 180px;
}

/* Sidebar layout */
.app-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
}

.sidebar {
  background: #111827;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 16px;
  height: fit-content;
  position: sticky;
  top: 24px;
}

.sidebar-section {
  margin-bottom: 8px;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #1f2937;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
  user-select: none;
}

.sidebar-section-header:hover {
  background: #374151;
}

.sidebar-section-header .chevron {
  transition: transform 0.2s;
}

.sidebar-section.collapsed .chevron {
  transform: rotate(-90deg);
}

.sidebar-section.collapsed .sidebar-section-items {
  display: none;
}

.sidebar-section-items {
  padding: 4px 0 4px 8px;
}

.sidebar-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  margin: 2px 0;
}

.sidebar-item:hover {
  background: #1e293b;
}

.sidebar-item.active {
  background: #38bdf8;
  color: #0f172a;
}

.main-content {
  min-width: 0;
}

@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }
}

/* Legacy tab styles - kept for compatibility */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  background: #1f2937;
  color: #e2e8f0;
}

.tab.active {
  background: #38bdf8;
  color: #0f172a;
}

.assignment-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.assignment-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.assignment-grid > div {
  min-width: 0;
}

.assignment-grid select {
  width: 100%;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #cbd5f5;
  gap: 6px;
}

input,
select {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0f172a;
  color: #e2e8f0;
}

button {
  background: #38bdf8;
  border: none;
  color: #0f172a;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

button.secondary {
  background: #1e293b;
  color: #e2e8f0;
}

button.danger {
  background: #f87171;
  color: #0f172a;
}

.tenant-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tenant-item {
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 16px;
  background: #0b1220;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 12px;
  align-items: center;
}

.tenant-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-panel {
  margin-top: 16px;
  border-top: 1px solid #1e293b;
  padding-top: 16px;
}

.hint {
  font-size: 12px;
  color: #94a3b8;
}

@media (max-width: 780px) {
  .tenant-item {
    grid-template-columns: 1fr;
  }
}

/* Log table styles */
.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.log-table th,
.log-table td {
  padding: 12px 8px;
  text-align: left;
  border-bottom: 1px solid #1e293b;
}

.log-table th {
  background: #1f2937;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: #94a3b8;
}

.log-table tr:hover {
  background: #1e293b;
}

.log-table a {
  color: #38bdf8;
  text-decoration: none;
}

.log-table a:hover {
  text-decoration: underline;
}

.summary-cell {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* License warnings */
.license-warning {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #92400e;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-weight: 500;
}

.compliance-warning {
  background: #fee2e2;
  border: 1px solid #ef4444;
  color: #991b1b;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-weight: 500;
}

.user-limit-exceeded {
  color: #ef4444;
  font-weight: 600;
}

.user-count-badge {
  font-size: 14px;
  color: #94a3b8;
  font-weight: normal;
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-header-row h2 {
  margin: 0;
}

/* Location History Map and Playback Controls */
#location-map {
  z-index: 1;
}

.playback-controls {
  margin-top: 16px;
  padding: 16px;
  background: #1a1a2e;
  border-radius: 8px;
}

.playback-timeline {
  margin-bottom: 16px;
}

.playback-timeline input[type="range"] {
  width: 100%;
  height: 8px;
  background: #334155;
  border-radius: 4px;
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.playback-timeline input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: #38bdf8;
  border-radius: 50%;
  cursor: pointer;
}

.playback-timeline input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: #38bdf8;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.playback-time {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: #94a3b8;
}

.playback-buttons {
  display: flex;
  gap: 12px;
  align-items: center;
}

.playback-btn {
  padding: 8px 16px;
  font-size: 14px;
}

/* Leaflet map overrides for dark theme */
.leaflet-container {
  background: #1a1a2e;
}

.leaflet-popup-content-wrapper {
  background: #1f2937;
  color: #e2e8f0;
  border-radius: 8px;
}

.leaflet-popup-tip {
  background: #1f2937;
}

.leaflet-popup-content {
  margin: 12px;
}

.location-popup-time {
  font-size: 14px;
  font-weight: 600;
  color: #38bdf8;
  margin-bottom: 4px;
}

.location-popup-coords {
  font-size: 12px;
  color: #94a3b8;
}

.location-popup-info {
  font-size: 12px;
  color: #cbd5e1;
  margin-top: 4px;
}

/* Location icon markers */
.location-icon {
  background: transparent !important;
  border: none !important;
  cursor: pointer;
}

.location-icon svg {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  transition: transform 0.2s;
}

.location-icon:hover svg {
  transform: scale(1.15);
}

/* Walkie talkie transmission marker */
.walkie-talkie-marker svg {
  filter: drop-shadow(0 2px 6px rgba(56, 189, 248, 0.4));
}

/* Location legend */
.location-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 12px;
  background: #1f2937;
  border-radius: 8px;
  font-size: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.legend-section {
  display: flex;
  gap: 12px;
  align-items: center;
}

.legend-section-title {
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.05em;
}

/* Geo-fence label styling */
.geo-fence-label {
  background: transparent !important;
  border: none !important;
}

.geo-fence-label div {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transform: translateX(-50%);
}
