/**
 * Khatutik Platform — Admin Portal Styles
 */

:root {
  --header-height: 64px;
  --sidebar-width: 250px;
  --sidebar-collapsed-width: 72px;
  --transition-speed: 0.25s;
}

/* ==========================================================================
   Admin Header
   ========================================================================== */
.admin-header {
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-light);
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  box-shadow: var(--shadow-sm);
}

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

.btn-toggle-sidebar {
  background: none;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-toggle-sidebar:hover {
  background: var(--color-bg);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
}

.header-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.header-title-wrap {
  display: flex;
  flex-direction: column;
}

.header-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--color-text);
}

.header-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary);
}

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

.system-status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: #065F46;
  background: var(--color-accent-light);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-dot {
  width: 7px;
  height: 7px;
  background: var(--color-accent);
  border-radius: 50%;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.3rem 0.5rem 0.3rem 0.3rem;
  background: #F1F5F9;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border-light);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-details {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.2;
}

.user-role-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  align-self: flex-start;
  margin-top: 1px;
}

.user-role-badge.superadmin {
  background: var(--color-secondary-light);
  color: #92400E;
}

.user-role-badge.admin {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.user-role-badge.user {
  background: #E2E8F0;
  color: var(--color-text);
}

/* ==========================================================================
   Admin Layout & Sidebar
   ========================================================================== */
.admin-layout {
  display: flex;
  flex: 1;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
  position: relative;
}

.admin-sidebar {
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border-light);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: width var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
  overflow-x: hidden;
  flex-shrink: 0;
  z-index: 30;
}

.admin-layout.sidebar-collapsed .admin-sidebar {
  width: var(--sidebar-collapsed-width);
}

.sidebar-nav {
  padding: 1rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 0.9rem;
  color: var(--color-muted);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.nav-item:hover {
  background: #F1F5F9;
  color: var(--color-primary);
}

.nav-item.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-label {
  opacity: 1;
  transition: opacity var(--transition-speed) ease;
}

.admin-layout.sidebar-collapsed .nav-label {
  opacity: 0;
  pointer-events: none;
  width: 0;
}

/* ==========================================================================
   Collapsible Sub-menu Items (Settings)
   ========================================================================== */

.nav-item-with-sub {
  display: flex;
  flex-direction: column;
}

.nav-parent {
  position: relative;
}

.nav-chevron {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-muted);
  opacity: 0.5;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.nav-parent:hover .nav-chevron {
  opacity: 0.8;
}

.nav-parent.active .nav-chevron {
  transform: rotate(90deg);
  opacity: 1;
}

.nav-sub-list {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.25s ease;
  padding-left: 1rem;
}

.nav-sub-list.open {
  max-height: 120px;
}

.nav-sub-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.nav-sub-item:hover {
  background: #F1F5F9;
  color: var(--color-primary);
}

.nav-sub-item.active {
  background: #EFF6FF;
  color: var(--color-primary);
  font-weight: 700;
}

/* Collapse: hide chevron and sub-nav */
.admin-layout.sidebar-collapsed .nav-chevron,
.admin-layout.sidebar-collapsed .nav-label {
  opacity: 0 !important;
  width: 0;
  pointer-events: none;
}

.admin-layout.sidebar-collapsed .nav-sub-list {
  display: none !important;
}

/* ==========================================================================
   Admin Main Window
   ========================================================================== */
.sidebar-footer {
  padding: 1rem 0.6rem;
  border-top: 1px solid var(--color-border-light);
}

.nav-item.logout {
  color: #DC2626;
}

.nav-item.logout:hover {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

/* ==========================================================================
   Admin Main Window
   ========================================================================== */
.admin-main {
  flex: 1;
  overflow-y: auto;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

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

.page-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--color-muted);
  margin-top: 0.2rem;
}

/* Stats Row */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.primary { background: var(--color-primary-light); color: var(--color-primary); }
.stat-icon.secondary { background: var(--color-secondary-light); color: var(--color-secondary); }
.stat-icon.accent { background: var(--color-accent-light); color: var(--color-accent); }

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.1;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--color-muted);
  font-weight: 600;
}

/* Content Cards & Tables */
.content-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-header-bar {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.card-heading {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-text);
}

/* Settings Card */
.settings-card {
  background: var(--color-surface);
}

.settings-card-body {
  padding: 1.25rem 1.5rem 1.5rem;
}

.settings-timezone-select {
  flex: 1;
  min-width: 240px;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

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

th {
  background: #F8FAFC;
  color: var(--color-muted);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--color-border-light);
}

td {
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
  color: var(--color-text);
}

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

tr:hover td {
  background-color: #F8FAFC;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
}

.status-badge.active {
  background: var(--color-accent-light);
  color: #065F46;
}

.status-badge.inactive {
  background: #F1F5F9;
  color: var(--color-muted);
}

.status-badge.failed {
  background: #FEE2E2;
  color: #991B1B;
}

.status-badge.blocked {
  background: #FEF3C7;
  color: #92400E;
}

.filter-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem 1.25rem;
  background: #F8FAFC;
  border-bottom: 1px solid var(--color-border-light);
}

.filter-input-wrap {
  position: relative;
  flex: 1 1 220px;
  min-width: 180px;
}

.filter-input-wrap svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-muted);
  pointer-events: none;
}

.filter-input {
  width: 100%;
  padding: 0.45rem 0.75rem 0.45rem 2.2rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  background: #FFFFFF;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

.filter-select {
  padding: 0.45rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  background: #FFFFFF;
  outline: none;
  color: var(--color-text);
  cursor: pointer;
  transition: border-color 0.2s;
}

.filter-select:focus {
  border-color: var(--color-primary);
}

.btn-filter-reset {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-light);
  background: #FFFFFF;
  color: var(--color-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-filter-reset:hover {
  background: #F1F5F9;
  color: var(--color-text);
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--color-border-light);
  font-size: 0.85rem;
  color: var(--color-muted);
}

.btn-action {
  background: var(--color-primary);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-full);
  padding: 0.55rem 1.25rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.25);
  transition: all 0.2s ease;
}

.btn-action:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
}

.table-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
}

.btn-icon-action,
.btn-icon-del,
.btn-icon-edit,
.btn-icon-key {
  background: none;
  border: 1px solid var(--color-border-light);
  color: var(--color-muted);
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon-del:hover {
  color: var(--color-danger);
  border-color: var(--color-danger);
  background: var(--color-danger-light);
}

.btn-icon-edit:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.btn-icon-key:hover {
  color: #D97706;
  border-color: #D97706;
  background: #FEF3C7;
}

.btn-icon-cam:hover {
  color: #0891B2;
  border-color: #0891B2;
  background: #ECFEFF;
}

.temp-password-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #F8FAFC;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin: 1rem 0;
}

.temp-password-text {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.05em;
  color: var(--color-text);
  user-select: all;
}

.btn-copy-pw {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-copy-pw:hover {
  background: #F1F5F9;
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.view-panel {
  display: none;
}

.view-panel.active {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Cameras Grid */
.cameras-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
  padding: 1.25rem;
}

.camera-card {
  position: relative;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
}

.camera-card.inactive-cam {
  opacity: 0.75;
  background: #F8FAFC;
  border-style: dashed;
}

.camera-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  min-width: 0;
}

.camera-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  min-width: 0;
  flex: 1;
}

.camera-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
  word-break: break-word;
  line-height: 1.3;
}

.camera-auth-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: #F1F5F9;
  border: 1px solid var(--color-border-light);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  color: var(--color-muted);
  white-space: nowrap;
}

.camera-status-wrap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.camera-url-display {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--color-muted);
  background: #F8FAFC;
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid #EDF2F7;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  box-sizing: border-box;
}

.camera-schedule-info {
  font-size: 0.82rem;
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  word-break: break-word;
  line-height: 1.4;
}

.camera-schedule-info strong {
  color: var(--color-muted);
  font-weight: 600;
}

.camera-id-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-muted);
  background: #E2E8F0;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

/* Security Auth Overlay */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: #FFFFFF;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(2, 132, 199, 0.2);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Modal Dialog
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-backdrop.open {
  display: flex;
}

.modal-box {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 520px;
  width: 100%;
  padding: 2rem;
  position: relative;
  animation: modalIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-text);
}

.btn-modal-close {
  background: none;
  border: none;
  color: var(--color-muted);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
}

.btn-modal-close:hover {
  color: var(--color-text);
}

.modal-form-group {
  margin-bottom: 1.15rem;
}

.modal-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.35rem;
}

.modal-input, .modal-select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  border: 1.5px solid var(--color-border-light);
  border-radius: var(--radius-md);
  background: #FFFFFF;
  outline: none;
  transition: border-color 0.2s;
}

.modal-input:focus, .modal-select:focus {
  border-color: var(--color-primary);
}

/* Disable Microsoft Edge native password reveal icon */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  pointer-events: none !important;
}

.modal-cameras-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.5rem;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.cam-access-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--color-border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.18s ease;
  background: #FAFBFC;
  user-select: none;
}

.cam-access-card:hover {
  border-color: #0891B2;
  background: #F0FDFF;
}

.cam-access-card.selected {
  border-color: #0891B2;
  background: #ECFEFF;
}

.cam-access-card input[type="checkbox"] {
  display: none;
}

.cam-access-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: #E0F2FE;
  color: #0369A1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.18s;
}

.cam-access-card.selected .cam-access-card-icon {
  background: #0891B2;
  color: #FFFFFF;
}

.cam-access-card-body {
  flex: 1;
  min-width: 0;
}

.cam-access-card-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cam-access-card-meta {
  font-size: 0.76rem;
  color: var(--color-muted);
  font-family: var(--font-mono);
  margin-top: 2px;
}

.cam-access-card-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--color-border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.18s ease;
  color: transparent;
}

.cam-access-card.selected .cam-access-card-check {
  background: #0891B2;
  border-color: #0891B2;
  color: #FFFFFF;
}

.cameras-modal-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--color-muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.camera-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--color-text);
  background: #F8FAFC;
  border: 1px solid var(--color-border-light);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
}



.modal-error-banner {
  display: none;
  background: var(--color-danger-light);
  color: #991B1B;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.btn-secondary {
  background: #F1F5F9;
  color: var(--color-muted);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-full);
  padding: 0.55rem 1.25rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-secondary:hover {
  background: #E2E8F0;
  color: var(--color-text);
}

@media (max-width: 768px) {
  .admin-layout.sidebar-collapsed .admin-sidebar {
    width: 0;
    display: none;
  }
  .admin-sidebar {
    position: absolute;
    bottom: 0;
    top: 0;
    left: 0;
    height: 100%;
    box-shadow: var(--shadow-lg);
  }
}

/* ==========================================================================
   Cameras & Streaming Studio Styles
   ========================================================================== */

.streaming-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
}

.streaming-toggle-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* iOS-style Switch Toggle */
.switch-container {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.switch-label-text {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-text);
}

.switch-input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.switch-slider {
  position: relative;
  width: 48px;
  height: 26px;
  background-color: #CBD5E1;
  border-radius: 9999px;
  transition: background-color 0.25s ease;
}

.switch-slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.25s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.switch-input:checked + .switch-slider {
  background-color: var(--color-accent);
}

.switch-input:checked + .switch-slider::before {
  transform: translateX(22px);
}

/* Compact switch slider for individual cameras */
.switch-container.switch-sm {
  gap: 0.4rem;
}

.switch-container.switch-sm .switch-slider {
  width: 36px;
  height: 20px;
}

.switch-container.switch-sm .switch-slider::before {
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
}

.switch-container.switch-sm .switch-input:checked + .switch-slider::before {
  transform: translateX(16px);
}

.stream-limit-badge {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  background: #F1F5F9;
  color: var(--color-muted);
  border: 1px solid var(--color-border-light);
  font-weight: 600;
}

/* Alert Banner for Regular Admins when Streaming is Disabled */
.streaming-disabled-alert {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.35rem;
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  color: #92400E;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.4;
}

.streaming-disabled-alert .alert-icon {
  font-size: 1.3rem;
  line-height: 1;
  flex-shrink: 0;
}

.streaming-disabled-alert .alert-text {
  flex: 1;
}

/* Stream Editor Card */
.stream-editor-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  max-width: 760px;
  box-shadow: var(--shadow-sm);
  box-sizing: border-box;
}

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

.stream-editor-header h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.url-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.url-input-wrapper input {
  padding-right: 90px;
}

.form-field-hint {
  font-size: 0.78rem;
  color: var(--color-muted);
  margin-top: 0.35rem;
  display: block;
  line-height: 1.45;
}

.stream-auth-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

@media (max-width: 640px) {
  .stream-auth-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

.protocol-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: #E2E8F0;
  color: #475569;
  letter-spacing: 0.5px;
  line-height: 1.2;
  white-space: nowrap;
}

.url-input-wrapper .protocol-badge {
  position: absolute;
  right: 10px;
}

.protocol-badge.rtsp {
  background: #DBEAFE;
  color: #1E40AF;
}

.protocol-badge.hls, .protocol-badge.http {
  background: #D1FAE5;
  color: #065F46;
}

.protocol-badge.rtmp {
  background: #FEF3C7;
  color: #92400E;
}

.protocol-badge.exec {
  background: #F3E8FF;
  color: #6B21A8;
}

/* Days Selection */
.days-chips-wrapper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: #F8FAFC;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
}

.day-chip {
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: #FFFFFF;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.day-chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.day-chip.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #FFFFFF;
}

.days-quick-links {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--color-primary);
  margin-left: auto;
}

.days-quick-links span {
  cursor: pointer;
}

.days-quick-links span:hover {
  text-decoration: underline;
}

/* Periods List */
.periods-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.period-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #F8FAFC;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-light);
}

.period-row span {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.period-row input[type="time"] {
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  background: #FFFFFF;
  color: var(--color-text);
  outline: none;
}

.btn-remove-period {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--color-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  line-height: 1;
  transition: all 0.15s ease;
}

.btn-remove-period:hover {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

/* Stream Card Actions in Grid */
.camera-card-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border-light);
  box-sizing: border-box;
}

.btn-card-action {
  width: 100%;
  min-width: 0;
  padding: 0.4rem 0.35rem;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: #FFFFFF;
  color: var(--color-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  white-space: nowrap;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

.btn-card-action:hover {
  background: #F1F5F9;
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-card-action.danger:hover {
  background: var(--color-danger-light);
  border-color: var(--color-danger);
  color: var(--color-danger);
}

/* Video Preview Modal */
.preview-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.preview-modal-dialog {
  background: #0F172A;
  color: #FFFFFF;
  border-radius: var(--radius-lg);
  max-width: 420px;
  width: 100%;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}


.preview-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: #1E293B;
  border-bottom: 1px solid #334155;
}

.preview-modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #F8FAFC;
}

.preview-video-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-video-box video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.audio-disabled-pill {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(0, 0, 0, 0.7);
  color: #E2E8F0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  pointer-events: none;
}

