/* ============================================================
   RACK PLANNER — Complete Stylesheet
   ============================================================ */

/* ----------------------------------------------------------
   1. APP LAYOUT
   ---------------------------------------------------------- */
.rp-app {
  position: fixed;
  top: 72px;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-rows: 48px 1fr 36px;
  background: #0c1222;
  z-index: 50;
  overflow: hidden;
}

.rp-main {
  display: grid;
  grid-template-columns: var(--left-width, 280px) 4px 1fr 4px var(--right-width, 300px);
  overflow: hidden;
}

.rp-resizer {
  background: rgba(255, 255, 255, 0.05);
  cursor: col-resize;
  transition: background 0.2s;
  z-index: 10;
}

.rp-resizer:hover, .rp-resizer.active {
  background: var(--accent);
}

/* ----------------------------------------------------------
   2. TOOLBAR
   ---------------------------------------------------------- */
.rp-toolbar {
  height: 48px;
  background: #111827;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 16px;
}

.rp-toolbar-left,
.rp-toolbar-center,
.rp-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rp-toolbar-icon {
  font-size: 20px;
  color: var(--accent);
}

.rp-toolbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
}

.rp-toolbar-badge {
  font-size: 9px;
  background: var(--accent);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  line-height: 1.4;
}

.rp-toolbar-select-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-right: 8px;
}

.rp-toolbar-select {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.rp-toolbar-select:focus {
  border-color: var(--accent);
}

.rp-toolbar-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.rp-toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.rp-toolbar-btn--danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.rp-btn-label {
  pointer-events: none;
}

/* ----------------------------------------------------------
   3. SIDEBARS
   ---------------------------------------------------------- */
.rp-sidebar {
  background: #111827;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rp-sidebar--left {
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.rp-sidebar--right {
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  overflow-y: auto;
}

.rp-sidebar--right::-webkit-scrollbar {
  width: 5px;
}

.rp-sidebar--right::-webkit-scrollbar-track {
  background: transparent;
}

.rp-sidebar--right::-webkit-scrollbar-thumb {
  background: #374151;
  border-radius: 3px;
}
.rp-sidebar--right::-webkit-scrollbar-thumb:hover {
  background: #4b5563;
}

.rp-sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.rp-sidebar-head h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0;
}

.rp-btn-sm {
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.rp-btn-sm:hover {
  background: var(--accent);
  color: #fff;
}

/* ----------------------------------------------------------
   3a. SEARCH (left sidebar)
   ---------------------------------------------------------- */
.rp-search-wrap {
  position: relative;
  padding: 10px 12px 6px;
}

.rp-search-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 32px 8px 10px;
  font-size: 13px;
  outline: none;
  transition: var(--transition);
  box-sizing: border-box;
}

.rp-search-input::placeholder {
  color: var(--text-muted);
}

.rp-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.2);
}

.rp-search-clear {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 4px;
  line-height: 1;
  transition: var(--transition);
}

.rp-search-clear:hover {
  color: var(--text);
}

/* ----------------------------------------------------------
   4. CATALOG (left sidebar)
   ---------------------------------------------------------- */
.catalog-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.catalog-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  cursor: pointer;
  border-radius: 4px;
  white-space: nowrap;
  transition: var(--transition);
}

.catalog-tab.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
}

.catalog-tab:hover:not(.active) {
  color: var(--text-secondary);
}

.catalog-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.catalog-list::-webkit-scrollbar {
  width: 5px;
}

.catalog-list::-webkit-scrollbar-track {
  background: transparent;
}

.catalog-list::-webkit-scrollbar-thumb {
  background: #374151;
  border-radius: 3px;
}
.catalog-list::-webkit-scrollbar-thumb:hover {
  background: #4b5563;
}

.catalog-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 10px 12px;
  cursor: grab;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
  user-select: none;
}

.catalog-item:hover {
  border-style: solid;
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.06);
}

.catalog-item-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.catalog-item-name {
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
}

.catalog-item-specs {
  font-size: 10px;
  color: var(--text-muted);
}

.catalog-item-action {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 3px 8px;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}

.catalog-item:hover .catalog-item-action {
  background: var(--accent);
  color: #fff;
}

.catalog-item-action.added-success {
  background: var(--success) !important;
  color: #fff !important;
  border-color: var(--success) !important;
}

/* ----------------------------------------------------------
   5. CANVAS
   ---------------------------------------------------------- */
.rp-canvas {
  background: #0a0f1a;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 20px 20px;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  position: relative;
  padding: 40px 0;
}

.rp-canvas::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.rp-canvas::-webkit-scrollbar-track {
  background: transparent;
}
.rp-canvas::-webkit-scrollbar-thumb {
  background: #374151;
  border-radius: 4px;
}
.rp-canvas::-webkit-scrollbar-thumb:hover {
  background: #4b5563;
}

.rp-canvas-content {
  transition: transform 0.15s ease;
  transform-origin: top center;
  margin: 0 auto;
}

/* ----------------------------------------------------------
   6. CABINET & RACK
   ---------------------------------------------------------- */
.cabinet-wrapper {
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cabinet-rack {
  position: relative;
  background: #0f172a;
  border: 8px solid #1e293b;
  border-top: 16px solid #1e293b;
  border-bottom: 20px solid #1e293b;
  width: 440px;
  min-height: 400px;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.9);
  padding: 0 4px;
}

.cabinet-rack::before,
.cabinet-rack::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 12px;
  z-index: 2;
  opacity: 0.5;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 16px,
    rgba(255, 255, 255, 0.08) 16px,
    rgba(255, 255, 255, 0.08) 18px,
    transparent 18px,
    transparent 24px,
    rgba(255, 255, 255, 0.06) 24px,
    rgba(255, 255, 255, 0.06) 25px,
    transparent 25px,
    transparent 42px
  );
  pointer-events: none;
}

.cabinet-rack::before {
  left: 4px;
}

.cabinet-rack::after {
  right: 4px;
}

.rack-slots-container {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.rack-slot {
  display: grid;
  grid-template-columns: 35px 1fr;
  align-items: stretch;
  height: 42px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.25);
  position: relative;
  flex-shrink: 0;
}

.rack-slot.drop-hover {
  background: rgba(59, 130, 246, 0.1);
}

.slot-number {
  background: #1e293b;
  color: var(--text-muted);
  font-family: monospace;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 2px solid #334155;
  user-select: none;
}

.slot-dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 11px;
  font-style: italic;
  cursor: pointer;
  transition: var(--transition);
  z-index: 3;
}

.slot-dropzone:hover {
  background: rgba(59, 130, 246, 0.05);
  color: var(--accent-cyan);
}

/* ----------------------------------------------------------
   7. PLACED DEVICES & ACCESSORIES
   ---------------------------------------------------------- */
.rack-shelf-bg {
  position: absolute;
  bottom: 1px;
  left: 37px;
  right: 6px;
  height: 6px;
  background: linear-gradient(to bottom, #475569, #1e293b);
  border-bottom: 2px solid #0f172a;
  border-radius: 2px;
  z-index: 4; /* Below placed devices (which are z-index 5) */
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.1);
}

.placed-device {
  position: absolute;
  left: 37px;
  right: 6px;
  z-index: 5;
  background: #1e293b;
  border: 1.5px solid #475569;
  border-radius: 3px;
  padding: 3px 8px 2px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: var(--transition);
  cursor: grab;
  overflow: hidden;
}

.placed-device:hover {
  border-color: var(--accent-cyan);
  box-shadow: 0 6px 15px rgba(6, 182, 212, 0.15);
}

.placed-device.drop-hover {
  border: 1.5px dashed var(--accent) !important;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.4) !important;
  filter: brightness(1.2);
}

.placed-device.newly-added-pulse {
  animation: flash-green 1.2s ease-out;
}

body.dragging-active .placed-device * {
  pointer-events: none !important;
}

/* Device faceplate structure */
.device-faceplate-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
}

.device-faceplate-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.device-faceplate-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  height: 12px;
  margin-top: 1px;
}

.device-faceplate-label {
  font-size: 8px;
  font-family: monospace;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.device-faceplate {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.device-faceplate-info {
  display: flex;
  flex-direction: column;
}

.device-model {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.3px;
  line-height: 1.3;
}

.device-desc {
  font-size: 9px;
  color: var(--text-secondary);
  line-height: 1.2;
}

.device-logo {
  font-family: monospace;
  font-size: 8px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.25);
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
}

/* LED indicators */
.device-leds {
  display: flex;
  align-items: center;
  gap: 3px;
}

.led {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
}

.led.glowing {
  background: var(--success);
  box-shadow: 0 0 4px var(--success);
}

.led.orange {
  background: var(--warning);
  box-shadow: 0 0 4px var(--warning);
}

/* Port grids */
.device-ports {
  display: grid;
  grid-template-rows: repeat(2, auto);
  grid-auto-flow: column;
  gap: 2px;
  align-items: center;
}

.patch-panel-ports {
  grid-template-rows: 1fr !important;
  width: 100%;
  padding: 0 12px;
  box-sizing: border-box;
  justify-items: center;
  gap: 0;
}

/* Realistic RJ45 Ports */
.port-dot {
  width: 12px;
  height: 10px;
  border-radius: 1.5px;
  background: #050810;
  border: 1px solid #94a3b8; /* silver metallic shield */
  border-bottom: 2px solid #94a3b8; /* thicker bottom */
  position: relative;
  transition: var(--transition);
}

/* Simulate the little clip notch at the top */
.port-dot::after {
  content: '';
  position: absolute;
  top: -1px;
  left: 3px;
  width: 4px;
  height: 2px;
  background: #050810;
  border-left: 1px solid #94a3b8;
  border-right: 1px solid #94a3b8;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* RJ45 active state glow inside the hole and border */
.port-dot.active {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--success);
}
.port-dot.active::after {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--success);
}

.port-dot.poe-capable {
  display: flex;
  align-items: center;
  justify-content: center;
}
.port-dot.poe-capable::before {
  content: "⚡";
  font-size: 7px;
  line-height: 1;
  opacity: 0.3;
  color: #fff;
  z-index: 2;
  margin-top: 1px;
}

.port-dot.poe {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--warning);
  display: flex;
  align-items: center;
  justify-content: center;
}
.port-dot.poe::before {
  content: "⚡";
  font-size: 7px;
  line-height: 1;
  opacity: 1;
  color: #fff;
  z-index: 2;
  margin-top: 1px;
}
.port-dot.poe::after {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--warning);
}

.port-dot.uplink {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--accent);
}
.port-dot.uplink::after {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--accent);
}

.port-dot.wan-port {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  position: relative;
}
.port-dot.wan-port::after {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
}
.port-dot.wan-port::before {
  content: "WAN";
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 6px;
  color: #ef4444;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-shadow: none;
}

.port-dot.wan-last {
  margin-right: 36px; /* Large gap between WAN and LAN */
}

.patch-panel-ports .port-dot {
  width: 14px;
  height: 12px;
}
.patch-panel-ports .port-dot::after {
  width: 6px;
  left: 3px;
}

/* Brush strip & shelf plate */
.device-brush-strip {
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 0px,
    rgba(255, 255, 255, 0.04) 2px,
    transparent 2px,
    transparent 5px
  );
  border-radius: 2px;
}

.device-shelf-plate {
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.06) 0px,
    rgba(255, 255, 255, 0.06) 12px,
    rgba(255, 255, 255, 0.02) 12px,
    rgba(255, 255, 255, 0.02) 24px
  );
  border-radius: 2px;
}

/* Device delete / actions */
.device-actions {
  position: absolute;
  top: 2px;
  right: 4px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: var(--transition);
  z-index: 10;
}

.placed-device:hover .device-actions {
  opacity: 1;
}

.device-delete-btn {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 3px;
  color: var(--danger);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1;
  padding: 0;
}

.device-delete-btn:hover {
  background: var(--danger);
  color: #fff;
}

/* ----------------------------------------------------------
   8. BRAND COLORS
   ---------------------------------------------------------- */
.device-brand-ubiquiti {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  border-left: 4px solid var(--accent);
}

.device-brand-cisco {
  background: linear-gradient(135deg, #062016, #112a1f);
  border-left: 4px solid var(--success);
}

.device-brand-mikrotik {
  background: linear-gradient(135deg, #2d1b10, #382415);
  border-left: 4px solid var(--warning);
}

.device-brand-tplink {
  background: linear-gradient(135deg, #0f2b3e, #183e58);
  border-left: 4px solid #00a4e4;
}

.device-brand-araknis {
  background: linear-gradient(135deg, #111e25, #1f2d37);
  border-left: 4px solid #005691;
}

.device-brand-cyberpower {
  background: linear-gradient(135deg, #111827, #1f2937);
  border-left: 4px solid #facc15;
}

.device-brand-denon {
  background: linear-gradient(135deg, #181818, #2a2a2a);
  border-left: 4px solid #b89753;
}

.device-brand-marantz {
  background: linear-gradient(135deg, #101010, #222222);
  border-left: 4px solid #d4af37;
}

.device-brand-apple {
  background: linear-gradient(135deg, #2c2d30, #3a3b3e);
  border-left: 4px solid #a3aaae;
}

.device-brand-sony {
  background: linear-gradient(135deg, #0b0c10, #1b1c21);
  border-left: 4px solid #0096d6;
}

.device-brand-sonos {
  background: linear-gradient(135deg, #111111, #252525);
  border-left: 4px solid #e1a12c;
}

.device-brand-generic {
  background: linear-gradient(135deg, #1f2937, #374151);
  border-left: 4px solid var(--text-secondary);
}

/* ----------------------------------------------------------
   9. RIGHT SIDEBAR PANELS
   ---------------------------------------------------------- */
.rp-panel {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.rp-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.rp-panel-head span {
  font-size: 16px;
}

.rp-panel-head h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin: 0;
}

.rp-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.rp-setting {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rp-setting label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

.rp-setting input {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: var(--text);
  padding: 7px 10px;
  font-size: 14px;
  font-weight: 600;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  transition: var(--transition);
}

.rp-setting input:focus {
  border-color: var(--accent);
}

.rp-btn-full {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 10px;
}

.rp-btn-full:hover {
  filter: brightness(1.15);
}

/* ----------------------------------------------------------
   10. VALIDATION (compact rows)
   ---------------------------------------------------------- */
.rp-val-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rp-val-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  transition: var(--transition);
  font-size: 11px;
}

.rp-val-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.rp-val-item.valid .rp-val-dot {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.rp-val-item.warning .rp-val-dot {
  background: var(--warning);
  box-shadow: 0 0 6px var(--warning);
}

.rp-val-item.danger .rp-val-dot {
  background: var(--danger);
  box-shadow: 0 0 6px var(--danger);
}

.rp-val-item.warning {
  border-color: rgba(245, 158, 11, 0.2);
  background: rgba(245, 158, 11, 0.04);
}

.rp-val-item.danger {
  border-color: rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.04);
}

.rp-val-item .validation-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.rp-val-item .validation-name {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.rp-val-item .validation-value {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  max-width: 140px;
}

/* ----------------------------------------------------------
   11. STATUS BAR
   ---------------------------------------------------------- */
.rp-statusbar {
  height: 36px;
  background: #111827;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 12px;
}

.rp-status-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rp-status-chip {
  color: var(--text-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.rp-status-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rp-zoom-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: var(--transition);
  padding: 0;
  line-height: 1;
}

.rp-zoom-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.rp-zoom-slider {
  width: 100px;
  accent-color: var(--accent);
  height: 4px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

.rp-zoom-slider::-webkit-slider-runnable-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.rp-zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  margin-top: -4px;
  box-shadow: 0 0 4px rgba(59, 130, 246, 0.4);
}

.rp-zoom-slider::-moz-range-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  border: none;
}

.rp-zoom-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  box-shadow: 0 0 4px rgba(59, 130, 246, 0.4);
}

.rp-zoom-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 38px;
  text-align: center;
}

/* ----------------------------------------------------------
   12. BOM DRAWER
   ---------------------------------------------------------- */
.rp-bom-drawer {
  position: absolute;
  bottom: 36px;
  left: 0;
  right: 0;
  height: 45vh;
  background: #111827;
  border-top: 2px solid var(--accent);
  transform: translateY(calc(100% + 36px));
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 40;
  display: flex;
  flex-direction: column;
}

.rp-bom-drawer.open {
  transform: translateY(0);
}

.rp-bom-handle {
  display: flex;
  justify-content: center;
  padding: 8px;
  cursor: pointer;
}

.rp-bom-handle-bar {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.rp-bom-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.rp-bom-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.rp-bom-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: var(--transition);
  line-height: 1;
}

.rp-bom-close:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.rp-bom-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.rp-bom-body::-webkit-scrollbar {
  width: 6px;
}

.rp-bom-body::-webkit-scrollbar-track {
  background: transparent;
}

.rp-bom-body::-webkit-scrollbar-thumb {
  background: #374151;
  border-radius: 3px;
}
.rp-bom-body::-webkit-scrollbar-thumb:hover {
  background: #4b5563;
}

.manifest-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

.manifest-table-wrapper {
  overflow-x: auto;
}

.manifest-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.manifest-table th,
.manifest-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.manifest-table th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

.manifest-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}

.manifest-table th.sortable:hover {
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.08);
}

.manifest-table .sort-icon {
  margin-left: 4px;
  font-size: 10px;
  opacity: 0.5;
}

.manifest-table td {
  font-size: 13px;
  color: var(--text);
}

.manifest-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.manifest-summary-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-self: start;
}

.manifest-summary-card h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
}

.summary-row.total {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 10px;
}

/* ----------------------------------------------------------
   13. ENDPOINT TABLE (right sidebar)
   ---------------------------------------------------------- */
.endpoint-list-wrapper {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  max-height: 160px;
  overflow-y: auto;
}

.endpoint-list-wrapper::-webkit-scrollbar {
  width: 5px;
}

.endpoint-list-wrapper::-webkit-scrollbar-track {
  background: transparent;
}

.endpoint-list-wrapper::-webkit-scrollbar-thumb {
  background: #374151;
  border-radius: 3px;
}
.endpoint-list-wrapper::-webkit-scrollbar-thumb:hover {
  background: #4b5563;
}

.endpoint-table {
  width: 100%;
  font-size: 11px;
  border-collapse: collapse;
}

.endpoint-table th {
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 9px;
  padding: 5px 6px;
  letter-spacing: 0.3px;
  text-align: left;
  position: sticky;
  top: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1;
}

.endpoint-table td {
  color: var(--text);
  padding: 4px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  vertical-align: middle;
}

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

.endpoint-delete-btn {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 3px;
  color: var(--danger);
  font-size: 10px;
  cursor: pointer;
  transition: var(--transition);
  padding: 0;
  line-height: 1;
}

.endpoint-delete-btn:hover {
  background: var(--danger);
  color: #fff;
}

/* Endpoint badges */
.endpoint-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: inline-block;
}

.badge-wireless {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-cctv {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-access {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.badge-voip {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Draggable endpoint rows */
.draggable-endpoint-row {
  cursor: grab;
  transition: var(--transition);
}

.draggable-endpoint-row.dragging-row {
  opacity: 0.4;
}

.drag-over-row {
  border-top: 2px solid var(--accent) !important;
}

.endpoint-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 10px;
  padding: 0 2px;
  user-select: none;
}

.endpoint-drag-handle:hover {
  color: var(--text-secondary);
}

/* ----------------------------------------------------------
   14. MODALS
   ---------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 40, 0.85);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  padding: 20px;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #1e293b;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: translateY(20px);
  transition: transform var(--transition);
}

.modal-content::-webkit-scrollbar {
  width: 6px;
}

.modal-content::-webkit-scrollbar-track {
  background: transparent;
}

.modal-content::-webkit-scrollbar-thumb {
  background: #374151;
  border-radius: 3px;
}
.modal-content::-webkit-scrollbar-thumb:hover {
  background: #4b5563;
}

.modal-overlay.open .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.modal-header h2,
.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: var(--transition);
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

/* Modal form elements */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  font-size: 15px;
  transition: var(--transition);
  width: 100%;
  box-sizing: border-box;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.form-grid .form-group {
  margin-bottom: 0;
}

/* Modal buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
}

.btn.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn.btn-primary:hover {
  filter: brightness(1.15);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.btn.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

/* ----------------------------------------------------------
   15. ANIMATIONS
   ---------------------------------------------------------- */
@keyframes pulse-led {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

@keyframes flash-green {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    filter: brightness(1.2);
  }
  50% {
    box-shadow: 0 0 20px 10px rgba(16, 185, 129, 0.4);
    filter: brightness(1.4);
  }
  100% {
    box-shadow: none;
    filter: none;
  }
}

/* ----------------------------------------------------------
   16. PRINT STYLES
   ---------------------------------------------------------- */
.rp-print-header {
  display: none;
}

.print-only {
  display: none;
}

@media print {
  @page {
    margin: 10mm;
  }

  html, body, .rp-app, .rp-main, .rp-canvas, .rp-canvas-content, .cabinet-wrapper, .rp-print-header {
    background: white !important;
    background-color: white !important;
    background-image: none !important;
    color: black !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  html, body {
    height: auto !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  .rp-print-header {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #000;
    padding-top: 20px;
    padding-bottom: 10px;
    margin-bottom: 10px;
  }
  .rp-print-header h2 { margin: 0; font-size: 24px; color: black !important; line-height: 1.2; }
  .rp-print-header p { margin: 2px 0; font-size: 14px; color: #555 !important; }
  .rp-print-header-right { text-align: right; }

  .header, .footer, .mobile-nav,
  .rp-toolbar,
  .rp-sidebar,
  .rp-statusbar,
  .rp-resizer,
  .device-delete-btn,
  .rp-bom-handle,
  .rp-bom-close {
    display: none !important;
  }

  .rp-app {
    position: static !important;
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  .rp-main {
    position: static !important;
    display: block !important;
    height: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    order: 3 !important;
    page-break-inside: avoid !important;
  }

  #print-header-bom { order: 0 !important; }
  #print-header-rack { 
    display: none !important;
  }

  .rp-canvas {
    background: white !important;
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
    display: block !important;
  }

  #cabinet-rack {
    display: none !important;
  }

  .print-only {
    display: block !important;
  }

  .cabinet-rack {
    margin: 0 auto !important;
    page-break-inside: avoid;
    background: #fff !important;
    border: 2px solid #ccc !important;
    border-top: 2px solid #ccc !important;
    border-bottom: 2px solid #ccc !important;
    box-shadow: none !important;
  }
  .cabinet-rack::before,
  .cabinet-rack::after {
    display: none !important;
  }
  
  .cabinet-post {
    background: #f1f5f9 !important;
    border-left: 1px solid #ccc !important;
    border-right: 1px solid #ccc !important;
  }
  
  .slot-number {
    background: #fff !important;
    color: #666 !important;
    border-bottom: 1px solid #ddd !important;
    border-right: 1px solid #ddd !important;
  }

  .placed-device {
    background: #f8fafc !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
  }
  
  .device-faceplate-top {
    background: #e2e8f0 !important;
    border-bottom: 1px solid #ccc !important;
  }
  
  .device-faceplate-bottom {
    background: #fff !important;
  }
  
  .device-faceplate-label, .device-logo {
    color: #000 !important;
  }

  .rp-bom-drawer {
    position: static !important;
    transform: none !important;
    display: block !important;
    height: auto !important;
    background: white !important;
    color: black !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    page-break-before: auto !important;
    page-break-after: always !important;
    order: 1 !important;
    margin-bottom: 20px !important;
  }

  .rp-bom-drawer * {
    color: black !important;
    border-color: #ccc !important;
  }

  .rp-bom-header {
    background: none !important;
    border-bottom: 2px solid #000 !important;
    color: black !important;
    padding: 0 0 10px 0 !important;
  }

  .manifest-grid th {
    background: #f1f5f9 !important;
    color: black !important;
    font-weight: bold !important;
  }

  .manifest-grid td {
    color: black !important;
  }
}

/* ----------------------------------------------------------
   17. RESPONSIVE
   ---------------------------------------------------------- */
@media (max-width: 1024px) {
  .rp-main {
    grid-template-columns: var(--left-width, 240px) 4px 1fr 4px var(--right-width, 260px);
  }

  .rp-btn-label {
    display: none;
  }

  .cabinet-rack {
    width: 380px;
  }
}

@media (max-width: 768px) {
  .rp-main {
    grid-template-columns: 1fr;
  }
  .rp-resizer {
    display: none;
  }

  .rp-sidebar {
    display: none;
  }

  .rp-statusbar .rp-status-left {
    display: none;
  }

  .manifest-grid {
    grid-template-columns: 1fr;
  }

  .cabinet-rack {
    width: 100%;
    max-width: 440px;
  }
}
