/* Importing Premium Fonts: Outfit for UI, JetBrains Mono for metrics and counters */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-main: #0a0c10;
  --bg-card: rgba(22, 28, 38, 0.75);
  --bg-card-hover: rgba(30, 37, 50, 0.9);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(59, 130, 246, 0.5);
  
  /* Neon Status Colors */
  --color-live: #10b981;
  --color-live-glow: rgba(16, 185, 129, 0.3);
  --color-offline: #ef4444;
  --color-offline-glow: rgba(239, 68, 68, 0.3);
  --color-warning: #f59e0b;
  --color-info: #06b6d4;
  --color-primary: #3b82f6;
  --color-primary-glow: rgba(59, 130, 246, 0.4);
  
  /* Text */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dark: #64748b;
  
  --font-sans: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --shadow-neon: 0 0 20px rgba(59, 130, 246, 0.15);
  --transition-speed: 0.3s;
}

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

/* Prevent text selection on buttons, tabs, links, and clickable controls */
button,
.btn,
.select-filter,
.sound-toggle,
.time-widget,
.chart-time-filters button,
.history-header button,
a {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

body {
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 0% 0%, rgba(16, 185, 129, 0.03) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(59, 130, 246, 0.05) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(6, 182, 212, 0.02) 0px, transparent 50%);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: 2rem;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* Fullscreen Mode Utility */
body:-webkit-full-screen {
  width: 100%;
  height: 100%;
  padding: 1.5rem;
  background-color: var(--bg-main);
}

/* App Shell Layout */
header {
  border-bottom: 1px solid var(--border-color);
  background: rgba(10, 12, 16, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 1rem 2rem;
}

.header-container {
  max-width: 1800px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.5rem;
  color: white;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

.logo-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.brand h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #f8fafc, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand span {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: rgba(59, 130, 246, 0.15);
  color: var(--color-primary);
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-left: 0.5rem;
}

.chart-time-filters {
  display: flex;
  gap: 0.5rem;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.time-widget {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-muted);
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.time-widget span {
  color: var(--text-main);
  font-weight: 600;
}

/* Simulation Mode Warning Banner */
.simulation-banner {
  background: linear-gradient(90deg, #b45309, #d97706);
  color: white;
  padding: 0.5rem 1rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  display: none; /* Controlled by JS */
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0 0 8px 8px;
  margin: 0 auto;
  max-width: 600px;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.2);
}

/* Main Container */
main {
  max-width: 1800px;
  margin: 1.5rem auto 0 auto;
  padding: 0 1.5rem;
}

/* NOC Summary Panel */
.summary-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.summary-card {
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition-speed);
}



.summary-card h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.summary-card .value {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 0.5rem;
  color: var(--text-main);
  display: flex;
  align-items: baseline;
}

.summary-card .subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Countdown & Controls Row */
.dashboard-controls {
  background: rgba(30, 41, 59, 0.3);
  border: 1px solid var(--border-color);
  padding: 1rem 1.5rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.search-filter-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-grow: 1;
  max-width: 600px;
}

.search-input {
  background: #161c26;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  width: 100%;
  outline: none;
  font-family: var(--font-sans);
  transition: border-color var(--transition-speed);
}

.search-input:focus {
  border-color: var(--border-focus);
}

.select-filter {
  background: #161c26;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
  font-family: var(--font-sans);
  cursor: pointer;
}

.countdown-widget {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  font-family: var(--font-mono);
}

.progress-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--color-primary);
  animation: spin 1s linear infinite;
  display: none; /* Triggered on fetch update */
}

/* Grid of Cards */
.live-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

/* Video NOC Card */
.live-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  transition: transform var(--transition-speed), border-color var(--transition-speed), box-shadow var(--transition-speed);
  position: relative;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(8px);
}

.live-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 15px rgba(255, 255, 255, 0.02);
}

.live-card.online {
  border-color: rgba(16, 185, 129, 0.2);
}

.live-card.online:hover {
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 20px rgba(16, 185, 129, 0.1);
}

/* Thumbnail Section */
.card-thumbnail-wrapper,
.card-thumbnail-link {
  position: relative;
  display: block;
  width: 100%;
  padding-top: 56.25%; /* 16:9 Aspect Ratio */
  background: #0f131a;
  overflow: hidden;
  text-decoration: none;
}

.card-thumbnail-link {
  cursor: pointer;
  color: var(--text-main);
}

.card-thumbnail-link:visited,
.card-thumbnail-link:hover,
.card-thumbnail-link:active {
  color: var(--text-main);
}

.card-thumbnail-link .card-badge,
.card-thumbnail-link .duration-badge {
  color: var(--text-main);
}

.card-thumbnail-link:hover .card-thumbnail {
  transform: scale(1.05);
}

.thumbnail-play-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 2;
  pointer-events: none;
}

.thumbnail-play-overlay i {
  font-size: 2.5rem;
  color: #ef4444;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.6));
}

.card-thumbnail-link:hover .thumbnail-play-overlay {
  opacity: 1;
}

.card-thumbnail {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.live-card:hover .card-thumbnail {
  transform: scale(1.03);
}

.card-badge {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  letter-spacing: 0.5px;
  z-index: 3;
}

.card-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.live-card.online .card-badge .dot {
  background-color: var(--color-live);
  box-shadow: 0 0 10px var(--color-live);
  animation: pulse-glow 1.5s infinite;
}

.live-card.offline .card-badge .dot {
  background-color: var(--color-offline);
}

.duration-badge {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(4px);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.05);
  z-index: 3;
}

/* Channel Logo & Header */
.card-content {
  padding: 1.25rem 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.channel-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.channel-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.08);
  background-color: #1e293b;
  object-fit: cover;
}

.channel-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.channel-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}

.channel-handle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.live-title {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
  height: 2.8em; /* Exactly 2 lines */
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: var(--text-main);
  margin-bottom: 0.75rem;
}

/* NOC Card Metrics */
.card-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 0.75rem;
  border-top: 1px solid var(--border-color);
  padding-top: 0.75rem;
  margin-top: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  margin-bottom: 0;
}

.metric-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.metric-label {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.metric-value {
  color: var(--text-main);
  font-weight: 600;
}

.metric-value.live-viewers {
  color: var(--color-live);
  text-shadow: 0 0 10px var(--color-live-glow);
}

/* Button Actions */
.card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.btn {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background-color var(--transition-speed), transform 0.1s ease;
  outline: none;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background-color: #ef4444; /* Youtube Red */
  color: white;
  flex-grow: 1;
  text-decoration: none;
}

.btn-primary:hover {
  background-color: #dc2626;
}

.btn-primary:disabled {
  background-color: #475569;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background-color: #1e293b;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  min-width: 44px;
}

.btn-secondary:hover {
  background-color: #334155;
  border-color: rgba(255, 255, 255, 0.15);
}

/* Charts & Logging Grid */
.noc-details-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.noc-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(8px);
}

.noc-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.noc-panel-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
}

/* Live Terminal Log Console */
.terminal-console {
  background: #07090e;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #10b981; /* Terminal green */
  height: 320px;
  overflow-y: auto;
  line-height: 1.5;
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.8);
}

.terminal-line {
  margin-bottom: 0.4rem;
  white-space: pre-wrap;
  word-break: break-all;
}

.terminal-line.error { color: #f87171; }
.terminal-line.warn { color: #fbbf24; }
.terminal-line.info { color: #a7f3d0; }

/* Config View Container */
.config-container {
  max-width: 800px;
  margin: 2rem auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 2rem;
  backdrop-filter: blur(8px);
}

.config-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.config-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.form-group {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.btn-success {
  background-color: var(--color-primary);
  color: white;
}

.btn-success:hover {
  background-color: #2563eb;
}

/* Channels List Table */
.channels-table-wrapper {
  margin-top: 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
}

.channels-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.channels-table th, .channels-table td {
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--border-color);
}

.channels-table th {
  background-color: rgba(30, 41, 59, 0.4);
  font-weight: 600;
  color: var(--text-muted);
}

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

.channels-table tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

.channels-table td .channel-name-cell {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 500;
}

.channels-table td .btn-danger-sm {
  background-color: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  border-radius: 6px;
}

.channels-table td .btn-danger-sm:hover {
  background-color: rgba(239, 68, 68, 0.3);
}

/* Audio Control Button */
.sound-toggle {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--transition-speed);
}

.sound-toggle.muted {
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--text-muted);
}

/* History Logs Export View */
.history-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  margin-top: 1.5rem;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.history-title {
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.export-buttons {
  display: flex;
  gap: 0.5rem;
}

/* Visual Alert Toast Wrapper */
#alert-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 400px;
  width: calc(100% - 3rem);
}

.alert-toast {
  background: rgba(15, 23, 42, 0.95);
  border-left: 4px solid var(--color-primary);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7), 0 0 15px rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 1rem;
  color: var(--text-main);
  animation: slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  backdrop-filter: blur(8px);
}

.alert-toast.live-start { border-left-color: var(--color-live); }
.alert-toast.live-end { border-left-color: var(--color-offline); }
.alert-toast.spike { border-left-color: var(--color-warning); }
.alert-toast.drop { border-left-color: var(--color-warning); }

.alert-toast-header {
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.alert-toast-body {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Keyframes Animations */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pulse-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

@keyframes slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Responsive Breakpoints */
@media(max-width: 1024px) {
  .noc-details-grid {
    grid-template-columns: 1fr;
  }
}

@media(max-width: 768px) {
  .header-container {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
  }
  
  .brand {
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
  }
  
  .brand h1 {
    font-size: 1.3rem;
  }
  
  .brand span {
    margin-left: 0 !important;
  }
  
  .header-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
  }
  
  .dashboard-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-filter-box {
    flex-direction: column;
    align-items: stretch;
    max-width: none;
  }
  
  .form-group {
    flex-direction: column;
  }

  .noc-panel-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
  }
  
  .chart-time-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
  }
  
  .chart-time-filters .btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }

  .history-header {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
  }

  body {
    padding: 1rem 0.75rem;
  }

  .live-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .summary-panel {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
  }

  .channels-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* 4K & Ultrawide Customizations */
@media(min-width: 2560px) {
  .live-grid {
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 2rem;
  }
  
  .summary-panel {
    gap: 1.5rem;
  }
  
  body {
    font-size: 1.1rem;
  }
  
  .brand h1 {
    font-size: 2rem;
  }
  
  .brand span {
    font-size: 0.9rem;
  }
  
  .summary-card h3 {
    font-size: 0.9rem;
  }
  
  .summary-card .value {
    font-size: 2.5rem;
  }
}
