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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #222636;
  --accent: #6c63ff;
  --accent2: #ff6584;
  --text: #e8eaf6;
  --muted: #8888aa;
  --success: #4caf90;
  --border: #2e3350;
  --radius: 14px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 40px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 6px 14px;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}
nav a.active, nav a:hover { background: var(--surface2); color: var(--text); }

main {
  max-width: 820px;
  margin: 40px auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.card h2 { font-size: 1.3rem; margin-bottom: 8px; }
.card h3 { font-size: 1.1rem; margin-bottom: 16px; }
.hint { color: var(--muted); font-size: 0.9rem; margin-bottom: 24px; }

/* Drop Zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  color: var(--muted);
  font-size: 0.95rem;
}
.drop-zone.drag-over { border-color: var(--accent); background: rgba(108,99,255,0.06); }
.browse { color: var(--accent); cursor: pointer; text-decoration: underline; }
.file-name { margin-top: 10px; color: var(--text); font-size: 0.9rem; font-weight: 600; }

button[type="submit"] {
  margin-top: 20px;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #8b80ff);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}
button[type="submit"]:disabled { opacity: 0.4; cursor: not-allowed; }
button[type="submit"]:not(:disabled):hover { opacity: 0.9; transform: translateY(-1px); }

/* Progress */
.progress { margin-top: 24px; }
.progress-bar { background: var(--surface2); border-radius: 8px; height: 8px; overflow: hidden; }
.progress-fill {
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  width: 0%;
  transition: width 0.4s;
  animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%,100%{ opacity:1 } 50%{ opacity:0.6 } }
#statusText { margin-top: 10px; color: var(--muted); font-size: 0.88rem; }

/* Result */
.result { margin-top: 24px; text-align: center; }
.result p { color: var(--success); font-weight: 600; margin-bottom: 14px; }
.btn-download {
  display: inline-block;
  padding: 12px 28px;
  background: var(--success);
  color: #fff;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.2s;
}
.btn-download:hover { opacity: 0.85; }

/* Table */
.history-card { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 10px 10px; border-bottom: 1px solid var(--border); color: var(--text); }
tr:last-child td { border-bottom: none; }
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 0.78rem; font-weight: 600;
}
.badge-pending    { background: rgba(255,200,0,0.15);  color: #ffc800; }
.badge-processing { background: rgba(108,99,255,0.15); color: var(--accent); }
.badge-done       { background: rgba(76,175,144,0.15); color: var(--success); }
.badge-failed     { background: rgba(255,101,132,0.15); color: var(--accent2); }
.badge-mp4        { background: rgba(108,99,255,0.12); color: var(--accent); }
.badge-tts        { background: rgba(255,101,132,0.12); color: var(--accent2); }
.badge-photo      { background: rgba(76,175,144,0.12); color: var(--success); }
.badge-screen     { background: rgba(255,200,0,0.12);  color: #ffc800; }
.badge-trim       { background: rgba(139,128,255,0.14); color: #8b80ff; }
.badge-concat     { background: rgba(76,175,144,0.14);  color: var(--success); }

/* Cắt video/audio: player trực quan + timeline */
.player-wrap { margin-top: 20px; }
.media-holder { display: flex; justify-content: center; }
.media-holder video { max-width: 100%; max-height: 340px; border-radius: 10px; background: #000; }
.media-holder audio { width: 100%; margin-top: 4px; }

.timeline { margin-top: 16px; padding: 0 11px; }
.tl-track {
  position: relative;
  height: 22px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.tl-range {
  position: absolute; top: 0; bottom: 0;
  background: rgba(108,99,255,0.30);
  border-left: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
}
.tl-playhead {
  position: absolute; top: -3px; bottom: -3px; width: 2px;
  background: var(--accent2); pointer-events: none;
}
.tl-handle {
  position: absolute; top: 50%; width: 14px; height: 28px;
  transform: translate(-50%, -50%);
  background: var(--accent); border-radius: 5px; cursor: ew-resize;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.tl-handle::after {
  content: ''; position: absolute; top: 7px; left: 5px;
  width: 4px; height: 14px;
  border-left: 1px solid rgba(255,255,255,0.6);
  border-right: 1px solid rgba(255,255,255,0.6);
}
.tl-handle-end { background: var(--accent2); }

.tl-bar { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; gap: 12px; }
.tl-time { color: var(--muted); font-size: 0.88rem; }
.tl-time b { color: var(--text); font-variant-numeric: tabular-nums; }
.tl-preview {
  padding: 7px 16px; border: 1px solid var(--accent); border-radius: 8px;
  background: transparent; color: var(--accent); cursor: pointer; font-size: 0.85rem;
  transition: background 0.2s, color 0.2s;
}
.tl-preview:hover { background: var(--accent); color: #fff; }

/* Cắt video/audio: hàng nhập thời gian */
.time-row { display: flex; gap: 16px; margin-top: 20px; }
.time-row .form-group { flex: 1; margin-bottom: 0; }
.muted-note { color: var(--muted); font-weight: 400; font-size: 0.78rem; }
input[type="text"] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
input[type="text"]:focus { border-color: var(--accent); }
code {
  background: var(--surface2);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.85em;
  color: var(--accent);
}

.subtabs { display: flex; gap: 8px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.subtab {
  background: none; border: none; color: var(--text); cursor: pointer;
  padding: 8px 16px; font-size: 0.95rem; border-bottom: 2px solid transparent;
  margin-bottom: -1px; opacity: 0.65;
}
.subtab:hover { opacity: 1; }
.subtab.active { opacity: 1; border-bottom-color: var(--accent); color: var(--accent); }

.capture-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.capture-status { margin-top: 14px; }
.check-label { display: flex; align-items: center; gap: 8px; color: var(--text); cursor: pointer; }
.check-label input { width: 16px; height: 16px; cursor: pointer; }

.dl-link { color: var(--accent); text-decoration: none; font-size: 0.85rem; }
.dl-link:hover { text-decoration: underline; }

.history-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.history-header h3 { margin-bottom: 0; }

.btn-delete-all {
  padding: 6px 16px;
  border: 1px solid var(--accent2);
  border-radius: 8px;
  background: transparent;
  color: var(--accent2);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.btn-delete-all:hover { background: var(--accent2); color: #fff; }

.btn-delete-row {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}
.btn-delete-row:hover { color: var(--accent2); background: rgba(255,101,132,0.1); }

.btn-rename-row {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}
.btn-rename-row:hover { color: var(--accent); background: rgba(122,162,247,0.1); }
.btn-rename-row:disabled { opacity: 0.3; cursor: default; }

/* Danh sách ghép nối */
.concat-list { list-style: none; margin: 16px 0; display: flex; flex-direction: column; gap: 8px; }
.concat-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
}
.concat-idx {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
}
.concat-name { flex: 1; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.concat-actions { display: flex; gap: 2px; flex-shrink: 0; }

/* TTS form */
.form-group { margin-bottom: 18px; }
.form-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 500;
}
.char-count { font-size: 0.8rem; }
textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 14px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}
textarea:focus { border-color: var(--accent); }
select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238888aa' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
select:focus { border-color: var(--accent); }

.row-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.dl-link { white-space: nowrap; }

/* Modal xem trực tiếp */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.7); }
.modal-box {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 90vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.modal-close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: none; color: var(--muted);
  font-size: 1.2rem; cursor: pointer; padding: 4px 8px; border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}
.modal-close:hover { color: var(--accent2); background: rgba(255,101,132,0.1); }
.modal-body {
  display: flex; align-items: center; justify-content: center;
  max-width: 100%;
}
.modal-body img, .modal-body video {
  max-width: 82vw; max-height: 70vh;
  border-radius: 10px; object-fit: contain;
}
.audio-wrap { text-align: center; min-width: 320px; }
.audio-name { color: var(--text); font-weight: 600; margin-bottom: 16px; }
.modal-body audio { width: 360px; max-width: 80vw; }

.hidden { display: none !important; }

/* ── Đăng nhập / Đăng ký ─────────────────────────────────────── */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.auth-box {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px 30px;
}
.auth-logo {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.auth-box h2 { font-size: 1.25rem; margin-bottom: 4px; }
.auth-sub { color: var(--muted); font-size: 0.88rem; margin-bottom: 18px; }
.auth-label { display: block; font-size: 0.82rem; color: var(--muted); margin: 12px 0 6px; }
.auth-input {
  width: 100%;
  padding: 11px 13px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.95rem;
}
.auth-input:focus { outline: none; border-color: var(--accent); }
.auth-btn {
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 0.98rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #8b80ff);
}
.auth-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.auth-switch { margin-top: 18px; text-align: center; font-size: 0.88rem; color: var(--muted); }
.auth-switch a { color: var(--accent); text-decoration: none; font-weight: 600; }
.auth-switch a:hover { text-decoration: underline; }
.auth-error {
  display: none;
  background: rgba(255,101,132,0.12);
  border: 1px solid var(--accent2);
  color: var(--accent2);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  margin-bottom: 6px;
}

/* Ô tài khoản trên header */
.user-box { display: flex; align-items: center; gap: 12px; }
.user-email { color: var(--muted); font-size: 0.85rem; }
.btn-logout {
  padding: 7px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}
.btn-logout:hover { border-color: var(--accent2); color: var(--accent2); }

/* Banner nhắc xác thực email */
.verify-banner {
  background: rgba(255,193,7,0.12);
  border-bottom: 1px solid #f9ab00;
  color: #f9ab00;
  padding: 10px 40px;
  text-align: center;
  font-size: 0.88rem;
}
.verify-banner a { color: var(--accent); font-weight: 600; text-decoration: none; }
.verify-banner a:hover { text-decoration: underline; }
#resendMsg { margin-left: 8px; color: var(--success); }

/* Thông báo thành công trong khung auth (vd đã gửi email đặt lại mật khẩu) */
.auth-msg {
  background: rgba(76,175,144,0.12);
  border: 1px solid var(--success);
  color: var(--success);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  margin-bottom: 6px;
}
