@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
@import url('https://unpkg.com/@phosphor-icons/web@2.0.3/src/regular/style.css');
@import url('https://unpkg.com/@phosphor-icons/web@2.0.3/src/fill/style.css');


:root {
  --bg-color: #f1f5f9;
  --surface-color: #ffffff;
  --text-color: #010509;
  --text-muted: #717579;
  --border-color: #d1d5d9;
  --primary: #ff6900;
}

[data-bs-theme="dark"] {
  --bg-color: #010509;
  --surface-color: #212529;
  --text-color: #f1f5f9;
  --text-muted: #717579;
  --border-color: #414549;
  --primary: #ff6900;
  
  --bs-body-bg: #010509;
  --bs-body-color: #f1f5f9;
  --bs-tertiary-bg: #212529;
  --bs-secondary-bg: #414549;
  --bs-border-color: #414549;
  --bs-dark: #212529;
  --bs-dark-rgb: 33, 37, 41;
  --bs-card-bg: #212529;
}

/* Force foolproof contrast in dark mode */
[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .bg-dark,
[data-bs-theme="dark"] .bg-surface,
[data-bs-theme="dark"] .modal-container,
[data-bs-theme="dark"] .dropdown-menu {
  background-color: var(--surface-color) !important;
  border: 1px solid var(--border-color) !important;
}

/* Fix table striping and hover in dark mode */
[data-bs-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text-color);
  --bs-table-border-color: var(--border-color);
}
[data-bs-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: rgba(255, 255, 255, 0.05) !important;
}
[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * {
  background-color: rgba(255, 255, 255, 0.075) !important;
}

:root {
  --bs-primary: #ff6900;
  --bs-primary-rgb: 255, 105, 0;
}

.btn-primary, .btn-primary:hover, .btn-primary:active, .btn-primary:focus, .btn-primary:disabled {
  --bs-btn-bg: #ff6900;
  --bs-btn-border-color: #ff6900;
  --bs-btn-hover-bg: #e65e00;
  --bs-btn-hover-border-color: #d95900;
  --bs-btn-active-bg: #d95900;
  --bs-btn-active-border-color: #cc5400;
  --bs-btn-disabled-bg: #ff6900;
  --bs-btn-disabled-border-color: #ff6900;
  --bs-btn-color: #fff;
  --bs-btn-hover-color: #fff;
  --bs-btn-active-color: #fff;
}
.text-primary, .text-primary-emphasis {
  color: #ff6900 !important;
}
.bg-primary {
  background-color: #ff6900 !important;
}
.border-primary {
  border-color: #ff6900 !important;
}

body {
  font-family: 'Poppins', sans-serif !important;
  background-color: var(--bg-color) !important;
  color: var(--text-color) !important;
}

.card, .btn {
  border-radius: 12px !important;
}

/* Phosphor alignment */
.ph, .ph-fill, .ph-bold, .ph-duotone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: text-bottom;
}

[data-bs-theme="dark"] .swal2-popup {
  background-color: #18181b !important;
  color: #e4e4e7 !important;
}
[data-bs-theme="dark"] .swal2-title {
  color: #e4e4e7 !important;
}
[data-bs-theme="dark"] .swal2-html-container {
  color: #a1a1aa !important;
}

/* Video Player cinematic styling */
.player-overlay {
    pointer-events: none;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 20%, transparent 80%, rgba(0,0,0,0.7) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.ratio:hover .player-overlay {
    pointer-events: none;
  opacity: 1;
}

@media (max-width: 768px) {
  .hide-text-mobile {
      display: none !important;
  }
}

/* Status dots */
.status {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-online, .status-running { background-color: #22c55e; box-shadow: 0 0 5px #22c55e; }
.status-offline, .status-error { background-color: #ef4444; box-shadow: 0 0 5px #ef4444; }

.yt-item-status {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #000;
}
.yt-item-status.online { background-color: #22c55e; }
.yt-item-status.offline { background-color: #ef4444; }

.ptz-overlay { display: none; }
.ptz-overlay.active { display: flex !important; }
.btn-ptz { width: 40px; height: 40px; border-radius: 50%; border: none; background: rgba(255,255,255,0.2); color: white; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.btn-ptz:hover { background: rgba(255,255,255,0.3); }
.btn-ptz:active, .btn-ptz.active { background: rgba(255,255,255,0.4); transform: scale(0.95); }
.ptz-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }

.modal-backdrop {
  position: fixed !important;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.8) !important;
  display: flex !important;
  align-items: center; justify-content: center;
  z-index: 9999 !important;
  opacity: 0; visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.modal-backdrop.active {
  opacity: 1 !important; visibility: visible !important;
}
.modal-container {
  background-color: var(--surface-color, #18181b);
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  transform: translateY(20px);
  transition: transform 0.3s ease;
}
.modal-backdrop.active .modal-container {
  transform: translateY(0);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 0;
  border-bottom: none;
}
.modal-title {
  margin: 0; font-size: 1.25rem;
}
.modal-close {
  background: none; border: none; font-size: 1.5rem; cursor: pointer; color: inherit;
}



/* Active Playlist Item */
.playlist-item.active { background-color: var(--primary) !important; color: #fff !important; border-color: var(--primary) !important; }
.playlist-item.active .text-muted { color: rgba(255,255,255,0.8) !important; }

.swal2-popup {
  background-color: var(--surface-color) !important;
  color: var(--text-color) !important;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
}
.swal2-title, .swal2-html-container {
  color: var(--text-color) !important;
}

/* Mobile Navbar Styles */
@media (max-width: 991.98px) {
  .navbar {
    z-index: 1000;
    position: relative;
  }
  .mobile-navbar {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #212529; /* Matches bg-dark */
    z-index: 999;
    padding: 1rem;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3);
    border-bottom: 1px solid rgba(255,255,255,0.1);
  }
  .mobile-navbar .navbar-nav {
    align-items: flex-start !important;
    gap: 8px !important;
  }
  .mobile-navbar .nav-item {
    width: 100%;
  }
  .mobile-navbar .nav-link {
    padding: 12px 16px;
    border-radius: 8px;
    background-color: rgba(255,255,255,0.03);
    transition: background-color 0.2s;
  }
  .mobile-navbar .nav-link:hover, .mobile-navbar .nav-link.active {
    background-color: rgba(255,255,255,0.1);
  }
  .mobile-navbar .dropdown-menu {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .mobile-navbar .dropdown-item {
    color: #e4e4e7 !important;
    padding: 10px 16px;
    border-radius: 8px;
  }
  .mobile-navbar .dropdown-item:hover {
    background-color: rgba(255,255,255,0.1) !important;
  }
  .mobile-navbar .dropdown-divider {
    border-color: rgba(255,255,255,0.1) !important;
  }
  
  /* Theme toggle on mobile */
  .mobile-navbar #theme-toggle {
    width: 100%;
    border-radius: 8px !important;
    border-color: rgba(255,255,255,0.1);
    color: #e4e4e7;
    margin-top: 8px;
  }
}

/* Multi View Grid */
.multiview-grid {
  display: grid;
  grid-template-columns: repeat(var(--mv-cols, 3), 1fr);
  gap: 8px;
  width: 100%;
  align-content: start;
}
.multiview-cell {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background-color: #000;
  border-radius: 0;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.multiview-cell video, .multiview-cell iframe {
  width: 100%;
  height: 100%;
  object-fit: contain; /* Don't crop CCTV */
}
.multiview-cell .cell-overlay {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
}
@media (max-width: 991.98px) {
  .multiview-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
@media (max-width: 575.98px) {
  .multiview-grid {
    grid-template-columns: 1fr !important;
  }
}


/* Sidebar List Items (Dashboard & Records) */
.sidebar-item {
  transition: all 0.2s ease;
  border: 1px solid var(--border-color) !important;
  cursor: pointer;
  background-color: var(--surface-color) !important;
}
.sidebar-item:hover {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 1px var(--primary) !important;
}
.sidebar-item.active {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 1px var(--primary) !important;
  background-color: rgba(var(--bs-primary-rgb), 0.05) !important;
  color: var(--text-color) !important;
}
.sidebar-item.active .text-muted {
  color: var(--text-muted) !important;
}

.sidebar-item.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(1);
}
.sidebar-item.disabled:hover {
  border-color: var(--border-color) !important;
  box-shadow: none !important;
}

/* Desktop sticky player */
@media (min-width: 992px) {
  #yt-player-wrapper {
    position: sticky !important;
    top: 1rem !important;
    z-index: 900 !important;
  }
}

.rotating { animation: rotation 1.5s infinite linear; }
@keyframes rotation { from { transform: rotate(0deg); } to { transform: rotate(359deg); } }


.player-overlay button, .player-overlay a { pointer-events: auto; }

/* Live Talk Button & Badge (Dark & Light Mode Safe) */
#btn-live-talk {
  background-color: #16a34a !important;
  color: #ffffff !important;
  cursor: pointer;
}
#btn-live-talk:hover {
  background-color: #15803d !important;
}
#btn-live-talk:active {
  background-color: #166534 !important;
}
#btn-live-talk[data-talk-state="connecting"] {
  background-color: #eab308 !important;
  color: #ffffff !important;
  cursor: wait;
}
#btn-live-talk[data-talk-state="talking"] {
  background-color: #dc2626 !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.35) !important;
}
#btn-live-talk[data-talk-state="talking"]:hover {
  background-color: #b91c1c !important;
}


