/* ===================================================================
   YouTube AI Studio — Reusable UI Components
   Glassmorphic cards, buttons, badges, and composed elements
   =================================================================== */

/* ===================== GLASS CARDS ===================== */

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-2xl);
  padding: var(--space-lg);
  box-shadow: var(--shadow-glass);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.glass-card:hover {
  border-color: var(--glass-border-strong);
}

.glass-card--subtle {
  background: var(--glass-bg-subtle);
  border-color: var(--glass-border-subtle);
  box-shadow: none;
}

.glass-card--strong {
  background: var(--glass-bg-strong);
  border-color: var(--glass-border-strong);
  box-shadow: var(--shadow-elevated);
}

.glass-card--interactive {
  cursor: pointer;
  transition: transform var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base);
}

.glass-card--interactive:hover {
  transform: translateY(-2px);
  border-color: var(--glass-border-strong);
  box-shadow: var(--shadow-elevated);
}

/* Card with accent glow */
.glass-card--glow-indigo {
  box-shadow: var(--shadow-glass), var(--shadow-glow-indigo);
}

.glass-card--glow-cyan {
  box-shadow: var(--shadow-glass), var(--shadow-glow-cyan);
}

/* ===================== GRADIENT BUTTONS ===================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 12px 24px;
  font-family: var(--font-family);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--accent-indigo);
  outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-violet));
  color: var(--text-primary);
  box-shadow: 0 4px 16px rgba(129, 140, 248, 0.25);
}

.btn-primary:hover {
  box-shadow: 0 6px 24px rgba(129, 140, 248, 0.35);
  transform: translateY(-1px);
  color: var(--text-primary);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--glass-bg);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
}

.btn-secondary:hover {
  background: var(--glass-bg-strong);
  border-color: var(--glass-border-strong);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 8px 16px;
}

.btn-ghost:hover {
  background: var(--glass-bg-subtle);
  color: var(--text-primary);
}

.btn-danger {
  background: linear-gradient(135deg, var(--accent-rose), #e11d48);
  color: var(--text-primary);
  box-shadow: 0 4px 16px rgba(251, 113, 133, 0.2);
}

.btn-danger:hover {
  box-shadow: 0 6px 24px rgba(251, 113, 133, 0.3);
  transform: translateY(-1px);
}

.btn-lg {
  padding: 16px 32px;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.8125rem;
}

.btn-block {
  width: 100%;
}

/* ===================== STATUS BADGE ===================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-emerald);
  flex-shrink: 0;
}

.badge-dot--indigo { background: var(--accent-indigo); }
.badge-dot--cyan { background: var(--accent-cyan); }
.badge-dot--rose { background: var(--accent-rose); }
.badge-dot--amber { background: var(--accent-amber); }

/* ===================== SECTION HEADER ===================== */

.section {
  margin-bottom: var(--space-2xl);
}

.section-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.section-header__accent {
  width: 4px;
  height: 22px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent-indigo), var(--accent-cyan));
  flex-shrink: 0;
}

.section-header__title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ===================== KPI / METRIC CARDS ===================== */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.kpi-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  transition: border-color var(--transition-base);
}

.kpi-card:hover {
  border-color: var(--glass-border-strong);
}

.kpi-card__label {
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: var(--space-sm);
}

.kpi-card__value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.kpi-card__note {
  font-size: 0.6875rem;
  color: var(--text-dim);
  margin-top: 6px;
}

/* ===================== DATA TABLES ===================== */

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--glass-border-subtle);
}

.data-table th {
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.data-table td {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

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

.data-table tr:hover td {
  background: var(--glass-bg-subtle);
}

/* ===================== INSIGHT BOX ===================== */

.insight-box {
  background: var(--glass-bg-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-top: var(--space-md);
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-secondary);
  border-left: 3px solid var(--accent-indigo);
}

.insight-box strong {
  color: var(--accent-emerald);
}

/* ===================== CHART CONTAINER ===================== */

.chart-container {
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--glass-bg-subtle);
}

.chart-container img {
  width: 100%;
  height: auto;
  display: block;
}

/* ===================== FORM ELEMENTS ===================== */

.form-input {
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.9375rem;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  outline: none;
}

.form-input::placeholder {
  color: var(--text-dim);
}

.form-input:focus {
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.15);
}

/* ===================== LOADING STATE ===================== */

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--glass-border);
  border-top-color: var(--accent-indigo);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-indigo);
  animation: pulse-subtle 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ===================== PROGRESS BAR ===================== */

.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--glass-bg-strong);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-indigo), var(--accent-cyan));
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===================== STATUS TIMELINE ===================== */

.status-timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.status-step {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--text-dim);
  transition: all var(--transition-base);
}

.status-step--active {
  color: var(--text-primary);
  background: var(--glass-bg-subtle);
}

.status-step--complete {
  color: var(--accent-emerald);
}

.status-step__icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ===================== ERROR STATE ===================== */

.error-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: rgba(251, 113, 133, 0.1);
  border: 1px solid rgba(251, 113, 133, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-lg);
}

.error-icon svg {
  width: 28px;
  height: 28px;
  color: var(--accent-rose);
}

/* ===================== REPORT-SPECIFIC ===================== */

.report-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
}

.report-header__avatar {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--glass-border);
  object-fit: cover;
  background: var(--glass-bg);
  flex-shrink: 0;
}

.report-header__avatar-frame {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-lg);
  flex: 0 0 72px;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.12), transparent 34%),
    rgba(255, 59, 48, 0.12);
}

.report-header__avatar-frame .report-header__avatar {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

.report-header__avatar-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--glass-border);
  border-radius: inherit;
  color: var(--text-primary);
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: 0;
}

.report-header__avatar-frame:not(.report-header__avatar-frame--fallback) .report-header__avatar-fallback {
  display: none;
}

.report-header__avatar-frame--fallback .report-header__avatar {
  display: none;
}

.report-header__content {
  flex: 1;
  min-width: 250px;
}

.report-header__title {
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 700;
  margin-bottom: 4px;
}

.report-header__meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.report-header__meta a {
  color: var(--accent-blue);
}

.report-summary {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  background: var(--glass-bg-subtle);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border-left: 3px solid var(--accent-emerald);
  line-height: 1.7;
}

/* Duration bins */
.duration-bins {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}

.duration-bin {
  background: var(--glass-bg-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  text-align: center;
  min-width: 100px;
}

.duration-bin__label { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 4px; }
.duration-bin__value { font-size: 1.125rem; font-weight: 600; }
.duration-bin__count { font-size: 0.6875rem; color: var(--text-dim); }

/* Lift indicators */
.lift-positive { color: var(--positive); }
.lift-negative { color: var(--negative); }

/* LLM Summary */
.llm-summary h3 { font-size: 0.9375rem; font-weight: 600; margin-top: var(--space-md); }
.llm-summary p { margin: 6px 0; color: var(--text-secondary); font-size: 0.875rem; }
.llm-summary ul { color: var(--text-secondary); font-size: 0.875rem; padding-left: var(--space-lg); }
.llm-summary li { margin: 4px 0; }
.llm-summary strong { color: var(--text-primary); }

/* Info box */
.info-box {
  padding: 12px 18px;
  background: var(--glass-bg);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--accent-amber);
  font-size: 0.8125rem;
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
}

.info-box__label {
  color: var(--accent-amber);
  font-weight: 600;
  white-space: nowrap;
}

.info-box__text {
  color: var(--text-muted);
}

/* Placeholder section */
.placeholder-section {
  background: var(--glass-bg);
  border: 1px dashed var(--glass-border-strong);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  text-align: center;
}

.placeholder-section h3 { margin-bottom: var(--space-sm); }
.placeholder-section p { color: var(--text-muted); font-size: 0.875rem; }

/* Card title */
.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
}

/* Footer */
.report-footer {
  margin-top: var(--space-3xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--glass-border-subtle);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.report-footer__links a {
  color: var(--text-dim);
  text-decoration: none;
  margin: 0 4px;
}

.report-footer__links a:hover {
  color: var(--text-primary, #fff);
}

.report-footer__sep {
  opacity: 0.4;
}

.report-disclaimer {
  margin-top: var(--space-lg);
  padding: var(--space-md);
  background: var(--glass-bg);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.6;
}

.report-disclaimer strong {
  color: var(--text-muted);
}

/* ===================== PREMIUM BACKGROUND ===================== */

.premium-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.premium-bg__gradient {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(129, 140, 248, 0.06), transparent),
              radial-gradient(ellipse 60% 40% at 80% 100%, rgba(251, 113, 133, 0.04), transparent);
}

.premium-bg__noise {
  position: absolute;
  inset: 0;
  opacity: 0.015;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 200px 200px;
}

/* ===================== GEOMETRIC SHAPES ===================== */

.geometric-shapes {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.geometric-shape {
  position: absolute;
  border-radius: 50%;
  backdrop-filter: blur(2px);
  border: 2px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 32px rgba(255, 255, 255, 0.06);
  opacity: 0;
  animation: shapeEntry 2.4s cubic-bezier(0.23, 0.86, 0.39, 0.96) forwards;
}

.geometric-shape::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.15), transparent 70%);
}

.geometric-shape--float {
  animation: shapeEntry 2.4s cubic-bezier(0.23, 0.86, 0.39, 0.96) forwards,
             float 12s ease-in-out infinite;
  animation-delay: var(--shape-delay, 0s), calc(var(--shape-delay, 0s) + 2.4s);
}

@keyframes shapeEntry {
  from {
    opacity: 0;
    transform: translateY(-80px) rotate(calc(var(--shape-rotate, 0deg) - 15deg));
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(var(--shape-rotate, 0deg));
  }
}

/* Individual shape positioning & colors */
.shape-1 {
  --shape-delay: 0.3s;
  --shape-rotate: 12deg;
  width: min(500px, 60vw);
  height: min(120px, 15vw);
  left: -5%;
  top: 20%;
  background: linear-gradient(to right, rgba(129, 140, 248, 0.12), transparent);
  animation-delay: 0.3s, 2.7s;
}

.shape-2 {
  --shape-delay: 0.5s;
  --shape-rotate: -15deg;
  width: min(420px, 50vw);
  height: min(100px, 12vw);
  right: 0%;
  top: 75%;
  background: linear-gradient(to right, rgba(251, 113, 133, 0.12), transparent);
  animation-delay: 0.5s, 2.9s;
}

.shape-3 {
  --shape-delay: 0.4s;
  --shape-rotate: -8deg;
  width: min(260px, 35vw);
  height: min(70px, 9vw);
  left: 10%;
  bottom: 10%;
  background: linear-gradient(to right, rgba(167, 139, 250, 0.12), transparent);
  animation-delay: 0.4s, 2.8s;
}

.shape-4 {
  --shape-delay: 0.6s;
  --shape-rotate: 20deg;
  width: min(180px, 22vw);
  height: min(50px, 6vw);
  right: 20%;
  top: 15%;
  background: linear-gradient(to right, rgba(251, 191, 36, 0.1), transparent);
  animation-delay: 0.6s, 3.0s;
}

.shape-5 {
  --shape-delay: 0.7s;
  --shape-rotate: -25deg;
  width: min(130px, 18vw);
  height: min(35px, 5vw);
  left: 25%;
  top: 10%;
  background: linear-gradient(to right, rgba(34, 211, 238, 0.1), transparent);
  animation-delay: 0.7s, 3.1s;
}

/* ===================== RESPONSIVE ===================== */

@media (max-width: 768px) {
  .glass-card {
    padding: var(--space-md);
  }
  
  .report-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .report-footer {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .section-header {
    flex-wrap: wrap;
  }

  .btn-lg {
    padding: 14px 24px;
    font-size: 0.9375rem;
  }

  .geometric-shape {
    display: none;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .kpi-card__value {
    font-size: 1.5rem;
  }
}
