/**
 * Admin Interface Styles - Bootstrap Darkly Overrides
 * App-shell specific styles that complement Bootstrap
 */

/* ===== App Container Grid ===== */
.admin-container {
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  grid-template-rows: 60px 1fr;
  height: 100vh;
  gap: 0;
  overflow: hidden;
}

/* ===== Header ===== */
.admin-header {
  grid-column: 1 / -1;
  background: #2a2a2a;
  border-bottom: 1px solid #444;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.status-toast-host {
  position: fixed;
  top: 70px;
  right: 16px;
  width: min(360px, calc(100vw - 32px));
  z-index: 2000;
  pointer-events: none;
}

.status-toast {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #3f454d;
  background: rgba(34, 37, 42, 0.96);
  color: #f4f6f8;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: auto;
}

.status-toast::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7aa2ff;
  flex: 0 0 auto;
}

.status-toast.show {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

.status-toast.level-success {
  border-color: rgba(26, 186, 142, 0.7);
  background: rgba(17, 72, 57, 0.96);
}

.status-toast.level-success::before {
  background: #1aba8e;
}

.status-toast.level-warning {
  border-color: rgba(255, 176, 64, 0.75);
  background: rgba(86, 59, 25, 0.96);
}

.status-toast.level-warning::before {
  background: #ffb040;
}

.status-toast.level-error {
  border-color: rgba(240, 96, 96, 0.75);
  background: rgba(93, 29, 29, 0.96);
}

.status-toast.level-error::before {
  background: #f06060;
}

.admin-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sidebar-collapse-toggle {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-color: #4a4a4a;
  background: rgba(255, 255, 255, 0.06);
  color: #f4f6f8;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.sidebar-collapse-toggle:hover,
.sidebar-collapse-toggle:focus-visible {
  background: rgba(122, 162, 255, 0.14);
  border-color: rgba(122, 162, 255, 0.5);
  color: #ffffff;
}

.sidebar-collapse-toggle i {
  font-size: 14px;
  line-height: 1;
}

.sidebar-collapse-toggle.is-collapsed i {
  transform: translateX(1px);
}

.admin-header-logo {
  height: 26px;
  width: auto;
  display: block;
}

.admin-header h1 {
  font-size: 1.3em;
  color: #fff;
  margin: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

.app-switcher .btn {
  min-width: 145px;
}

.app-switcher .dropdown-menu {
  min-width: 300px;
}

.app-switcher .app-menu-item {
  white-space: normal;
}

.user-name {
  color: #ccc;
  font-size: 14px;
}

.logout-btn {
  padding: 8px 16px !important;
}

/* ===== Restart Banner ===== */
.restart-banner {
  grid-column: 1 / -1;
  background: #ffc107;
  color: #000;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e0a800;
  font-size: 14px;
  font-weight: 500;
}

.restart-banner .banner-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.2);
  color: #000;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s;
}

.restart-banner .banner-btn:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* ===== Sidebar ===== */
.admin-sidebar {
  background: #2a2a2a;
  border-right: 1px solid #444;
  overflow-y: auto;
  padding: 20px;
  min-width: 0;
  transition: padding 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}

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

.sidebar-section h3 {
  font-size: 0.9em;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.starting-stream-control {
  margin-bottom: 12px;
}

.starting-stream-control .form-label {
  margin-bottom: 4px;
  color: #b7b7b7;
  font-size: 12px;
}

.starting-stream-control .form-text {
  margin-top: 4px;
  color: #8d8d8d;
  font-size: 11px;
  line-height: 1.35;
}

.stream-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.stream-section-label {
  margin: 10px 0 6px;
  padding: 0 2px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.stream-section-label-online {
  color: #54da78;
}

.stream-section-label-offline {
  color: #8f98a1;
}

.stream-section-label-disabled {
  color: #d1a46a;
}

.stream-section-empty {
  color: #838b94;
  font-size: 12px;
  padding: 6px 10px 10px;
}

.stream-section-meta {
  color: #737c86;
  font-size: 11px;
  padding: 0 2px 10px;
}

.stream-section-meta-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stream-section-meta-btn {
  flex: 0 0 auto;
  padding: 2px 8px;
  font-size: 11px;
  line-height: 1.2;
}

.stream-item {
  padding: 10px 12px;
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 4px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.stream-item:hover {
  border-color: #007bff;
  background: #222;
}

.stream-item.active {
  background: #007bff;
  border-color: #007bff;
}

.stream-item.disabled {
  border-color: #5f4a34;
  background: #1f1a16;
}

.stream-item.disabled:hover {
  border-color: #c78c49;
  background: #272019;
}

.stream-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5a616b;
  border: 1px solid rgba(210, 220, 232, 0.35);
  opacity: 0.7;
  flex-shrink: 0;
}

.stream-status.live {
  width: 14px;
  height: 14px;
  background: #2ce85d;
  border-color: rgba(204, 255, 218, 0.95);
  box-shadow:
    0 0 0 3px rgba(44, 232, 93, 0.2),
    0 0 14px rgba(44, 232, 93, 0.7);
  opacity: 1;
  animation: streamLivePulse 1.8s ease-in-out infinite;
}

.stream-status.disabled {
  background: #b67b46;
  border-color: rgba(255, 220, 181, 0.6);
  opacity: 0.95;
}

.stream-item + .stream-section-label {
  margin-top: 14px;
}

.stream-name {
  flex: 1;
  font-size: 14px;
}

.stream-viewers-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  color: #d7ffe6;
  background: rgba(44, 232, 93, 0.18);
  border: 1px solid rgba(100, 255, 153, 0.7);
}

.stream-item.active .stream-viewers-badge {
  color: #fff;
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.78);
}

.stream-source-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.pending-changes-indicator {
  font-size: 14px;
  opacity: 0.9;
  animation: pulse 2s ease-in-out infinite;
}

.stream-section-pagination {
  margin: -2px 0 10px;
}

.stream-section-pagination-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 2px 0;
}

.stream-section-range {
  color: #96a0aa;
  font-size: 11px;
}

.stream-section-pagination-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stream-section-pagination-actions .btn {
  padding: 1px 8px;
  font-size: 11px;
}

.stream-section-page {
  min-width: 74px;
  text-align: center;
  color: #b4bcc5;
  font-size: 11px;
}

@keyframes pulse {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 0.5; }
}

@keyframes streamLivePulse {
  0%, 100% {
    box-shadow:
      0 0 0 3px rgba(44, 232, 93, 0.18),
      0 0 10px rgba(44, 232, 93, 0.5);
  }
  50% {
    box-shadow:
      0 0 0 4px rgba(44, 232, 93, 0.32),
      0 0 18px rgba(44, 232, 93, 0.85);
  }
}

@media (prefers-reduced-motion: reduce) {
  .stream-status.live {
    animation: none;
  }
}

.add-stream-btn,
.sidebar-link-btn {
  width: 100%;
  margin-top: 10px;
}

.sidebar-external-link {
  text-align: left;
}

.sidebar-link-note {
  margin-top: 10px;
  color: #8d8d8d;
  font-size: 11px;
  line-height: 1.4;
}

.dashboard-nav-btn {
  text-align: left;
}

.dashboard-nav-btn.active {
  background: #007bff;
  border-color: #007bff;
  color: #fff;
}

/* ===== Main Content ===== */
.admin-main {
  overflow-y: auto;
  padding: 20px;
  background: #1a1a1a;
  min-width: 0;
}

#statusMessage {
  display: none !important;
}

.config-panel {
  background: #2a2a2a;
  border-radius: 8px;
  padding: 20px;
  max-width: 1200px;
}

.config-panel.statistics-layout-wide {
  max-width: none;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.panel-header h2 {
  font-size: 1.5em;
  color: #fff;
  margin: 0;
}

.panel-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 1500px) {
  .admin-container {
    grid-template-columns: minmax(220px, 250px) minmax(0, 1fr);
  }

  .admin-main {
    padding: 16px;
  }

  .sidebar-collapse-toggle .me-1 {
    margin-right: 0 !important;
  }
}

.admin-container.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.admin-container.sidebar-collapsed .admin-sidebar {
  padding-left: 0;
  padding-right: 0;
  padding-top: 20px;
  padding-bottom: 20px;
  border-right-color: transparent;
  overflow: hidden;
  opacity: 0;
}

.admin-container.sidebar-collapsed .sidebar-section,
.admin-container.sidebar-collapsed .add-stream-btn,
.admin-container.sidebar-collapsed .stream-list,
.admin-container.sidebar-collapsed .starting-stream-control,
.admin-container.sidebar-collapsed .sidebar-link-note {
  visibility: hidden;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .admin-container {
    grid-template-columns: 1fr;
    grid-template-rows: 60px auto 1fr;
  }

  .admin-sidebar {
    border-right: none;
    border-bottom: 1px solid #444;
    max-height: 200px;
  }

  .sidebar-collapse-toggle {
    display: none;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .panel-actions {
    width: 100%;
  }

  .user-info {
    gap: 8px;
  }

  .app-switcher .btn {
    min-width: 0;
  }

  .status-toast-host {
    top: 64px;
    right: 8px;
    width: calc(100vw - 16px);
  }

  .statistics-table th,
  .statistics-table td {
    font-size: 12px;
  }

  .statistics-range-row {
    flex-wrap: wrap;
  }

  .statistics-range-row #statisticsHours {
    width: auto;
    min-width: 120px;
  }

  .statistics-range-row #statisticsRangeMode {
    width: auto;
    min-width: 120px;
  }

  .statistics-chart-wrapper {
    height: 220px;
  }

  .statistics-pagination-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .statistics-custom-range-inner .form-control {
    min-width: 180px;
  }

  .statistics-custom-range-inner {
    flex-wrap: wrap;
  }

  .stream-section-pagination-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}
