:root {
  --bg-color: #0f172a;
  --surface-color: rgba(30, 41, 59, 0.7);
  --primary-color: #3b82f6;
  --accent-color: #10b981;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --glass-border: rgba(255, 255, 255, 0.1);
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.dashboard-container {
  display: grid;
  grid-template-columns: 350px 1fr;
  width: 100%;
  height: 100%;
}

.sidebar {
  background: var(--surface-color);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  padding: 24px;
  gap: 24px;
  overflow-y: auto;
  z-index: 10;
}

.brand {
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-dot {
  width: 12px;
  height: 12px;
  background-color: var(--primary-color);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--primary-color);
}

.section-title {
  font-size: 0.875rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 12px;
}

.device-list, .event-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.card:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

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

.device-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1; /* Allow to shrink/grow */
  min-width: 0; /* Allows text truncation in flexbox */
}

.btn-video {
  font-size: 0.75rem;
  background: var(--primary-color);
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background 0.2s;
}
.btn-video:hover {
  background: #2563eb;
}

.status-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-indicator.online {
  background: var(--accent-color);
  box-shadow: 0 0 8px var(--accent-color);
}
.status-indicator.offline {
  background: #f43f5e;
}

.device-details {
  font-size: 0.875rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.main-content {
  position: relative;
  display: flex;
  flex-direction: column;
}

#map {
  flex: 1;
  width: 100%;
  z-index: 1;
}

.controls-overlay {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 400px;
}

.panel-glass {
  background: var(--surface-color);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.form-control {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  color: white;
  padding: 10px 12px;
  border-radius: 8px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

.form-control:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

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

.btn:hover {
  background: #2563eb;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px);
}

.video-container {
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--glass-border);
}

.video-overlay-text {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  animation: fadeIn 0.4s ease forwards;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 10px;
}

/* -------------------------------- */
/* Live Video Modal Styles          */
/* -------------------------------- */
.video-modal-overlay {
  position: fixed;
  top: 10%;
  left: 20%;
  width: 60%;
  background: rgba(20, 20, 20, 0.95);
  backdrop-filter: blur(10px);
  padding: 20px;
  z-index: 9999;
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
}

.video-modal-title {
  color: #fff;
  font-family: 'Inter', sans-serif;
  margin-bottom: 15px;
  font-size: 1.2rem;
}

.video-modal-close-btn, .video-modal-mute-btn {
  position: absolute;
  top: 20px;
  padding: 10px 15px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  border: none;
  font-size: 0.9rem;
  transition: opacity 0.2s;
}
.video-modal-close-btn:hover, .video-modal-mute-btn:hover {
  opacity: 0.8;
}

.video-modal-close-btn {
  right: 20px;
  background: #f43f5e;
  color: white;
}

.video-modal-mute-btn {
  right: 110px;
  background: #333;
  color: white;
  border: 1px solid #555;
}

.video-modal-player {
  width: 100%;
  height: auto;
  border-radius: 10px;
  background: #000;
  display: block;
}

/* -------------------------------- */
/* Responsive Mobile Layout         */
/* -------------------------------- */
@media (max-width: 768px) {
  body {
    overflow-y: auto;
  }
  
  .dashboard-container {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  /* Map gets upper half */
  #map {
    height: 45vh; /* Takes 45% of viewport height */
    flex: none;
  }

  /* Sidebar moves below map */ 
  .sidebar {
    border-right: none;
    border-top: 1px solid var(--glass-border);
    padding: 16px;
    gap: 16px;
    height: auto;
    overflow: visible;
  }

  /* Overlays should be part of normal flow below map on mobile */
  .controls-overlay {
    position: relative;
    top: auto;
    right: auto;
    width: 100%;
    max-width: 100%;
    padding: 16px;
    gap: 16px;
  }

  .main-content {
    display: flex;
    flex-direction: column;
    order: 1; /* Map and overlay */
  }
  
  .sidebar {
    order: 2; /* Device lists */
  }

  /* Video Modal adapts to small screen */
  .video-modal-overlay {
    top: 5%;
    left: 5%;
    width: 90%;
    padding: 15px;
  }

  .video-modal-title {
    font-size: 1rem;
    padding-right: 80px; /* space for buttons */
  }

  .video-modal-close-btn, .video-modal-mute-btn {
    padding: 8px 12px;
    font-size: 0.8rem;
    top: 15px;
  }
  .video-modal-close-btn {
    right: 15px;
  }
  .video-modal-mute-btn {
    right: 90px;
  }
  
  .btn {
    padding: 12px 16px; /* Larger tap targets */
  }
}
