/**
 * PRESENTATION STYLES
 *
 * Avery brand presentation viewer
 * Warm, welcoming design with orange accents and Rubik typography
 */

/* Import Avery brand font */
@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@300;400;500;600;700&display=swap');

/* CSS Variables - Avery Brand */
:root {
  /* Primary Colors */
  --primary-orange-light: #FF8C00;
  --primary-orange-dark: #FF6B35;
  --text-dark: #333333;
  --text-gray: #666666;
  --text-light: #888888;

  /* Backgrounds */
  --overlay-light: rgba(255, 140, 0, 0.05);
  --white-overlay: rgba(255, 255, 255, 0.9);
  --border-orange: rgba(255, 140, 0, 0.2);

  /* Typography */
  --font-primary: 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Spacing */
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;

  /* Shadows */
  --shadow-sm: 0 4px 12px rgba(255, 140, 0, 0.1);
  --shadow-md: 0 8px 32px rgba(255, 140, 0, 0.15);
  --shadow-lg: 0 12px 40px rgba(255, 140, 0, 0.2);

  /* Transitions */
  --transition: all 0.3s ease;
}

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-primary);
  background: linear-gradient(135deg, rgba(255, 140, 0, 0.03) 0%, rgba(255, 165, 0, 0.06) 100%), #0a0a0a;
  color: #ffffff;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

/* Main container layout */
#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

/* PDF canvas container - takes most of the space */
#pdf-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  overflow: hidden;
  background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
}

#pdf-canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  border-radius: 4px;
}

/* PDF Link Layer */
#pdf-link-layer {
  pointer-events: none;
}

#pdf-link-layer .pdf-link {
  pointer-events: auto;
  background: transparent;
  transition: background-color 0.2s ease;
}

#pdf-link-layer .pdf-link:hover {
  background-color: var(--overlay-light);
  outline: 2px solid var(--border-orange);
  outline-offset: -2px;
}

/* Controls container - fixed at bottom */
#controls-container {
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-wrapper {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.page-counter-text {
  text-align: center;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 400;
  letter-spacing: 0.5px;
  width: 100%;
}

.nav-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  width: 100%;
}

/* Navigation buttons */
.nav-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: rgba(255, 140, 0, 0.1);
  border: 1px solid var(--border-orange);
  border-radius: var(--radius-md);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  backdrop-filter: blur(10px);
  min-width: 200px;
}

.nav-button:hover:not(:disabled) {
  background: rgba(255, 140, 0, 0.2);
  border-color: rgba(255, 140, 0, 0.4);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.nav-button:active:not(:disabled) {
  transform: translateY(0);
}

.nav-button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.nav-button .arrow {
  font-size: 1.2rem;
  font-weight: bold;
}

/* Old page counter styles (kept for backwards compatibility) */
.page-counter {
  /* Styles moved to .page-counter-text */
}

/* Voice Controls Inline Button */
.voice-button-inline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  background: rgba(255, 140, 0, 0.1);
  border: 2px solid var(--border-orange);
  border-radius: var(--radius-md);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 500;
  cursor: default;
  transition: var(--transition);
  backdrop-filter: blur(10px);
  opacity: 0.5;
  min-height: 44px;
  min-width: 230px;
  justify-content: center;
}

.sp-avatar-container {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border-orange);
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary-orange-light) 0%, var(--primary-orange-dark) 100%);
  transition: var(--transition);
}

.sp-avatar {
  width: 100%;
  height: 100%;
  background-image: url('../favicon-32x32.png');
  background-size: cover;
  background-position: center;
}

.voice-status-inline {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
}

/* Ready state */
.voice-button-inline.ready {
  border-color: rgba(255, 140, 0, 0.5);
  cursor: pointer;
  opacity: 1;
}

.voice-button-inline.ready .sp-avatar-container {
  border-color: rgba(255, 140, 0, 0.6);
}

.voice-button-inline.ready:hover {
  background: rgba(255, 140, 0, 0.2);
  border-color: rgba(255, 140, 0, 0.7);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.voice-button-inline.ready:hover .sp-avatar-container {
  border-color: var(--primary-orange-light);
}

/* Active state (listening) */
.voice-button-inline.active {
  background: rgba(255, 140, 0, 0.25);
  border-color: rgba(255, 140, 0, 0.8);
  animation: pulse-inline 2s infinite;
  cursor: pointer;
  opacity: 1;
}

.voice-button-inline.active .sp-avatar-container {
  border-color: var(--primary-orange-light);
  box-shadow: 0 0 15px rgba(255, 140, 0, 0.5);
}

.voice-button-inline.active:hover {
  background: rgba(239, 83, 80, 0.2);
  border-color: rgba(239, 83, 80, 0.8);
  animation: none;
  transform: translateY(-2px);
}

.voice-button-inline.active:hover .sp-avatar-container {
  border-color: rgba(239, 83, 80, 0.8);
  box-shadow: 0 0 15px rgba(239, 83, 80, 0.5);
}

/* Speaking state */
.voice-button-inline.speaking {
  background: rgba(255, 107, 53, 0.25);
  border-color: var(--primary-orange-dark);
  animation: glow-inline 1.5s ease-in-out infinite;
}

.voice-button-inline.speaking .sp-avatar-container {
  border-color: var(--primary-orange-dark);
  box-shadow: 0 0 20px rgba(255, 107, 53, 0.6);
}

/* Animations */
@keyframes pulse-inline {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 140, 0, 0.7);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(255, 140, 0, 0);
  }
}

@keyframes glow-inline {
  0%, 100% {
    box-shadow: 0 0 15px rgba(255, 107, 53, 0.5);
  }
  50% {
    box-shadow: 0 0 25px rgba(255, 107, 53, 0.8);
  }
}

/* Responsive design */
@media (max-width: 768px) {
  #pdf-container {
    padding: 1rem;
  }

  .nav-controls {
    gap: 0.75rem;
    flex-wrap: wrap;
  }

  .nav-button {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  .nav-button span:not(.arrow) {
    display: none;
  }

  .page-counter-text {
    font-size: 0.8rem;
  }

  .voice-button-inline {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  .sp-avatar-container {
    width: 32px;
    height: 32px;
  }

  .voice-status-inline {
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  #pdf-container {
    padding: 0.5rem;
  }

  .nav-controls {
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
  }

  .nav-button {
    padding: 0.5rem;
    min-width: 44px;
  }

  .page-counter-text {
    font-size: 0.75rem;
  }

  .voice-button-inline {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    min-width: auto;
  }

  .sp-avatar-container {
    width: 28px;
    height: 28px;
  }

  .voice-status-inline {
    font-size: 0.75rem;
  }
}

/* ========================================
   CHAT INTERFACE
   ======================================== */

/* Chat Panel */
.chat-panel {
  position: fixed;
  top: 0;
  right: -420px; /* Hidden by default */
  width: 420px;
  height: 100vh;
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--border-orange);
  display: flex;
  flex-direction: column;
  transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1100;
  box-shadow: -10px 0 40px rgba(255, 140, 0, 0.1);
}

.chat-panel.visible {
  right: 0;
}

/* Chat Header */
.chat-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-orange);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.chat-header h3 {
  margin: 0;
  color: #ffffff;
  font-size: 1.25rem;
  font-weight: 500;
}

.chat-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 2rem;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  line-height: 1;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-close:hover {
  color: var(--primary-orange-light);
}

/* Chat Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Custom scrollbar */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-orange);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 140, 0, 0.4);
}

/* Message Bubbles */
.message {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-width: 85%;
  animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  align-self: flex-end;
}

.message.agent {
  align-self: flex-start;
}

.message.system {
  align-self: center;
  max-width: 90%;
}

.message-content {
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  word-wrap: break-word;
  line-height: 1.5;
}

.message.user .message-content {
  background: rgba(255, 140, 0, 0.25);
  border: 1px solid rgba(255, 140, 0, 0.4);
  color: #ffffff;
  border-bottom-right-radius: 0.25rem;
}

.message.agent .message-content {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.95);
  border-bottom-left-radius: 0.25rem;
}

.message.system .message-content {
  background: rgba(255, 183, 77, 0.15);
  border: 1px solid rgba(255, 183, 77, 0.3);
  color: rgba(255, 183, 77, 0.95);
  font-size: 0.875rem;
  text-align: center;
}

.message-time {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
  padding: 0 0.5rem;
}

.message.user .message-time {
  text-align: right;
}

.message.agent .message-time {
  text-align: left;
}

.message.system .message-time {
  text-align: center;
}

/* Typing Indicator */
.typing-indicator {
  align-self: flex-start;
  max-width: 85%;
}

.typing-indicator .message-content {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  align-items: center;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-orange-light);
  animation: typingPulse 1.4s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingPulse {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  30% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Chat Input Form */
.chat-form {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-orange);
  display: flex;
  gap: 0.75rem;
  flex-shrink: 0;
  background: rgba(10, 10, 10, 0.5);
}

.chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-orange);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: #ffffff;
  font-size: 1rem;
  transition: var(--transition);
  font-family: var(--font-primary);
}

.chat-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.chat-input:focus {
  outline: none;
  border-color: rgba(255, 140, 0, 0.6);
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 3px rgba(255, 140, 0, 0.1);
}

.chat-send {
  background: rgba(255, 140, 0, 0.25);
  border: 1px solid rgba(255, 140, 0, 0.4);
  color: #ffffff;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
  font-size: 1rem;
  white-space: nowrap;
}

.chat-send:hover {
  background: rgba(255, 140, 0, 0.4);
  border-color: rgba(255, 140, 0, 0.6);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.chat-send:active {
  transform: translateY(0);
}

/* Chat Toggle Button */
.chat-toggle-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-orange-light) 0%, var(--primary-orange-dark) 100%);
  border: 2px solid rgba(255, 140, 0, 0.5);
  color: #ffffff;
  font-size: 1.75rem;
  cursor: pointer;
  transition: var(--transition);
  z-index: 1000;
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.chat-toggle-btn:hover {
  background: linear-gradient(135deg, var(--primary-orange-dark) 0%, var(--primary-orange-light) 100%);
  border-color: rgba(255, 140, 0, 0.7);
  transform: scale(1.1);
  box-shadow: var(--shadow-lg);
}

.chat-toggle-btn:active {
  transform: scale(1.05);
}

.chat-toggle-btn.active {
  background: linear-gradient(135deg, var(--primary-orange-dark) 0%, var(--primary-orange-light) 100%);
  border-color: var(--primary-orange-light);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .chat-panel {
    width: 100vw;
    right: -100vw;
  }

  .chat-panel.visible {
    right: 0;
  }

  .chat-toggle-btn {
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
  }

  .message {
    max-width: 90%;
  }
}

@media (max-width: 480px) {
  .chat-header {
    padding: 1rem;
  }

  .chat-messages {
    padding: 1rem;
  }

  .chat-form {
    padding: 0.75rem 1rem;
  }

  .chat-send {
    padding: 0.75rem 1rem;
  }

  .chat-toggle-btn {
    bottom: 1rem;
    right: 1rem;
    width: 52px;
    height: 52px;
  }
}

/* Loading state */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.6);
}

/* Error state */
.error {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  padding: 2rem;
  text-align: center;
}

.error h1 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: #ff6b6b;
}

.error p {
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 0.5rem;
}

/* Smooth transitions */
#pdf-canvas {
  transition: opacity 0.2s ease;
}

/* Focus styles for accessibility */
.nav-button:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

/* Print styles */
@media print {
  #controls-container,
  elevenlabs-convai,
  .hamburger-button,
  .slide-sidebar {
    display: none;
  }

  #pdf-container {
    padding: 0;
  }

  body {
    background: white;
  }
}

/* ========================================
   SLIDE SIDEBAR
   ======================================== */

/* Hamburger Button */
.hamburger-button {
  position: fixed;
  top: 1.5rem;
  left: 1.5rem;
  z-index: 1001;
  width: 44px;
  height: 44px;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.hamburger-button:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.hamburger-button:active {
  transform: translateY(0);
}

.hamburger-icon {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hamburger-icon span {
  display: block;
  width: 20px;
  height: 2px;
  background: #ffffff;
  border-radius: 2px;
  transition: all 0.3s ease;
}

/* Sidebar Overlay */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

/* Slide Sidebar */
.slide-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 320px;
  max-width: 85vw;
  height: 100vh;
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(20px);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

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

.sidebar-header {
  padding: 2rem 1.5rem 1rem 5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.sidebar-header h3 {
  font-size: 1.2rem;
  font-weight: 500;
  color: #ffffff;
  margin: 0;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Custom scrollbar */
.sidebar-content::-webkit-scrollbar {
  width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Slide List */
.slide-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.slide-item {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.slide-link {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  width: 100%;
  padding: 0.875rem 1.5rem;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  line-height: 1.4;
}

.slide-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.9);
}

.slide-number {
  flex-shrink: 0;
  display: inline-block;
  min-width: 2rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.4);
}

.slide-title {
  flex: 1;
}

/* Active slide highlight */
.slide-item.active .slide-link {
  background: var(--overlay-light);
  color: #ffffff;
  border-left: 3px solid var(--primary-orange-light);
  padding-left: calc(1.5rem - 3px);
}

.slide-item.active .slide-number {
  color: var(--primary-orange-light);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .hamburger-button {
    top: 1rem;
    left: 1rem;
    width: 40px;
    height: 40px;
  }

  .slide-sidebar {
    width: 280px;
  }

  .sidebar-header {
    padding: 1.5rem 1rem 0.75rem 4.5rem;
  }

  .sidebar-header h3 {
    font-size: 1.1rem;
  }

  .slide-link {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
  }

  .slide-number {
    min-width: 1.75rem;
  }
}

@media (max-width: 480px) {
  .slide-sidebar {
    width: 260px;
  }
}
