/* --- CHAT COMPONENT --- */
.chat-wrapper {
  display: flex;
  flex-direction: column;
  height: 680px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.chat-header {
  padding: 1rem 1.25rem;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.bot-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-purple), var(--plex-amber));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.3);
}

.chat-status-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-green);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px var(--accent-green);
}

.chat-messages {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

/* Chat Bubbles */
.chat-bubble {
  max-width: 82%;
  padding: 1rem 1.2rem;
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  line-height: 1.6;
  position: relative;
  word-break: break-word;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-bottom-left-radius: 4px;
  color: var(--text-main);
}

.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.25);
}

.chat-bubble p {
  margin-bottom: 0.5rem;
}
.chat-bubble p:last-child {
  margin-bottom: 0;
}
.chat-bubble ul, .chat-bubble ol {
  margin-left: 1.25rem;
  margin-bottom: 0.5rem;
}
.chat-bubble code {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85em;
}

/* Action Cards inside chat */
.action-card {
  margin-top: 0.75rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.action-card-icon {
  font-size: 1.5rem;
}

.action-card-text h4 {
  font-size: 0.85rem;
  color: var(--plex-amber);
  margin-bottom: 0.15rem;
}

.action-card-text p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Prompt Chips */
.chat-prompts-container {
  padding: 0.75rem 1.25rem;
  background: rgba(17, 21, 31, 0.5);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  white-space: nowrap;
}

.prompt-chip {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.prompt-chip:hover {
  background: rgba(229, 160, 13, 0.15);
  border-color: rgba(229, 160, 13, 0.4);
  color: var(--plex-amber);
  transform: translateY(-1px);
}

/* Image preview before sending */
.chat-image-preview-container {
  display: none;
  padding: 0.5rem 1.25rem;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  align-items: center;
  gap: 0.75rem;
}

.chat-image-preview-wrapper {
  position: relative;
  display: inline-block;
}

.chat-image-preview-thumb {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border-focus);
}

.btn-remove-image {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-red);
  color: #fff;
  border: none;
  font-size: 0.75rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Chat Input Bar */
.chat-input-bar {
  padding: 1rem 1.25rem;
  background: var(--bg-surface-elevated);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-attach-img {
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-attach-img:hover {
  background: rgba(229, 160, 13, 0.15);
  border-color: var(--plex-amber);
  color: var(--plex-amber);
  transform: translateY(-1px);
}

.chat-input-bar input {
  flex: 1;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.8rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Image inside chat bubble */
.chat-bubble-image {
  max-width: 260px;
  max-height: 220px;
  border-radius: var(--radius-md);
  margin-bottom: 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  display: block;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.chat-bubble-image:hover {
  transform: scale(1.02);
}

.chat-input-bar input:focus {
  border-color: var(--plex-amber);
  box-shadow: 0 0 10px var(--plex-amber-glow);
}

/* Typing Indicator */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.75rem 1rem;
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  align-self: flex-start;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--plex-amber);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* --- STREAM DOCTOR COMPONENT --- */
.stream-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}

.stream-card {
  background: var(--bg-glass-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: all 0.2s ease;
}

.stream-card.highlight {
  border-color: var(--plex-amber);
  box-shadow: 0 0 20px var(--plex-amber-glow);
}

.stream-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.stream-user-tag {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.stream-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}

.stream-specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.stream-spec-item span:first-child {
  color: var(--text-dim);
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
}

.stream-warning-box {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  font-size: 0.8rem;
  color: #fca5a5;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.stream-info-box {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  font-size: 0.8rem;
  color: #fde68a;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

/* --- MEDIA SEARCH COMPONENT --- */
.search-bar-container {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.search-input {
  flex: 1;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 1rem;
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--plex-amber);
  box-shadow: 0 0 15px var(--plex-amber-glow);
}

.media-results-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.media-item-card {
  background: var(--bg-glass-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  gap: 1.25rem;
  align-items: center;
  transition: border-color 0.2s ease;
}

.media-item-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.media-thumb {
  width: 70px;
  height: 105px;
  border-radius: 8px;
  background: #1e2638;
  object-fit: cover;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--text-dim);
}

.media-details {
  flex: 1;
  min-width: 0;
}

.media-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.media-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}

.media-year {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.media-badges {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.media-audio-row {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.media-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* --- CLIENT GUIDES --- */
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.guide-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.guide-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.guide-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg-surface-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  border: 1px solid var(--border-subtle);
}

.guide-steps {
  list-style: none;
  counter-reset: guide-counter;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.guide-steps li {
  counter-increment: guide-counter;
  font-size: 0.88rem;
  color: var(--text-muted);
  position: relative;
  padding-left: 1.8rem;
  line-height: 1.4;
}

.guide-steps li strong {
  color: var(--text-main);
}

.guide-steps li::before {
  content: counter(guide-counter);
  position: absolute;
  left: 0;
  top: 0;
  width: 20px;
  height: 20px;
  background: rgba(229, 160, 13, 0.15);
  color: var(--plex-amber);
  border: 1px solid rgba(229, 160, 13, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
}

/* --- LOGIN PAGE --- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-glass-card);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--plex-amber), #f57c00);
  border-radius: 18px;
  margin: 0 auto 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  box-shadow: 0 0 25px var(--plex-amber-glow);
}

.login-card h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.login-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.btn-plex-oauth {
  width: 100%;
  padding: 0.95rem;
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--plex-amber), #f57c00);
  color: #000;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  box-shadow: 0 6px 20px var(--plex-amber-glow);
  transition: all 0.25s ease;
}

.btn-plex-oauth:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(229, 160, 13, 0.45);
}

.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.75rem 0;
  color: var(--text-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.direct-login-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  text-align: left;
}

.form-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  display: block;
}

.form-group input {
  width: 100%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  outline: none;
  font-size: 0.9rem;
  transition: border-color 0.2s ease;
}

.form-group input:focus {
  border-color: var(--plex-amber);
}

.error-message {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 0.65rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}
