/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1c1c2e;
  --bg-hover: #252540;
  --border: #2a2a45;
  --text-primary: #e8e8f0;
  --text-secondary: #8888aa;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.3);
  --success: #00b894;
  --warning: #fdcb6e;
  --error: #e17055;
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.badge {
  background: var(--bg-tertiary);
  color: var(--accent-light);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

/* ===== Main Layout ===== */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ===== Control Panel (Left) ===== */
.control-panel {
  width: 360px;
  min-width: 360px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

/* ===== Form Elements ===== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}
.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-secondary);
}
.form-textarea {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 100px;
  transition: border-color 0.2s;
}
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-textarea::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

/* ===== Button Groups ===== */
.btn-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.btn-toggle {
  flex: 1;
  min-width: 60px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.btn-toggle.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px var(--accent-glow);
}

/* ===== Info Box ===== */
.info-box {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.info-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}
.info-row span:last-child {
  color: var(--text-primary);
  font-weight: 600;
}

/* ===== Buttons ===== */
.btn-generate {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent), #8b7cf6);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-generate:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--accent-glow);
}
.btn-generate:active {
  transform: translateY(0);
}
.btn-generate:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-small {
  padding: 4px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  align-self: flex-start;
}
.btn-small:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.btn-enhance {
  margin-top: 4px;
}

/* ===== Result Panel (Right) ===== */
.result-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 20px;
  gap: 16px;
}

.result-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.result-area {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.empty-state {
  text-align: center;
  color: var(--text-secondary);
}
.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.3;
}
.empty-state p {
  font-size: 15px;
}

/* ===== Progress ===== */
.progress-container {
  width: 100%;
  max-width: 500px;
  padding: 40px;
}
.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.progress-status {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.progress-percent {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-light);
}
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 4px;
  transition: width 0.5s ease;
  position: relative;
  overflow: hidden;
}
.progress-fill::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.progress-detail {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}

/* ===== Video Player ===== */
.video-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 12px;
}
#videoPlayer {
  max-width: 100%;
  max-height: 70vh;
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.video-actions {
  display: flex;
  gap: 12px;
}
.btn-action {
  padding: 8px 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}
.btn-action:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.video-meta {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  max-width: 600px;
}

/* ===== History ===== */
.history-section {
  max-height: 240px;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.history-empty {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 20px;
}
.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}
.history-item:hover {
  background: var(--bg-hover);
}
.history-thumb {
  width: 48px;
  height: 36px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.history-info {
  flex: 1;
  min-width: 0;
}
.history-prompt {
  font-size: 12px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-meta {
  font-size: 11px;
  color: var(--text-secondary);
}
.history-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}
.history-badge.success {
  background: rgba(0, 184, 148, 0.2);
  color: var(--success);
}
.history-badge.failed {
  background: rgba(225, 112, 85, 0.2);
  color: var(--error);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  color: var(--text-primary);
  font-size: 14px;
  z-index: 1000;
  transition: transform 0.3s;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.toast.show {
  transform: translateX(-50%) translateY(0);
}
.toast.error {
  border-color: var(--error);
}
.toast.success {
  border-color: var(--success);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .main-layout {
    flex-direction: column;
  }
  .control-panel {
    width: 100%;
    min-width: 0;
    max-height: 50vh;
  }
  .result-panel {
    padding: 12px;
  }
}
