/* ===============================
   SCREENPLAY SIDEBAR PILL
   Floating vertical tool strip, matches page-indicator / word-count-pill styling.
   Positioned fixed, top-right of the canvas viewport.
   =============================== */

.sp-sidebar-pill {
  position: fixed;
  z-index: 50;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 3px;

  background: rgba(30, 30, 36, 0.92);
  border: 1px solid var(--border, #4b4b50);
  border-radius: 8px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);

  user-select: none;
  opacity: 0.85;
  transition: opacity 0.15s ease;
}

.sp-sidebar-pill:hover {
  opacity: 1;
}

.sp-sidebar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--text-secondary, #b5b5b5);
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease;
  position: relative;
}

.sp-sidebar-btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.sp-sidebar-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary, #e6e6e6);
}

.sp-sidebar-btn-active,
.sp-sidebar-btn.notes-active,
.sp-sidebar-btn.outline-active {
  color: var(--accent);
  background: rgba(209, 139, 60, 0.15);
}

.sp-sidebar-btn-active:hover,
.sp-sidebar-btn.notes-active:hover,
.sp-sidebar-btn.outline-active:hover {
  color: var(--accent);
  background: rgba(209, 139, 60, 0.22);
}

/* Note badge on the sidebar notes button */
.sp-sidebar-btn .notes-badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 12px;
  height: 12px;
  padding: 0 2px;
  font-size: 8px;
}

/* ===============================
   STATS PANEL
   Uses same shell pattern as notes/outline panels
   =============================== */

.stats-panel {
  width: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--bg-panel);
  border-left: none;
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease, min-width 0.25s ease;
  opacity: 0;
  pointer-events: none;
}

.stats-panel.stats-panel-open {
  width: 320px;
  min-width: 320px;
  opacity: 1;
  border-left: 1px solid var(--border);
  pointer-events: auto;
  transition: width 0.25s ease, min-width 0.25s ease, opacity 0.15s ease 0.1s;
}

.stats-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.stats-panel-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

.stats-panel-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease;
}

.stats-panel-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.stats-panel-close svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stats-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
}

/* ===============================
   STATISTICS CONTENT (rendered inside panel)
   =============================== */

.stats-overview {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.stats-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  text-align: center;
}

.stats-card-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.stats-card-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.stats-section {
  margin-bottom: 14px;
}

.stats-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* Ratio Bar */
.stats-ratio-bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  margin: 8px 0;
  background: var(--bg-elevated);
}

.stats-ratio-segment {
  height: 100%;
}

.stats-ratio-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.stats-ratio-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-secondary);
}

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

/* Character Table */
.stats-char-table {
  width: 100%;
  border-collapse: collapse;
}

.stats-char-table th {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  text-align: left;
  padding: 3px 6px;
  border-bottom: 1px solid var(--border);
}

.stats-char-table th:not(:first-child) {
  text-align: right;
}

.stats-char-table td {
  font-size: 11px;
  color: var(--text-primary);
  padding: 4px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.stats-char-table td:not(:first-child) {
  text-align: right;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.stats-char-table tr:last-child td {
  border-bottom: none;
}

.stats-char-name {
  font-weight: 600;
}

.stats-char-bar-cell {
  width: 60px;
}

.stats-char-bar {
  height: 5px;
  border-radius: 3px;
  background: rgba(209, 139, 60, 0.2);
  float: right;
}

.stats-char-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
}

/* ===============================
   PRINT
   =============================== */

@media print {
  .sp-sidebar-pill,
  .stats-panel {
    display: none !important;
  }
}
