/**
 * Viewer CSS - Dedicated viewer for presentations and modules
 * Uses RC Theme design system tokens
 */

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

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--rc-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
  background: var(--rc-base, #070a08);
  color: var(--rc-ink, #e8f1ec);
}

/* Viewer container - fullscreen layout without body padding */
.viewer-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%; /* Full width by default; overridden with calc() when .app-shell-icon-only is applied (line 166) */
}

/* Traffic-light control bar */
.pv-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 55%), var(--rc-glass, rgba(17, 26, 21, 0.58));
  border-bottom: 1px solid var(--rc-border-strong, rgba(255, 255, 255, 0.14));
  backdrop-filter: blur(14px) saturate(125%);
  -webkit-backdrop-filter: blur(14px) saturate(125%);
  flex-shrink: 0;
  z-index: 900;
}

.pv-traffic-lights {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.pv-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: transform 0.1s ease, filter 0.1s ease;
}

.pv-dot:hover {
  transform: scale(1.15);
  filter: brightness(1.15);
}

.pv-dot:active {
  transform: scale(0.95);
}

.pv-dot:focus {
  outline: 2px solid color-mix(in oklab, var(--rc-brand, #35e08a) 55%, transparent);
  outline-offset: 2px;
}

.pv-dot-red    { background: #ff5f57; box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.3); }
.pv-dot-yellow { background: #ffbd2e; box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.3); }
.pv-dot-green  { background: #28c840; box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.3); }

.pv-title {
  font-size: 12px;
  color: var(--rc-ink-dim, #a9bbb1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  font-family: var(--rc-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
  text-align: center;
}

.pv-clock {
  font-size: 12px;
  color: var(--rc-ink-dim, rgba(240, 255, 250, 0.78));
  white-space: nowrap;
  font-family: var(--rc-font, system-ui, -apple-system, sans-serif);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* Sidebar toggle button (kept as text-style button to the far right) */
.viewer-btn-sidebar {
  margin-left: auto;
  padding: 0.4rem 0.6rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 60%), var(--rc-glass, rgba(17, 26, 21, 0.58));
  border: 1px solid var(--rc-border, rgba(255, 255, 255, 0.08));
  border-radius: var(--rc-radius-lg, 14px);
  color: var(--rc-ink, #e8f1ec);
  cursor: pointer;
  transition: all 0.12s ease;
  display: flex;
  align-items: center;
}

.viewer-btn-sidebar:hover {
  border-color: var(--rc-border-strong, rgba(255, 255, 255, 0.14));
}

.viewer-frame {
  flex: 1;
  width: 100%;
  position: relative;
  overflow: hidden;
  min-height: 0; /* Critical: allows proper scrolling */
}

.viewer-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* Presentation mode: iframe fills remaining space below control bar (flex: 1 on .viewer-frame handles this) */
/* Loading state */
.viewer-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--rc-ink-dim, #a9bbb1);
  font-size: 1rem;
}

/* Error state */
.viewer-error {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  max-width: 500px;
  padding: 2rem;
}

.viewer-error-title {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: #fc8181;
}

.viewer-error-message {
  color: var(--rc-ink-dim, #a9bbb1);
  line-height: 1.6;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .pv-bar {
    gap: 8px;
    padding: 6px 10px;
  }

  .pv-dot {
    width: 11px;
    height: 11px;
  }

  .pv-title {
    font-size: 11px;
  }

  .pv-clock {
    font-size: 10px;
  }
}

/* Fullscreen mode adjustments */
body:fullscreen,
body:-webkit-full-screen,
body:-moz-full-screen {
  background: var(--rc-base, #070a08);
}

body:fullscreen .pv-bar,
body:-webkit-full-screen .pv-bar,
body:-moz-full-screen .pv-bar {
  background: rgba(0, 0, 0, 0.9);
}

/* Viewer sidebar collapse styles */
/* Note: Sidebar transform/overlay rules are in app-shell.css */
body.viewer-sidebar-collapsed .viewer-container {
  margin-left: 0;
  transition: margin-left 0.3s ease;
}

/* Icon-only rail on viewer page - offset from 56px rail */
body.app-shell-icon-only .viewer-container {
  margin-left: var(--shell-width-collapsed, 56px);
  width: calc(100% - var(--shell-width-collapsed, 56px));
  transition: margin-left 0.3s ease;
}
