/* ========================================
   NSP Traffic Prediction - Dark Theme
   Color palette inspired by Nokia/NSP UI
   ======================================== */

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --bg-card: #1e2a3a;
  --bg-card-hover: #243447;
  --bg-input: #0d1b2a;
  --border-color: #2a3a4e;
  --border-hover: #3a5068;

  --text-primary: #e0e6ed;
  --text-secondary: #8899aa;
  --text-muted: #5a6a7a;

  --accent-orange: #ff6f3c;
  --accent-orange-hover: #ff8c5a;
  --accent-blue: #3498db;
  --accent-blue-light: #5dade2;
  --accent-cyan: #00d4aa;
  --accent-cyan-light: #48e8c8;
  --accent-red: #e74c3c;

  --color-live: #3498db;
  --color-live-light: #5dade2;
  --color-predicted: #ff6f3c;
  --color-predicted-light: #ff8c5a;

  --font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.4);
  --transition: all 0.2s ease;
}

/* Reset & Base */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-orange);
  letter-spacing: 2px;
}

.header-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 1.5px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

.status-badge.connected {
  background: rgba(0, 212, 170, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 212, 170, 0.3);
}

.status-badge.disconnected {
  background: rgba(231, 76, 60, 0.15);
  color: var(--accent-red);
  border: 1px solid rgba(231, 76, 60, 0.3);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge.connected .status-dot {
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* Main Layout */
.app-main {
  display: flex;
  height: calc(100vh - 56px);
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}

.filter-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.filter-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.filter-input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.82rem;
  transition: var(--transition);
}

.filter-input:focus {
  outline: none;
  border-color: var(--accent-orange);
  box-shadow: 0 0 0 2px rgba(255, 111, 60, 0.15);
}

/* Buttons */
.btn {
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.btn-primary {
  background: var(--accent-orange);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-orange-hover);
  box-shadow: 0 2px 12px rgba(255, 111, 60, 0.3);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

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

.btn-outline {
  background: transparent;
  color: var(--accent-orange);
  border: 1px solid var(--accent-orange);
  padding: 8px 14px;
  font-size: 0.82rem;
}

.btn-outline:hover {
  background: rgba(255, 111, 60, 0.1);
}

/* Stream Status */
.stream-status {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--bg-card);
  border-radius: var(--radius);
}

.status-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.status-dot-sm {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot-sm.live {
  background: var(--color-live);
}

.status-dot-sm.predicted {
  background: var(--color-predicted);
}

.count-badge {
  margin-left: auto;
  padding: 2px 8px;
  background: var(--bg-input);
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Streaming Indicator */
.streaming-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--accent-cyan);
  padding: 8px 12px;
  background: rgba(0, 212, 170, 0.08);
  border-radius: var(--radius);
  border: 1px solid rgba(0, 212, 170, 0.2);
}

.streaming-indicator.paused {
  color: var(--text-muted);
  background: rgba(90, 106, 122, 0.08);
  border-color: rgba(90, 106, 122, 0.2);
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-cyan);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.streaming-indicator.paused .pulse-dot {
  background: var(--text-muted);
  animation: none;
}

@keyframes pulse-dot {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.6);
    opacity: 0.4;
  }
}

.export-section {
  margin-top: auto;
}

/* Content */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px;
  gap: 16px;
}

/* Chart Container */
.chart-container {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
  flex: 1;
  min-height: 350px;
  display: flex;
  flex-direction: column;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px 0;
}

.chart-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-orange);
  letter-spacing: 0.5px;
}

.chart-area {
  flex: 1;
  min-height: 0;
}

/* Table Container */
.table-container {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
  flex: 1;
  min-height: 250px;
  display: flex;
  flex-direction: column;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 10px;
}

.table-filters {
  display: flex;
  gap: 20px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-orange);
  cursor: pointer;
}

.table-pagination-info {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.select-sm {
  padding: 4px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.82rem;
  cursor: pointer;
}

.pagination-text {
  color: var(--accent-orange);
  font-weight: 500;
  min-width: 100px;
  text-align: center;
}

.pagination-controls {
  display: flex;
  gap: 4px;
}

.btn-page {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition);
}

.btn-page:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--accent-orange);
  color: var(--accent-orange);
}

.btn-page:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Table */
.table-scroll {
  flex: 1;
  overflow-y: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 5;
}

.data-table th {
  padding: 10px 20px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 8px 20px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(42, 58, 78, 0.5);
}

.data-table tbody tr {
  transition: var(--transition);
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.data-table tbody tr.selected {
  background: rgba(255, 111, 60, 0.1);
  border-left: 3px solid var(--accent-orange);
}

.data-table tbody tr.selected td {
  color: var(--text-primary);
}

.label-live {
  color: var(--color-live);
  font-weight: 600;
}

.label-predicted {
  color: var(--color-predicted);
  font-weight: 600;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* Responsive */
@media (max-width: 900px) {
  .app-main {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    min-width: unset;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 12px;
    gap: 12px;
  }
  .filter-section {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
  }
  .content {
    min-height: unset;
  }
  .chart-container {
    min-height: 280px;
  }
}