/* CAKRA - Traffic History & Bandwidth Analytics Modal Styling */

.traffic-modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1050;
  padding: 20px;
  animation: trafficFadeIn 0.2s ease-out;
}

.traffic-modal-overlay.active {
  display: flex;
}

@keyframes trafficFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.traffic-modal-container {
  background: var(--bg-surface, #1e293b);
  border: 1px solid var(--border-color, #334155);
  border-radius: 18px;
  width: 100%;
  max-width: 900px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.05);
  overflow: hidden;
  animation: trafficSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes trafficSlideUp {
  from {
    transform: translateY(16px) scale(0.98);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* Modal Header */
.traffic-modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color, #334155);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(15, 23, 42, 0.3);
}

.traffic-header-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.traffic-header-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.traffic-header-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary, #f8fafc);
  margin: 0;
  letter-spacing: -0.01em;
}

.traffic-header-subtitle {
  font-size: 0.84rem;
  color: var(--text-muted, #94a3b8);
  display: flex;
  align-items: center;
  gap: 8px;
}

.traffic-modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted, #94a3b8);
  font-size: 1.4rem;
  line-height: 1;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.traffic-modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary, #f8fafc);
}

/* Modal Body */
.traffic-modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Period Controls Bar */
.traffic-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.traffic-period-pills {
  display: inline-flex;
  background: rgba(15, 23, 42, 0.45);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border-color, #334155);
}

.traffic-period-btn {
  background: transparent;
  border: none;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted, #94a3b8);
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.traffic-period-btn:hover {
  color: var(--text-primary, #f8fafc);
}

.traffic-period-btn.active {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.traffic-accuracy-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 9999px;
  letter-spacing: 0.02em;
}

/* Hero Stats Grid */
.traffic-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

@media (max-width: 768px) {
  .traffic-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.traffic-stat-card {
  background: rgba(15, 23, 42, 0.35);
  border: 1px solid var(--border-color, #334155);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.traffic-stat-card.featured {
  border-color: rgba(16, 185, 129, 0.35);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(15, 23, 42, 0.35) 100%);
}

.traffic-stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.traffic-stat-title {
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted, #94a3b8);
}

.traffic-stat-icon {
  font-size: 1rem;
}

.traffic-stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary, #f8fafc);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.traffic-stat-subtext {
  font-size: 0.75rem;
  color: var(--text-muted, #94a3b8);
  display: flex;
  align-items: center;
  gap: 6px;
}

.traffic-stat-subtext .down {
  color: #10b981;
  font-weight: 600;
}

.traffic-stat-subtext .up {
  color: #06b6d4;
  font-weight: 600;
}

/* Chart Container */
.traffic-chart-wrapper {
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid var(--border-color, #334155);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.traffic-chart-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.traffic-chart-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary, #f8fafc);
}

.traffic-chart-legend {
  display: flex;
  align-items: center;
  gap: 16px;
}

.traffic-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted, #94a3b8);
}

.traffic-legend-indicator {
  width: 12px;
  height: 4px;
  border-radius: 2px;
}

.traffic-legend-indicator.down {
  background-color: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

.traffic-legend-indicator.up {
  background-color: #06b6d4;
  box-shadow: 0 0 6px rgba(6, 182, 212, 0.4);
}

.traffic-canvas-box {
  width: 100%;
  height: 250px;
  position: relative;
}

#traffic-analytics-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Interactive Floating Tooltip */
.traffic-chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(59, 130, 246, 0.4);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6);
  border-radius: 8px;
  padding: 8px 12px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
  transform: translate(-50%, -100%);
  margin-top: -8px;
  white-space: nowrap;
}

.traffic-tooltip-time {
  font-size: 0.72rem;
  color: #94a3b8;
  font-weight: 600;
  border-bottom: 1px solid rgba(51, 65, 85, 0.6);
  padding-bottom: 3px;
  margin-bottom: 2px;
}

.traffic-tooltip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.78rem;
  font-weight: 700;
}

.traffic-tooltip-row.down {
  color: #10b981;
}

.traffic-tooltip-row.up {
  color: #06b6d4;
}

/* Hourly Breakdown Table */
.traffic-table-wrapper {
  background: rgba(15, 23, 42, 0.35);
  border: 1px solid var(--border-color, #334155);
  border-radius: 12px;
  overflow: hidden;
}

.traffic-table-header {
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.5);
  border-bottom: 1px solid var(--border-color, #334155);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary, #f8fafc);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.traffic-breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.traffic-breakdown-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted, #94a3b8);
  border-bottom: 1px solid var(--border-color, #334155);
  background: rgba(15, 23, 42, 0.2);
}

.traffic-breakdown-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.4);
  color: var(--text-primary, #f8fafc);
}

.traffic-breakdown-table tr:last-child td {
  border-bottom: none;
}

.traffic-breakdown-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

/* Modal Footer */
.traffic-modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border-color, #334155);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.3);
}

.traffic-footer-note {
  font-size: 0.74rem;
  color: var(--text-muted, #94a3b8);
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-traffic-close {
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: var(--text-primary, #f8fafc);
  padding: 7px 18px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-traffic-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

/* Light Mode Overrides */
[data-theme="light"] .traffic-modal-overlay,
body.light-mode .traffic-modal-overlay {
  background-color: rgba(15, 23, 42, 0.4);
}

[data-theme="light"] .traffic-modal-container,
body.light-mode .traffic-modal-container {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .traffic-modal-header,
[data-theme="light"] .traffic-modal-footer,
body.light-mode .traffic-modal-header,
body.light-mode .traffic-modal-footer {
  background: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .traffic-period-pills,
[data-theme="light"] .traffic-stat-card,
[data-theme="light"] .traffic-chart-wrapper,
[data-theme="light"] .traffic-table-wrapper,
body.light-mode .traffic-period-pills,
body.light-mode .traffic-stat-card,
body.light-mode .traffic-chart-wrapper,
body.light-mode .traffic-table-wrapper {
  background: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .traffic-stat-card.featured,
body.light-mode .traffic-stat-card.featured {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, #f8fafc 100%);
  border-color: #a7f3d0;
}

[data-theme="light"] .traffic-chart-tooltip,
body.light-mode .traffic-chart-tooltip {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}
