/* ================================================================
   Rayumi Content Scraper — Premium Dark UI
   ================================================================ */

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

[hidden] {
  display: none !important;
}

:root {
  --bg: #050507;
  --surface: rgba(255, 255, 255, 0.03);
  --surface-hover: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --text: #f0f0f3;
  --text-secondary: #8b8b9e;
  --text-muted: #55556a;
  --accent: #f97316;
  --accent-dim: rgba(249, 115, 22, 0.12);
  --accent-glow: rgba(249, 115, 22, 0.25);
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.1);
  --green-glow: rgba(52, 211, 153, 0.2);
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.08);
  --purple: #a78bfa;
  --purple-dim: rgba(167, 139, 250, 0.12);
  --blue: #60a5fa;
  --blue-dim: rgba(96, 165, 250, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.4), 0 8px 32px rgba(0,0,0,0.3);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.5rem 1rem;
  overflow-x: hidden;
  position: relative;
}

/* --- Animated background --- */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 64px 64px;
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
  animation: drift 20s ease-in-out infinite;
}

.bg-glow-1 {
  background: #f97316;
  top: -150px;
  right: -100px;
}

.bg-glow-2 {
  background: #ef4444;
  bottom: -200px;
  left: -150px;
  animation-delay: -10s;
}

@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.05); }
  66% { transform: translate(-20px, 15px) scale(0.95); }
}

/* --- Layout --- */
.container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* --- Top Bar --- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.25rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-dim), rgba(239, 68, 68, 0.15));
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.brand-name {
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: -0.02em;
  color: var(--text-secondary);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3rem 0.65rem;
  border-radius: 100px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
}

.nav-link:hover {
  border-color: var(--border-hover);
  color: var(--text-secondary);
  background: var(--surface-hover);
}

.auth-pill {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3rem 0.65rem;
  border-radius: 100px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--text-muted);
}

.auth-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}

.auth-dot.connected {
  background: var(--green);
  box-shadow: 0 0 8px var(--green-glow);
}

.auth-dot.disconnected {
  background: var(--red);
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.3);
}

/* --- Main Card --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  overflow: hidden;
}

.card-inner {
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* --- Hero --- */
.hero {
  text-align: center;
  padding-bottom: 0.25rem;
}

.hero-icon-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 0.875rem;
}

.hero-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-dim), rgba(239, 68, 68, 0.18));
  border: 1px solid rgba(249, 115, 22, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: float 4s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.hero-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.3rem;
}

.hero-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* --- Section --- */
.section {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.section-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 100px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: var(--transition);
}

.section-badge.ok {
  color: var(--green);
  background: var(--green-dim);
  border-color: rgba(52, 211, 153, 0.15);
}

.section-badge.err {
  color: var(--red);
  background: var(--red-dim);
  border-color: rgba(248, 113, 113, 0.15);
}

/* --- Platform Tabs --- */
.platform-tabs {
  display: flex;
  gap: 0.375rem;
}

.platform-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 0.5rem;
  border-radius: var(--radius-xs);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
}

.platform-tab:hover {
  border-color: var(--border-hover);
  color: var(--text-secondary);
  background: var(--surface-hover);
}

.platform-tab.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.1);
}

/* --- Auth Panels --- */
.auth-panel {
  display: none;
  flex-direction: column;
  gap: 0.625rem;
  animation: fadeIn 0.2s ease;
}

.auth-panel.active {
  display: flex;
}

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

.auth-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--green);
  padding: 0.5rem 0.75rem;
  background: var(--green-dim);
  border: 1px solid rgba(52, 211, 153, 0.12);
  border-radius: var(--radius-xs);
}

.auth-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

/* --- Input Fields --- */
.input-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input-label-sm {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-muted);
}

.input-field {
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-xs);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.8rem;
  font-family: var(--font);
  transition: var(--transition);
  width: 100%;
}

.input-field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.input-field::placeholder {
  color: var(--text-muted);
}

.input-textarea {
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-xs);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.72rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  transition: var(--transition);
  width: 100%;
  resize: vertical;
  min-height: 60px;
}

.input-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.input-textarea::placeholder {
  color: var(--text-muted);
  font-family: var(--font);
}

.input-hint {
  font-size: 0.62rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.input-select {
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-xs);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.72rem;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
}

.input-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* --- Search Row --- */
.search-row {
  display: flex;
  gap: 0.5rem;
}

.search-input {
  flex: 1;
}

.search-options {
  display: flex;
  gap: 0.75rem;
}

.option-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
  transition: opacity var(--transition);
}

.btn:hover::after {
  opacity: 1;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

.btn:disabled::after {
  display: none;
}

.btn-search {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: var(--radius-xs);
  background: linear-gradient(135deg, var(--accent), #ef4444);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-search:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-action {
  width: 100%;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  background: linear-gradient(135deg, var(--accent), #ef4444);
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
  margin-top: 0.5rem;
}

.btn-action:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px var(--accent-glow);
}

.btn-mark {
  flex: 1;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-xs);
  font-size: 0.72rem;
  background: var(--blue-dim);
  border: 1px solid rgba(96, 165, 250, 0.2);
  color: var(--blue);
}

.btn-mark:hover {
  background: rgba(96, 165, 250, 0.2);
}

.btn-trim-confirm {
  flex: 1;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-xs);
  font-size: 0.72rem;
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25);
}

.btn-trim-confirm:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(5, 150, 105, 0.4);
}

.btn-text-small {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-family: var(--font);
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  transition: var(--transition);
}

.btn-text-small:hover {
  color: var(--red);
  background: var(--red-dim);
}

/* --- Results Grid --- */
.results-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 420px;
  overflow-y: auto;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: var(--transition);
  cursor: pointer;
}

.result-item:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.result-item.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.result-thumb {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-xs);
  background: var(--bg);
  object-fit: cover;
  flex-shrink: 0;
}

.result-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.result-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-meta {
  font-size: 0.65rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.result-views {
  color: var(--accent);
  font-weight: 600;
}

.result-duration {
  color: var(--purple);
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex-shrink: 0;
}

.btn-preview {
  padding: 0.35rem 0.6rem;
  border-radius: 5px;
  font-size: 0.62rem;
  font-weight: 600;
  background: var(--purple-dim);
  border: 1px solid rgba(167, 139, 250, 0.2);
  color: var(--purple);
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
}

.btn-preview:hover {
  background: rgba(167, 139, 250, 0.2);
}

.btn-quick-upload {
  padding: 0.35rem 0.6rem;
  border-radius: 5px;
  font-size: 0.62rem;
  font-weight: 600;
  background: var(--green-dim);
  border: 1px solid rgba(52, 211, 153, 0.2);
  color: var(--green);
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
}

.btn-quick-upload:hover {
  background: rgba(52, 211, 153, 0.2);
}

/* --- Trim Panel --- */
.trim-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.trim-video {
  width: 100%;
  max-height: 300px;
  border-radius: var(--radius-sm);
  background: #000;
  border: 1px solid var(--border);
}

.trim-controls {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.trim-time-display {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
}

.trim-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.trim-label.dim {
  color: var(--text-muted);
}

.trim-time {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.trim-slider {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.trim-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 2px 8px var(--accent-glow);
  cursor: grab;
}

.trim-slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.2);
}

.trim-actions {
  display: flex;
  gap: 0.5rem;
}

/* --- Processing List --- */
.processing-list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.processing-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-xs);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.processing-item .spinner-ring-small {
  flex-shrink: 0;
}

.processing-item.done {
  border-color: rgba(52, 211, 153, 0.12);
  background: var(--green-dim);
  color: var(--green);
}

.processing-item.failed {
  border-color: rgba(248, 113, 113, 0.12);
  background: var(--red-dim);
  color: var(--red);
}

/* --- Completed List --- */
.completed-list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.completed-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-xs);
  background: var(--green-dim);
  border: 1px solid rgba(52, 211, 153, 0.12);
}

.completed-item-name {
  font-size: 0.7rem;
  color: var(--green);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
}

.completed-item-link {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--green);
  text-decoration: none;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  transition: var(--transition);
}

.completed-item-link:hover {
  background: rgba(52, 211, 153, 0.15);
}

/* --- Error --- */
.error-card {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--red-dim);
  border: 1px solid rgba(248, 113, 113, 0.12);
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

.error-icon {
  color: var(--red);
  flex-shrink: 0;
  margin-top: 1px;
}

.error-msg {
  font-size: 0.78rem;
  color: #fca5a5;
  line-height: 1.5;
}

/* --- Spinner --- */
.spinner-ring-small {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(249, 115, 22, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Footer --- */
.footer {
  text-align: center;
  font-size: 0.62rem;
  color: var(--text-muted);
  opacity: 0.5;
  padding-top: 0.25rem;
}

/* --- Focus visible --- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::selection {
  background: var(--accent-dim);
  color: var(--accent);
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* --- Responsive --- */
@media (min-width: 768px) {
  .container {
    max-width: 660px;
  }

  .card-inner {
    padding: 2rem;
  }
}

@media (max-width: 480px) {
  body {
    padding: 0.75rem;
  }

  .card-inner {
    padding: 1.25rem;
  }

  .hero-title {
    font-size: 1.15rem;
  }

  .platform-tabs {
    flex-direction: column;
  }

  .search-options {
    flex-direction: column;
    gap: 0.5rem;
  }

  .trim-actions {
    flex-direction: column;
  }

  .result-thumb {
    width: 48px;
    height: 48px;
  }
}
