/* CTI call-log side panel: LEFT side (softphone sits bottom-right). Stack above phone widget (1080). */

:root {
  --og-cti-panel-width: 40vw;
  --og-cti-panel-min: 320px;
  /* phone.css uses --z-phone-widget: 1080; panel must sit on top */
  --og-cti-panel-z: var(--z-cti-panel, 1100);
  /* Set by JS from .navbar height (fallback matches phone widget) */
  --og-cti-top: 56px;
  --og-cti-height: calc(100vh - 56px);
}

/* When nav sidebar is open: dock CTI after it and cap width so the panel does not grow past the viewport.
   (Previously only `left: 250px` + same 40vw made the right edge jump ~250px — felt “wider”.)
   body.og-sidebar-open is toggled from base.html (more reliable than :has() alone). */
body.og-sidebar-open .og-cti-panel:not(.og-cti-panel--expanded),
body:has(#sidebar.open) .og-cti-panel:not(.og-cti-panel--expanded) {
  left: 250px;
  width: min(var(--og-cti-panel-width), calc(100vw - 250px));
  max-width: calc(100vw - 250px);
  transition: left 0.3s ease, width 0.22s ease;
}

/* Full-width expand still clears the sidebar strip so content stays usable */
body.og-sidebar-open .og-cti-panel.og-cti-panel--expanded,
body:has(#sidebar.open) .og-cti-panel.og-cti-panel--expanded {
  left: 250px !important;
  width: calc(100vw - 250px) !important;
  min-width: 0 !important;
  max-width: calc(100vw - 250px) !important;
}

#og-cti-panel-root[hidden] {
  display: none !important;
}

#og-cti-panel-root.og-cti-panel--open {
  display: flex !important;
}

.og-cti-panel {
  position: fixed;
  top: var(--og-cti-top, 56px);
  left: 0;
  right: auto;
  height: var(--og-cti-height, calc(100vh - 56px));
  width: var(--og-cti-panel-width);
  min-width: var(--og-cti-panel-min);
  max-width: 100vw;
  z-index: var(--og-cti-panel-z);
  flex-direction: column;
  background: var(--bs-body-bg, var(--surface-raised));
  /* Rounded right edge — docked to viewport left */
  border-top-right-radius: 0; 
  border-bottom-right-radius: 8px;
  /* Allow Live Assist radial to extend slightly outside inner bounds */
  overflow: visible;
  box-shadow: 4px 0 16px rgba(0, 0, 0, 0.35);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  transition: width 0.22s ease, min-width 0.22s ease, box-shadow 0.2s ease, left 0.3s ease;
}

/* Drag handle: right edge only (expand button remains separate full-width mode) */
.og-cti-panel__resize {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  z-index: calc(var(--og-cti-panel-z) + 2);
  cursor: ew-resize;
  background: transparent;
  touch-action: none;
}
.og-cti-panel__resize:hover,
.og-cti-panel__resize:focus-visible {
  background: rgba(13, 110, 253, 0.25);
}
.og-cti-panel__resize:focus {
  outline: none;
}
.og-cti-panel.og-cti-panel--expanded .og-cti-panel__resize {
  display: none;
}
.og-cti-panel--resizing .og-cti-panel__frame {
  pointer-events: none;
}
.og-cti-panel--resizing {
  transition: none !important;
}

.og-cti-panel.og-cti-panel--expanded {
  width: 100vw !important;
  min-width: 100%;
  max-width: 100vw;
}

.og-cti-panel__header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.5rem 0 1rem;
  min-height: 46px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--nav-bg-a);
  color: var(--text-inverse);
  box-shadow: none;
  overflow: hidden;
}

.og-cti-panel__title {
  font-family: 'Lato', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.05rem;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}

/* Modern pill actions — title truncates first */
.og-cti-panel__actions {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.og-cti-panel__btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  padding: 0.3rem 0.45rem;
  border-radius: 0.25rem;  /* matches .btn */
  font-size: 0.75rem;
  box-shadow: none;
  transition: color 0.2s ease, background 0.2s ease;
}

.og-cti-panel__btn:hover {
  color: var(--text-inverse);
  background: rgba(255, 255, 255, 0.1); /* matches .sidebar .nav-link:hover */
  border-color: transparent;
  box-shadow: none;
}

.og-cti-panel__btn--close {
  border: none; /* remove the red tint border */
  color: rgba(255, 255, 255, 0.6);
}

.og-cti-panel__btn--close:hover {
  color: var(--danger);
  background: rgba(var(--danger-rgb), 0.18);
}

@media (max-width: 420px) {
  .og-cti-panel__btn-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .og-cti-panel__btn {
    padding: 0.45rem 0.55rem;
  }
}

/* Tab bar lives inside the header — no separate strip */
.og-cti-panel__tabbar {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.3rem;
  overflow-x: auto;
  overflow-y: visible;
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
  scrollbar-width: none;
}

.og-cti-panel__tabbar::-webkit-scrollbar {
  display: none;
}

.og-cti-panel__tab {
  flex: 0 1 auto;
  max-width: 180px;
  min-width: 60px;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.5rem 0.3rem 0.6rem;
  font-size: 0.72rem;
  font-family: 'Lato', sans-serif;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 0.25rem;
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.7);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.og-cti-panel__tab:hover:not(.og-cti-panel__tab--active) {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-inverse);
}

.og-cti-panel__tab--active {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.35);
  border-bottom: 2px solid var(--primary);
  color: var(--text-inverse);
  font-weight: 600;
}

.og-cti-panel__tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.og-cti-panel__tab-close {
  flex-shrink: 0;
  opacity: 0.5;
  padding: 0 0.1rem;
  margin-left: 0.1rem;
  font-size: 0.9rem;
  line-height: 1;
  border-radius: 3px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.7);
  transition: opacity 0.15s ease, background 0.15s ease;
}

.og-cti-panel__tab-close:hover {
  opacity: 1;
  color: var(--danger);
  background: rgba(var(--danger-rgb), 0.22);
}

.og-cti-panel__frames-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  border-radius: 0 0 8px 0;
}

/* Live Assist: layout + visuals in static/css/live-assist-radial.css */

.og-cti-panel__frames {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}

.og-cti-panel__frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--bs-body-bg, var(--surface-raised));
}

/* Shown until iframe `load` — makes panel feel responsive while call-log HTML boots */
.og-cti-panel__frame.og-cti-frame--loading {
  background: linear-gradient(
    110deg,
    rgba(128, 128, 128, 0.06) 0%,
    rgba(128, 128, 128, 0.14) 42%,
    rgba(128, 128, 128, 0.06) 84%
  );
  background-size: 200% 100%;
  animation: og-cti-frame-shimmer 1.05s ease-in-out infinite;
}
@keyframes og-cti-frame-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

/* Hide iframe stack but keep tab bar (minimize) */
.og-cti-panel--frames-collapsed .og-cti-panel__frames-wrap {
  flex: 0 0 0;
  min-height: 0;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.og-cti-panel.og-cti-panel--open.og-cti-panel--frames-collapsed {
  height: auto;
  min-height: 0;
  max-height: var(--og-cti-height, calc(100vh - 56px));
}

/* Full-page app shell hidden in iframe embed (cti_panel_embed=1) */
body.og-cti-embed nav.navbar,
body.og-cti-embed #flash-messages,
body.og-cti-embed .toast-container,
body.og-cti-embed > footer {
  display: none !important;
}

body.og-cti-embed main#contentColumn {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding-top: 0.75rem !important;
  padding-bottom: 0.75rem !important;
}

body.og-cti-panel-active {
  overflow-x: hidden;
}

/* Dark theme: soften highlights and keep header readable */
[data-bs-theme="dark"] .og-cti-panel {
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.6);
}
