:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: rgba(20, 20, 30, 0.6);
  --bg-card: rgba(30, 30, 45, 0.45);
  --bg-glass: rgba(15, 15, 25, 0.65);
  
  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-blue: #3b82f6;
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dark: #1f2937;
  
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(139, 92, 246, 0.5);
  
  --status-idle: #6b7280;
  --status-captioning: #3b82f6;
  --status-queued: #f59e0b;
  --status-uploading: #d97706;
  --status-success: #10b981;
  --status-error: #ef4444;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Background Gradients */
.glass-bg {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  background: 
    radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(236, 72, 153, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.08) 0%, transparent 50%);
  background-size: cover;
}

/* Main Container Layout */
.app-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 20px 28px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  gap: 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand .icon {
  font-size: 36px;
  filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.5));
  animation: float 4s ease-in-out infinite;
}

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

.brand h1 {
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(90deg, #fff, var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.brand p {
  font-size: 13px;
  color: var(--text-muted);
}

/* Stats Summary */
.stats-container {
  display: flex;
  gap: 16px;
  flex-grow: 1;
  justify-content: center;
  max-width: 600px;
}

.stat-card {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 10px 16px;
  text-align: center;
  transition: var(--transition-smooth);
}

.stat-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

#stat-total .stat-value { color: var(--text-main); }
#stat-queued .stat-value { color: var(--status-queued); }
#stat-published .stat-value { color: var(--status-success); }
#stat-failed .stat-value { color: var(--status-error); }

/* Buttons & Controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: 1px solid transparent;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  color: white;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border-color: var(--border-glass);
}

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

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ff8b8b;
  border-color: rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.3);
  border-color: rgba(239, 68, 68, 0.5);
}

.btn-icon-only {
  width: 42px;
  height: 42px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  cursor: pointer;
  font-size: 18px;
  transition: var(--transition-smooth);
}

.btn-icon-only:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: rotate(30deg);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Main Content Layout */
.main-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
}

.main-content.calendar-active {
  grid-template-columns: 1fr;
}

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

  .video-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

/* Left Panel: Video list */
.video-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.section-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.folder-path {
  font-size: 13px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-glass);
}

/* Video Grid and Cards */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 24px;
  background: var(--bg-glass);
  border: 2px dashed var(--border-glass);
  border-radius: 16px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 16px;
  filter: opacity(0.6);
}

.empty-state h3 {
  font-size: 18px;
  color: var(--text-main);
  margin-bottom: 8px;
}

.video-card {
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: var(--transition-smooth);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.video-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

/* Video Player Header */
.video-preview-container {
  position: relative;
  aspect-ratio: 9 / 12;
  max-height: 220px;
  background: #000;
  width: 100%;
  border-bottom: 1px solid var(--border-glass);
}

.video-preview-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-status-overlay {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border-radius: 30px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: white;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: white;
}

.status-badge.idle { background: var(--status-idle); }
.status-badge.captioning { background: var(--status-captioning); animation: pulse 1.5s infinite; }
.status-badge.queued { background: var(--status-queued); animation: pulse 1.5s infinite; }
.status-badge.uploading { background: var(--status-uploading); animation: pulse 1.5s infinite; }
.status-badge.published { background: var(--status-success); }
.status-badge.failed { background: var(--status-error); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Video Card Body */
.video-card-body {
  padding: 9px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1;
}

.video-title {
  font-size: 12px;
  font-weight: 600;
  word-break: break-all;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}

.video-metadata {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.caption-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-grow: 1;
}

.caption-wrapper label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.caption-textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-glass);
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 11px;
  line-height: 1.35;
  resize: vertical;
  min-height: 42px;
  max-height: 74px;
  transition: var(--transition-smooth);
}

.caption-textarea:focus {
  outline: none;
  border-color: var(--accent-purple);
  background: rgba(0, 0, 0, 0.4);
}

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

.caption-actions .btn {
  flex: 1;
  padding: 5px 8px;
  font-size: 11px;
}

.video-card-footer {
  padding: 8px 9px 10px 9px;
  border-top: 1px solid var(--border-glass);
  display: flex;
  gap: 6px;
}

.video-card-footer .btn {
  flex: 1;
}

/* Error banner inside video card */
.card-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: #ff8b8b;
  word-break: break-word;
}

/* Side Panel (Console & Instructions) */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 24px;
  align-self: start;
}

/* Console Logger Card */
.console-card {
  background: rgba(10, 10, 15, 0.85);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  height: 400px;
}

.console-header {
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.console-header h3 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--status-success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--status-success);
  animation: glow 1.5s infinite alternate;
}

@keyframes glow {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

.console-body {
  padding: 16px;
  flex-grow: 1;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Monospace Log Lines */
.log-line {
  word-break: break-word;
  white-space: pre-wrap;
}

.log-line .time {
  color: var(--text-muted);
  margin-right: 6px;
}

.log-line.info { color: #e5e7eb; }
.log-line.success { color: #34d399; }
.log-line.error { color: #f87171; }

/* Instructions Card */
.instructions-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 20px;
}

.instructions-card h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
}

.instructions-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.instructions-card li {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.instructions-card li strong {
  color: var(--accent-purple);
  margin-right: 4px;
}

.instructions-card li code {
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 11px;
  font-family: var(--font-mono);
}

/* Modal Styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-smooth);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  background: #11111a;
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  width: 90%;
  max-width: 650px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: var(--transition-smooth);
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

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

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

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

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.form-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.form-section h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-purple);
  margin-bottom: 4px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group input[type="text"],
.form-group select,
.form-group textarea {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  transition: var(--transition-smooth);
  width: 100%;
}

.form-group input[type="text"]:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-purple);
}

.password-input-container {
  display: flex;
  position: relative;
}

.password-input-container input {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 10px 44px 10px 14px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  transition: var(--transition-smooth);
  width: 100%;
}

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

.btn-toggle-visibility {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
}

.field-help {
  font-size: 11px;
  color: var(--text-muted);
}

.field-help code {
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 4px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

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

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}

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

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}
