/* Import premium fonts: Outfit for English & Sarabun for Thai */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #080B11;
  --bg-secondary: rgba(17, 24, 39, 0.7);
  --bg-panel: rgba(30, 41, 59, 0.45);
  --border-color: rgba(255, 255, 255, 0.08);
  
  --primary: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.35);
  --primary-hover: #4f46e5;
  --accent: #8b5cf6;
  --accent-glow: rgba(139, 92, 246, 0.3);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dark: #64748b;
  
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --font-family: 'Outfit', 'Sarabun', system-ui, -apple-system, sans-serif;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.1) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

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

/* Header */
header {
  backdrop-filter: blur(12px);
  background: rgba(8, 11, 17, 0.85);
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.2rem;
  box-shadow: 0 0 15px var(--primary-glow);
}

h1 {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Controls & Settings Trigger */
.header-actions {
  display: flex;
  gap: 1rem;
}

.btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  transition: var(--transition-smooth);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border: none;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--primary-glow);
  filter: brightness(1.1);
}

/* Main Container */
main {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Upload Container */
.upload-container {
  background: var(--bg-secondary);
  border: 2px dashed rgba(99, 102, 241, 0.3);
  border-radius: 16px;
  padding: 4rem 2rem;
  text-align: center;
  cursor: pointer;
  backdrop-filter: blur(16px);
  box-shadow: var(--glass-shadow);
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.upload-container:hover, .upload-container.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.15);
}

.upload-icon {
  width: 80px;
  height: 80px;
  background: rgba(99, 102, 241, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 2.2rem;
  transition: var(--transition-smooth);
}

.upload-container:hover .upload-icon {
  transform: scale(1.1);
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent);
}

.upload-text h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

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

/* File Info Bar */
.file-info-bar {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: fadeIn 0.3s ease;
}

.file-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.file-icon {
  font-size: 1.5rem;
  color: var(--primary);
}

.file-details h4 {
  font-size: 0.95rem;
  font-weight: 500;
}

.file-details span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.action-buttons {
  display: flex;
  gap: 0.75rem;
}

/* Grid Dashboard */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 2rem;
  min-height: 550px;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(16px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Video Player Panel */
.video-panel {
  padding: 1.25rem;
}

.video-wrapper {
  background: #000;
  border-radius: 10px;
  aspect-ratio: 16/9;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.video-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-info {
  margin-top: 1rem;
}

.video-info h3 {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

/* Transcript Panel */
.transcript-panel {
  display: flex;
  flex-direction: column;
}

.transcript-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.search-box {
  position: relative;
}

.search-box input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.9rem;
  padding: 0.65rem 1rem 0.65rem 2.2rem;
  border-radius: 8px;
  outline: none;
  transition: var(--transition-smooth);
}

.search-box input:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.15);
}

.search-icon {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.tab-export-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  padding: 3px;
  border: 1px solid var(--border-color);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-family);
  font-weight: 500;
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  transition: var(--transition-smooth);
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Export Dropdown Menu */
.export-dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 105%;
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  min-width: 160px;
  z-index: 100;
  display: none;
  flex-direction: column;
  padding: 0.4rem;
  backdrop-filter: blur(20px);
  animation: slideDown 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown-menu.show {
  display: flex;
}

.dropdown-item {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.6rem 1rem;
  text-align: left;
  font-family: var(--font-family);
  font-size: 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
}

/* Transcript Body */
.transcript-body {
  flex: 1;
  padding: 1.25rem;
  max-height: 480px;
  overflow-y: auto;
  position: relative;
}

.panel-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Full Text Style */
#panelText p {
  line-height: 1.7;
  font-size: 0.95rem;
  color: #cbd5e1;
}

/* Interactive Segments List */
.segments-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.segment-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  padding: 0.8rem 2.2rem 0.8rem 1rem;
  cursor: pointer;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.segment-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(99, 102, 241, 0.25);
  transform: translateX(3px);
}

.segment-item::after {
  content: '✏️';
  position: absolute;
  right: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-smooth);
}

.segment-item:hover::after {
  opacity: 0.4;
}

.segment-time {
  background: rgba(99, 102, 241, 0.12);
  color: var(--primary);
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-family: 'Outfit', monospace;
  margin-top: 0.1rem;
}

.segment-text {
  flex: 1;
  line-height: 1.5;
  font-size: 0.92rem;
  color: #e2e8f0;
  outline: none;
  cursor: text;
  padding: 2px 6px;
  border-radius: 4px;
  transition: var(--transition-smooth);
}

.segment-text:focus {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 1px var(--primary);
  color: white;
}

/* Segment highlighting when playing */
.segment-item.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.12) 0%, rgba(139, 92, 246, 0.04) 100%);
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: inset 3px 0 0 var(--primary);
}

.segment-item.active .segment-time {
  background: var(--primary);
  color: white;
}

.segment-item.active .segment-text {
  color: white;
  font-weight: 500;
}

/* Highlight Search Mark */
.highlight-mark {
  background: rgba(245, 158, 11, 0.25);
  border-bottom: 2px solid var(--warning);
  color: #fff;
  border-radius: 2px;
  padding: 0 2px;
}

.hidden-search {
  display: none !important;
}

/* Settings Slide Panel */
.settings-panel {
  position: fixed;
  top: 0;
  right: -380px;
  width: 380px;
  height: 100vh;
  background: #0f172a;
  border-left: 1px solid var(--border-color);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.settings-panel.open {
  right: 0;
}

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

.settings-header h3 {
  font-size: 1.15rem;
  font-weight: 600;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.close-btn:hover {
  color: white;
}

.settings-body {
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-group input, .form-group select {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  font-family: var(--font-family);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-smooth);
}

.form-group input:focus, .form-group select:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.06);
}

.help-text {
  font-size: 0.78rem;
  color: var(--text-dark);
  line-height: 1.4;
}

.settings-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.settings-footer .btn {
  width: 100%;
  justify-content: center;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(8, 11, 17, 0.85);
  backdrop-filter: blur(10px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader-card {
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 3rem;
  width: 90%;
  max-width: 460px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.75rem;
}

/* Sound Wave Animation */
.sound-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 60px;
}

.sound-wave span {
  width: 5px;
  height: 15px;
  background: linear-gradient(to top, var(--primary), var(--accent));
  border-radius: 4px;
  animation: wave 1.2s ease-in-out infinite;
}

.sound-wave span:nth-child(1) { animation-delay: 0.1s; }
.sound-wave span:nth-child(2) { animation-delay: 0.3s; }
.sound-wave span:nth-child(3) { animation-delay: 0.5s; }
.sound-wave span:nth-child(4) { animation-delay: 0.2s; }
.sound-wave span:nth-child(5) { animation-delay: 0.4s; }

@keyframes wave {
  0%, 100% { height: 12px; }
  50% { height: 50px; }
}

.loader-text h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.loader-text p {
  color: var(--text-muted);
  font-size: 0.88rem;
  min-height: 1.3rem;
}

.progress-container {
  width: 100%;
}

.progress-bar {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  height: 6px;
  width: 100%;
  overflow: hidden;
  margin-bottom: 0.5rem;
  position: relative;
}

.progress-bar-fill {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  height: 100%;
  width: 0%;
  border-radius: 10px;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px var(--primary-glow);
}

.progress-text {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Toast Notifications Container */
#notificationContainer {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 3000;
  max-width: 380px;
}

.toast {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
  padding: 0.9rem 1.25rem;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: white;
  font-size: 0.88rem;
  box-shadow: 0 10px 20px rgba(0,0,0,0.3);
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.show {
  transform: translateX(0);
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--error); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info { border-left: 4px solid var(--primary); }

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Keyframes */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem;
  border-top: 1px solid var(--border-color);
  color: var(--text-dark);
  font-size: 0.8rem;
  margin-top: auto;
}
