/* =========================================================================
   RNL_PBX • Compact DataTables, Top-Label Modals & Responsive Layout
   ========================================================================= */

:root {
  --rnl-desktop-bg: #8e8e8e;
  --rnl-panel-bg: #f0f0f0;
  --rnl-toolbar-bg: #eaeaea;
  --rnl-window-bg: #ffffff;
  --rnl-border-light: #ffffff;
  --rnl-border-mid: #c2c2c2;
  --rnl-border-dark: #7a7a7a;
  --rnl-blue-dark: #1c2d87;
  --rnl-blue-mid: #32449c;
  --rnl-blue-light: #5b6ec4;
  --rnl-row-alt: #f5f7fb;
  --rnl-row-hover: #dce8fc;
  --rnl-text-main: #111111;
  --font-ui: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --font-mono: 'Consolas', 'Courier New', monospace;
}

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

html, body {
  min-height: 100%;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: auto;
  -webkit-overflow-scrolling: touch;
  font-family: var(--font-ui);
  font-size: 12.5px;
  color: var(--rnl-text-main);
  background: var(--rnl-desktop-bg);
  user-select: text;
  -webkit-user-select: text;
}

.wb-table, .wb-table td, .wb-table th, .wb-window, .wb-modal-body, .wb-window-statusbar {
  user-select: text;
  -webkit-user-select: text;
}

.ptr-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 0;
  overflow: hidden;
  background: #1c2d87;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4000;
  transition: height 0.15s ease;
}

.ptr-indicator.visible {
  height: 34px;
  border-bottom: 1px solid #ffffff;
}

/* =========================================================================
   1. Single Clean Header Bar
   ========================================================================= */
.wb-single-header {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  background: var(--rnl-panel-bg);
  border-bottom: 2px solid var(--rnl-border-dark);
  z-index: 1300;
  position: relative;
}

.wb-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wb-sidebar-toggle {
  width: 28px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f8f8f8;
  border: 1px solid #8c8c8c;
  border-top-color: #fff;
  border-left-color: #fff;
  font-size: 14px;
  font-weight: 700;
  color: #1c2d87;
  cursor: pointer;
}

.wb-sidebar-toggle:hover {
  background: #dce8fc;
}

.wb-brand-title {
  font-size: 14px;
  font-weight: 800;
  color: #1c2d87;
  letter-spacing: 0.4px;
}

.wb-header-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  background: #ffffff;
  border: 1px solid #9ca3af;
  font-size: 11.5px;
  font-weight: 600;
}

.wb-led {
  width: 9px;
  height: 9px;
  background: #9ca3af;
  border: 1px solid #374151;
}

.wb-led.online { background: #16a34a; }
.wb-led.offline { background: #dc2626; }

/* Profile Dropdown on Right */
.wb-header-right {
  position: relative;
  display: flex;
  align-items: center;
}

.wb-profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  background: #f8f8f8;
  border: 1px solid #8c8c8c;
  border-top-color: #fff;
  border-left-color: #fff;
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 600;
  color: #111;
  cursor: pointer;
}

.wb-profile-btn:hover { background: #dce8fc; }

.wb-profile-dropdown {
  display: none;
  position: absolute;
  top: 32px;
  right: 0;
  width: 155px;
  background: #ffffff;
  border: 1px solid #555555;
  box-shadow: 2px 3px 8px rgba(0, 0, 0, 0.35);
  z-index: 1500;
}

.wb-profile-dropdown.open { display: block; }

.wb-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 11px;
  border: none;
  background: transparent;
  font-family: var(--font-ui);
  font-size: 12.5px;
  color: #111;
  text-align: left;
  cursor: pointer;
}

.wb-dropdown-item:hover {
  background: #316ac5;
  color: #ffffff;
}

.wb-dropdown-divider {
  height: 1px;
  background: #d4d4d4;
}

/* =========================================================================
   2. Workspace & Sidebar (Auto-Hidden on Small Screens)
   ========================================================================= */
.wb-workspace {
  display: flex;
  height: calc(100vh - 40px);
  width: 100%;
  position: relative;
}

.wb-sidebar {
  width: 195px;
  min-width: 195px;
  height: 100%;
  background: var(--rnl-panel-bg);
  border-right: 2px solid var(--rnl-border-dark);
  transition: width 0.15s ease, min-width 0.15s ease, transform 0.18s ease;
  overflow: hidden;
  z-index: 1200;
}

.wb-sidebar.desktop-collapsed {
  width: 0;
  min-width: 0;
  border-right: none;
}

.wb-nav-list {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  padding: 4px 0;
}

.wb-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  border: 1px solid transparent;
  background: transparent;
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 500;
  color: #111111;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  outline: none;
}

.wb-nav-item:hover {
  background: #dbeafe;
  border-top-color: #93c5fd;
  border-bottom-color: #93c5fd;
}

.wb-nav-item.active,
.wb-nav-item:focus-visible {
  background: #316ac5;
  color: #ffffff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 #0f1d5e;
}

.wb-nav-icon {
  width: 16px;
  text-align: center;
  font-size: 13px;
  flex-shrink: 0;
}

.wb-nav-badge {
  margin-left: auto;
  background: #dcdcdc;
  color: #111;
  font-size: 11px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: 2px;
  border: 1px solid #999;
}

.wb-nav-item.active .wb-nav-badge {
  background: #ffffff;
  color: #1c2d87;
}

.wb-nav-divider {
  height: 1px;
  background: #c4c4c4;
  border-bottom: 1px solid #ffffff;
  margin: 4px 6px;
}

/* =========================================================================
   3. Desktop Canvas & Window Containers
   ========================================================================= */
.wb-desktop {
  flex: 1;
  height: 100%;
  background: var(--rnl-desktop-bg);
  padding: 10px;
  overflow-y: auto;
  overscroll-behavior-y: auto;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

.wb-window {
  background: var(--rnl-panel-bg);
  border: 2px solid #2b3c96;
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.35);
  margin-bottom: 12px;
}

.wb-window.minimized .wb-window-body,
.wb-window.minimized .wb-window-toolbar,
.wb-window.minimized .dt-header-bar {
  display: none;
}

.wb-window-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg, #273992 0%, #5b6ec4 100%);
  color: #ffffff;
  padding: 4px 9px;
  font-size: 12.5px;
  font-weight: 700;
}

.wb-window-controls {
  display: flex;
  align-items: center;
  gap: 3px;
}

.wb-win-ctrl {
  width: 17px;
  height: 15px;
  background: #e5e5e5;
  color: #111;
  border: 1px solid #fff;
  border-right-color: #555;
  border-bottom-color: #555;
  font-size: 10px;
  font-weight: 800;
  line-height: 12px;
  text-align: center;
  cursor: pointer;
}

.wb-window-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background: var(--rnl-toolbar-bg);
  border-bottom: 1px solid #b5b5b5;
  gap: 6px;
  flex-wrap: wrap;
}

.wb-tool-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.wb-toolbar-btn, .wb-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 2px 8px;
  height: 23px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  color: #111;
  background: #f7f7f7;
  border: 1px solid #8c8c8c;
  border-top-color: #ffffff;
  border-left-color: #ffffff;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.wb-toolbar-btn:hover, .wb-icon-btn:hover {
  background: #dce8fc;
  border-color: #3b5998;
}

.wb-toolbar-btn.btn-primary-wb, .wb-icon-btn.btn-primary-wb {
  background: #dce8fc;
  color: #10247a;
  border-color: #4a69bd;
}

.wb-toolbar-btn.btn-danger-wb {
  background: #fee2e2;
  color: #991b1b;
  border-color: #dc2626;
}

.wb-toolbar-btn.btn-success-wb {
  background: #dcfce7;
  color: #14532d;
  border-color: #16a34a;
}

/* =========================================================================
   4. Responsive DataTables with Minimized Compact Row Height
   ========================================================================= */
.dt-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background: #f5f5f5;
  border-bottom: 1px solid #cccccc;
  font-size: 11.5px;
  gap: 8px;
  flex-wrap: wrap;
}

.dt-length-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  color: #333;
}

.dt-select {
  padding: 1px 4px;
  font-size: 11.5px;
  border: 1px solid #8c8c8c;
  background: #fff;
}

.wb-find-input {
  padding: 2px 7px;
  height: 22px;
  font-size: 12px;
  border: 1px solid #8c8c8c;
  background: #ffffff;
  color: #111;
  min-width: 170px;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: #ffffff;
}

.wb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  color: #111111;
  user-select: text;
}

.wb-table thead th {
  background: linear-gradient(180deg, #f7f7f7 0%, #dfdfdf 100%);
  border-right: 1px solid #bdbdbd;
  border-bottom: 1px solid #969696;
  padding: 4px 8px;
  height: 24px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  color: #1f2937;
  white-space: nowrap;
  cursor: pointer;
}

.wb-table thead th:hover {
  background: #dbeafe;
}

.wb-table tbody tr {
  border-bottom: 1px solid #e2e2e2;
  background: #ffffff;
  height: 25px;
}

.wb-table tbody tr:nth-child(even) {
  background: var(--rnl-row-alt);
}

.wb-table tbody tr:hover {
  background: var(--rnl-row-hover);
}

.wb-table td {
  padding: 2px 8px;
  height: 25px;
  line-height: 1.15;
  border-right: 1px solid #e5e5e5;
  vertical-align: middle;
  white-space: nowrap;
}

.wb-table .wb-toolbar-btn {
  height: 20px;
  padding: 1px 6px;
  font-size: 11px;
}

.wb-flag {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  color: #374151;
}

.wb-status-online {
  color: #15803d;
  font-weight: 700;
}

.wb-status-offline {
  color: #b45309;
  font-weight: 600;
}

.wb-mono {
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.wb-window-statusbar {
  padding: 4px 8px;
  background: #eaeaea;
  border-top: 1px solid #b8b8b8;
  font-size: 11.5px;
  font-weight: 600;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.dt-pagination {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.dt-page-btn {
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
  background: #fff;
  border: 1px solid #8c8c8c;
  cursor: pointer;
}

.dt-page-btn.active {
  background: #316ac5;
  color: #fff;
  border-color: #1c2d87;
}

/* =========================================================================
   5. Modals with Input Labels on Top + Codecs Checkboxes + Select2 Dropdown
   ========================================================================= */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  align-items: center;
  justify-content: center;
  z-index: 1600;
  padding: 10px;
}

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

.wb-modal-window {
  width: 480px;
  max-width: 96vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--rnl-panel-bg);
  border: 2px solid #273992;
  box-shadow: 4px 4px 16px rgba(0, 0, 0, 0.5);
}

.wb-modal-body {
  padding: 12px 14px;
  background: #f4f4f4;
  overflow-y: auto;
}

/* Top-positioned labels on all modals */
.wb-form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.wb-form-group > label,
.wb-label-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: #1f2937;
}

.wb-input, .wb-select {
  width: 100%;
  padding: 5px 8px;
  font-family: var(--font-ui);
  font-size: 12.5px;
  color: #111111;
  background: #ffffff;
  border: 1px solid #7a7a7a;
}

.wb-input:focus, .wb-select:focus {
  outline: 2px solid #316ac5;
}

/* Allowed Codecs Checkbox Grid (Explicitly left-aligned so every checkbox stays beside its label) */
.codecs-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: #ffffff;
  border: 1px solid #8c8c8c;
  padding: 8px;
}

.wb-form-group .codec-checkbox-item,
.codec-checkbox-item {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 6px;
  padding: 4px 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: #111111;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.codec-checkbox-item:hover {
  background: #e8f0fe;
  border-color: #3b5998;
}

.codec-checkbox-item input[type="checkbox"] {
  appearance: auto;
  -webkit-appearance: checkbox;
  width: 15px;
  height: 15px;
  margin: 0;
  flex-shrink: 0;
  accent-color: #273992;
  cursor: pointer;
}

/* Recovery Channel Selector (Email vs Telephone SMS) */
.recovery-channel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.wb-form-group .recovery-channel-item,
.recovery-channel-item {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 6px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 600;
  color: #111111;
  background: #ffffff;
  border: 1px solid #8c8c8c;
  cursor: pointer;
}

.recovery-channel-item input[type="radio"] {
  appearance: auto;
  -webkit-appearance: radio;
  width: 14px;
  height: 14px;
  margin: 0;
  flex-shrink: 0;
  accent-color: #273992;
  cursor: pointer;
}

/* Custom Select2 Searchable Dropdown */
.select2-wrapper {
  position: relative;
  width: 100%;
}

.select2-trigger {
  width: 100%;
  padding: 5px 8px;
  background: #ffffff;
  border: 1px solid #7a7a7a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: #111;
  cursor: pointer;
}

.select2-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #316ac5;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
  z-index: 1800;
}

.select2-dropdown.open {
  display: block;
}

.select2-search-box {
  padding: 4px;
  background: #f0f4fa;
  border-bottom: 1px solid #d0d7e2;
}

.select2-search-input {
  width: 100%;
  padding: 4px 6px;
  font-size: 12px;
  border: 1px solid #8c8c8c;
}

.select2-options-list {
  max-height: 150px;
  overflow-y: auto;
}

.select2-option {
  padding: 5px 8px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
}

.select2-option:hover,
.select2-option.selected {
  background: #316ac5;
  color: #ffffff;
}

.wb-code-viewer {
  background: #141824;
  color: #e5e7eb;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.4;
  padding: 10px;
  overflow: auto;
  max-height: 380px;
  white-space: pre-wrap;
  user-select: text;
}

.toast-container {
  position: fixed;
  bottom: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 3500;
}

.toast {
  background: #ffffff;
  border: 2px solid #273992;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 600;
  color: #111;
  box-shadow: 2px 3px 8px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  gap: 6px;
}

.toast-success { border-color: #15803d; background: #f0fdf4; }
.toast-error { border-color: #b91c1c; background: #fef2f2; }

/* =========================================================================
   6. Small Screen Auto-Hidden Sidebar & Responsive Breakpoints
   ========================================================================= */
.wb-mobile-backdrop {
  display: none;
  position: fixed;
  top: 40px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1150;
}

.wb-mobile-backdrop.open {
  display: block;
}

@media (max-width: 992px) {
  .wb-sidebar {
    position: fixed;
    top: 40px;
    left: 0;
    bottom: 0;
    width: 210px !important;
    min-width: 210px !important;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.45);
    transform: translateX(-105%);
  }

  .wb-sidebar.mobile-open {
    transform: translateX(0);
  }

  .wb-desktop {
    padding: 6px;
  }

  .codecs-checkbox-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
