/**
 * Study Buddy — PDF & YouTube doubt solver.
 * Hero, source cards (PDF | YouTube), and chat context banner.
 * Matches AI Companion / elite aesthetics.
 */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ----- Header (same pattern as ai-companion) ----- */
.study-buddy-header .header-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 8px 6px;
  margin: 0 -4px;
  border-radius: var(--app-radius-md);
  color: var(--app-text);
  font-size: var(--app-text-sm);
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.study-buddy-header .header-back-link:hover {
  background: var(--app-primary-soft);
  color: var(--app-primary);
}
.study-buddy-header .header-back-link svg {
  width: 20px;
  height: 20px;
}

/* ----- Main content ----- */
.study-buddy-main .page-content {
  padding-bottom: var(--app-space-xl);
}

/* ----- Hero ----- */
.study-buddy-hero {
  text-align: center;
  padding: var(--app-space-xl) var(--app-space);
  margin-bottom: var(--app-space-lg);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12) 0%, rgba(34, 197, 94, 0.08) 50%, rgba(99, 102, 241, 0.04) 100%);
  border-radius: var(--app-radius-lg);
  border: 1px solid rgba(99, 102, 241, 0.16);
}
.study-buddy-hero-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: var(--app-radius-lg);
  background: var(--app-primary-soft);
  border: 1px solid rgba(99, 102, 241, 0.22);
  margin-bottom: var(--app-space-md);
  color: var(--app-primary);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.12);
  overflow: hidden;
}
.study-buddy-hero-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.study-buddy-hero-title {
  font-size: var(--app-text-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--app-text);
  margin: 0 0 var(--app-space-sm);
  line-height: 1.25;
}
.study-buddy-hero-desc {
  font-size: var(--app-text-base);
  color: var(--app-text-secondary);
  line-height: 1.55;
  margin: 0 auto var(--app-space-md);
  max-width: 40ch;
}
.study-buddy-hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--app-space-sm);
  justify-content: center;
}
.study-buddy-badge {
  font-size: var(--app-text-xs);
  font-weight: 600;
  color: var(--app-primary);
  background: rgba(99, 102, 241, 0.1);
  padding: 6px 12px;
  border-radius: var(--app-radius-md);
  border: 1px solid rgba(99, 102, 241, 0.18);
}

/* ----- Choose label ----- */
.study-buddy-choose-label {
  font-size: var(--app-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--app-text-muted);
  margin: 0 0 var(--app-space-md);
}

/* ----- Source cards (PDF | YouTube) ----- */
.study-buddy-sources {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--app-space-lg);
  margin-bottom: var(--app-space-xl);
}
@media (min-width: 560px) {
  .study-buddy-sources {
    grid-template-columns: repeat(2, 1fr);
  }
}

.study-buddy-source-card {
  background: var(--app-surface);
  border: 2px solid var(--app-border-soft);
  border-radius: var(--app-radius-lg);
  padding: var(--app-space-lg);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  position: relative;
}
.study-buddy-source-card:hover {
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.08);
}
.study-buddy-source-card.selected {
  border-color: var(--app-primary);
  background: rgba(99, 102, 241, 0.04);
  box-shadow: 0 0 0 1px var(--app-primary);
}
.study-buddy-source-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--app-radius-md);
  margin-bottom: var(--app-space-md);
}
.study-buddy-source-icon-pdf {
  background: rgba(99, 102, 241, 0.12);
  color: var(--app-primary);
}
.study-buddy-source-icon-yt {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}
.study-buddy-source-title {
  font-size: var(--app-text-base);
  font-weight: 700;
  color: var(--app-text);
  margin: 0 0 var(--app-space-sm);
  line-height: 1.3;
}
.study-buddy-source-desc {
  font-size: var(--app-text-sm);
  color: var(--app-text-secondary);
  line-height: 1.5;
  margin: 0 0 var(--app-space-md);
}
.study-buddy-source-input-wrap {
  margin-top: var(--app-space-sm);
}
.study-buddy-file-input {
  width: 100%;
  font-size: var(--app-text-sm);
  padding: 8px 0;
  color: var(--app-text-secondary);
}
.study-buddy-file-input::file-selector-button {
  padding: 8px 14px;
  margin-right: 12px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-md);
  background: var(--app-bg);
  color: var(--app-primary);
  font-weight: 600;
  cursor: pointer;
}
.study-buddy-url-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-md);
  font-size: var(--app-text-sm);
  background: var(--app-bg);
  color: var(--app-text);
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.study-buddy-url-input:focus {
  outline: none;
  border-color: var(--app-primary);
  box-shadow: 0 0 0 2px var(--app-primary-soft);
}
.study-buddy-url-input::placeholder {
  color: var(--app-text-muted);
}
.study-buddy-source-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--app-text-muted);
  margin-top: 6px;
}
.study-buddy-source-filename {
  display: block;
  font-size: var(--app-text-xs);
  color: var(--app-primary);
  margin-top: 8px;
  font-weight: 500;
}

/* ----- CTA ----- */
.study-buddy-cta {
  display: block;
  text-align: center;
  margin-bottom: var(--app-space-sm);
}
.study-buddy-cta-hint {
  font-size: var(--app-text-sm);
  color: var(--app-text-muted);
  margin: 0 0 var(--app-space-lg);
  text-align: center;
}
.study-buddy-extracting {
  font-size: var(--app-text-sm);
  color: var(--app-primary);
  margin: 0 0 var(--app-space);
  text-align: center;
  font-weight: 500;
}

/* ----- Chat page: context banner ----- */
.study-buddy-chat-page .study-buddy-context {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: var(--app-space-sm);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(34, 197, 94, 0.05) 100%);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: var(--app-radius-md);
  font-size: var(--app-text-sm);
}
.study-buddy-context-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}
.study-buddy-context-label {
  font-weight: 600;
  color: var(--app-text-secondary);
  flex-shrink: 0;
}
.study-buddy-context-value {
  color: var(--app-text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.study-buddy-chat-card {
  flex: 1;
  min-height: 0;
}
.study-buddy-chat-page .msg-bot {
  white-space: pre-wrap;
}

/* API key (optional) */
.study-buddy-api-wrap {
  margin-top: var(--app-space-md);
  padding-top: var(--app-space-md);
  border-top: 1px solid var(--app-border-soft);
}
.study-buddy-api-toggle {
  background: none;
  border: none;
  font-size: var(--app-text-xs);
  color: var(--app-primary);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  -webkit-tap-highlight-color: transparent;
}
.study-buddy-api-toggle:hover { color: var(--app-primary-dark, #4338ca); }
.study-buddy-api-inner {
  display: flex;
  gap: var(--app-space-sm);
  margin-top: var(--app-space-sm);
  align-items: center;
}
.study-buddy-api-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-md);
  font-size: var(--app-text-sm);
  background: var(--app-surface);
  color: var(--app-text);
}
.study-buddy-api-input:focus {
  outline: none;
  border-color: var(--app-primary);
}
.study-buddy-api-save {
  padding: 10px 16px;
  font-size: var(--app-text-sm);
  font-weight: 600;
  color: var(--app-primary);
  background: var(--app-primary-soft);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--app-radius-md);
  cursor: pointer;
}
.study-buddy-api-save:hover { background: rgba(99, 102, 241, 0.2); }
