@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ========== CSS Variables ========== */
:root {
  --bg-primary: #0f0f13;
  --bg-secondary: #16161d;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --bg-input: rgba(255, 255, 255, 0.06);
  --bg-input-focus: rgba(255, 255, 255, 0.09);

  --text-primary: #e8e8ed;
  --text-secondary: #9898a6;
  --text-muted: #5c5c6e;

  --accent-start: #ff4e50;
  --accent-end: #8b5cf6;
  --accent-mid: #c044e0;
  --accent-glow: rgba(192, 68, 224, 0.15);

  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(139, 92, 246, 0.5);

  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 40px var(--accent-glow);

  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ========== Background Effect ========== */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(ellipse 600px 400px at 20% 20%, rgba(139,92,246,0.08), transparent),
    radial-gradient(ellipse 500px 350px at 80% 80%, rgba(255,78,80,0.06), transparent),
    radial-gradient(ellipse 400px 300px at 50% 50%, rgba(192,68,224,0.04), transparent);
  z-index: 0;
  pointer-events: none;
  animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
  0%   { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(-2%, -1%) rotate(1deg); }
}

/* ========== Layout ========== */
.app-wrapper {
  position: relative;
  z-index: 1;
  max-width: 840px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

/* ========== Header ========== */
.app-header {
  text-align: center;
  margin-bottom: 40px;
}

.app-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.app-logo svg {
  width: 40px;
  height: 40px;
}

.app-logo h1 {
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.app-tagline {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 400;
}

/* ========== Input Section ========== */
.input-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 28px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
  transition: border-color var(--transition-base);
}

.input-section:focus-within {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}

.input-group {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.input-field {
  flex: 1;
  position: relative;
}

.input-field input {
  width: 100%;
  padding: 14px 16px 14px 48px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: all var(--transition-base);
}

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

.input-field input:focus {
  background: var(--bg-input-focus);
  border-color: var(--border-focus);
}

.input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  transition: color var(--transition-base);
}

.input-field input:focus ~ .input-icon {
  color: var(--accent-mid);
}

.btn-generate {
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

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

.btn-generate:hover::before {
  opacity: 1;
}

.btn-generate:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(192, 68, 224, 0.35);
}

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

.btn-generate:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-generate:disabled::before {
  display: none;
}

/* ========== Video Info ========== */
.video-info {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin-bottom: 24px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: slideUp 0.4s var(--transition-slow);
}

.video-info.visible {
  display: block;
}

.video-info-inner {
  display: flex;
  gap: 20px;
  padding: 20px;
  align-items: center;
}

.video-thumbnail {
  width: 180px;
  min-width: 180px;
  aspect-ratio: 16/9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-secondary);
}

.video-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.video-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.language-select-group {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.language-select-group label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.language-select {
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-base);
}

.language-select:focus {
  border-color: var(--border-focus);
}

.language-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.btn-get-transcript {
  padding: 8px 18px;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
}

.btn-get-transcript:hover {
  box-shadow: 0 2px 12px rgba(192, 68, 224, 0.3);
}

.btn-get-transcript:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========== Transcript Section ========== */
.transcript-section {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow: hidden;
  animation: slideUp 0.4s var(--transition-slow);
}

.transcript-section.visible {
  display: block;
}

.transcript-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 10px;
}

.transcript-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.transcript-toolbar-left h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.toggle-timestamp {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.toggle-timestamp input[type="checkbox"] {
  accent-color: var(--accent-mid);
  cursor: pointer;
}

.transcript-actions {
  display: flex;
  gap: 8px;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base);
}

.btn-action:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

.btn-action svg {
  width: 14px;
  height: 14px;
}

.btn-action.copied {
  border-color: var(--success);
  color: var(--success);
}

.transcript-content {
  padding: 24px;
  max-height: 500px;
  overflow-y: auto;
  font-size: 0.92rem;
  line-height: 1.8;
  color: var(--text-primary);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.transcript-content::-webkit-scrollbar {
  width: 6px;
}

.transcript-content::-webkit-scrollbar-track {
  background: transparent;
}

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

.transcript-line {
  padding: 4px 0;
  transition: background var(--transition-fast);
  border-radius: 4px;
}

.transcript-line:hover {
  background: rgba(255,255,255,0.03);
}

.transcript-timestamp {
  color: var(--accent-mid);
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-right: 10px;
  opacity: 0.8;
  user-select: none;
}

.timestamp-hidden .transcript-timestamp {
  display: none;
}

/* ========== Status Messages ========== */
.status-message {
  display: none;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  margin-bottom: 20px;
  animation: slideUp 0.3s ease;
}

.status-message.visible {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-message.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.status-message.success {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.2);
  color: #86efac;
}

/* ========== Loading ========== */
.loading-overlay {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 24px;
  text-align: center;
}

.loading-overlay.visible {
  display: flex;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent-mid);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

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

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

/* ========== Footer ========== */
.app-footer {
  text-align: center;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ========== Responsive ========== */
@media (max-width: 640px) {
  .app-wrapper {
    padding: 24px 16px 40px;
  }

  .app-logo h1 {
    font-size: 1.4rem;
  }

  .input-group {
    flex-direction: column;
  }

  .btn-generate {
    width: 100%;
    padding: 14px;
  }

  .video-info-inner {
    flex-direction: column;
    text-align: center;
  }

  .video-thumbnail {
    width: 100%;
    min-width: unset;
    max-width: 320px;
    margin: 0 auto;
  }

  .language-select-group {
    justify-content: center;
  }

  .transcript-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .transcript-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .btn-action {
    flex: 1;
    min-width: calc(50% - 4px); /* Make sure buttons wrap nicely on mobile */
    justify-content: center;
  }

  .btn-action.btn-icon {
    flex: 0 0 auto;
    min-width: unset;
  }
}

/* ========== Custom styles for new buttons ========== */
.btn-action.btn-icon {
  padding: 8px 10px;
}

.btn-action#btn-save-gdoc:hover {
  border-color: #4285F4;
  color: #4285F4;
}

.btn-action#btn-download-pdf:hover {
  border-color: #ef4444;
  color: #ef4444;
}

/* ========== Modal Google Drive Settings ========== */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(10, 10, 14, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.visible {
  display: flex;
  animation: fadeIn 0.25s ease-out;
}

.modal-content {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  animation: slideDown 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  color: var(--text-primary);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
}

.modal-close {
  color: var(--text-muted);
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition-fast);
}

.modal-close:hover,
.modal-close:focus {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.form-group input[type="text"] {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  transition: all var(--transition-base);
}

.form-group input[type="text"]:focus {
  outline: none;
  border-color: var(--border-focus);
  background: var(--bg-input-focus);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.25);
}

.input-help {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.modal-instructions {
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 0.82rem;
}

.modal-instructions h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.modal-instructions ol {
  padding-left: 18px;
  color: var(--text-secondary);
}

.modal-instructions li {
  margin-bottom: 6px;
  line-height: 1.5;
}

.modal-instructions code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 4px;
  border-radius: 4px;
  font-family: monospace;
  color: var(--accent-end);
  font-size: 0.78rem;
}

.modal-instructions a {
  color: var(--accent-mid);
  text-decoration: none;
  border-bottom: 1px dashed var(--accent-mid);
}

.modal-instructions a:hover {
  color: var(--accent-start);
  border-bottom-style: solid;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.modal-footer button {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  border: none;
  color: #ffffff;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(192, 68, 224, 0.3);
}

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

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ========== Gemini AI Summary Styling ========== */
.btn-action.btn-ai {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(192, 68, 224, 0.12));
  border-color: rgba(192, 68, 224, 0.25);
  color: #d88cf4;
}

.btn-action.btn-ai:hover {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(192, 68, 224, 0.25));
  border-color: var(--accent-mid);
  color: var(--text-primary);
  box-shadow: 0 0 12px var(--accent-glow);
}

.btn-action.btn-ai svg {
  color: #c044e0;
  transition: transform 0.3s ease;
}

.btn-action.btn-ai:hover svg {
  transform: scale(1.1) rotate(10deg);
  color: var(--text-primary);
}

.ai-summary-container {
  display: none;
  background: rgba(192, 68, 224, 0.03);
  border-bottom: 1px solid var(--border-color);
  padding: 20px 24px;
  animation: slideUp 0.3s var(--transition-slow);
}

.ai-summary-container.visible {
  display: block;
}

.ai-summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.ai-summary-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #d88cf4;
}

.ai-summary-title svg {
  width: 16px;
  height: 16px;
  color: #c044e0;
}

.ai-summary-title h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.5px;
}

.btn-close-summary {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition-fast);
}

.btn-close-summary:hover {
  color: var(--text-primary);
}

.ai-summary-content {
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.ai-summary-content h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 18px 0 8px 0;
  border-left: 3px solid var(--accent-mid);
  padding-left: 8px;
}

.ai-summary-content h3:first-of-type {
  margin-top: 0;
}

.ai-summary-content p {
  margin-bottom: 12px;
}

.ai-summary-content ul {
  margin-bottom: 12px;
  padding-left: 20px;
}

.ai-summary-content li {
  margin-bottom: 6px;
}

.ai-summary-content strong {
  color: var(--text-primary);
}

