/* =====================
   🌐 STYLE CHUNG CHO TOÀN TRANG
   ===================== */
html, body {
  height: auto;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  font-family: "Segoe UI", Arial, sans-serif;
  background: #f4f7fb;
  color: #222;
}

/* ===== HEADER CHUNG ===== */
h1, .section-title {
  text-align: center;
  color: #333;
  margin: 30px 0 25px 0;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: linear-gradient(90deg, #007bff, #ff6f00);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 1.8em;
}

/* ===== BỐ CỤC CHUNG ===== */
.main-wrapper {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 40px 60px;
  box-sizing: border-box;
}

.content-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ===== TTS PROGRESS PANEL ===== */
.progress-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  min-width: 450px;
  max-width: 600px;
  background: #fff;
  border-radius: 15px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  border: 1px solid #e0e0e0;
}

.progress-content {
  padding: 25px;
  text-align: center;
}

.progress-content h3 {
  margin: 0 0 20px 0;
  color: #333;
  font-size: 1.3em;
  font-weight: 600;
}

.progress-bar-wrapper {
  width: 100%;
  height: 25px;
  background: #f0f0f0;
  border-radius: 12px;
  overflow: hidden;
  margin: 15px 0;
  border: 1px solid #ddd;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #007bff, #0056b3);
  transition: width 0.5s ease;
  border-radius: 11px;
}

#tts-progress-percent {
  font-size: 1.1em;
  font-weight: 600;
  color: #007bff;
  margin: 10px 0;
}

.progress-log {
  max-height: 150px;
  overflow-y: auto;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 10px;
  margin-top: 15px;
  text-align: left;
  font-size: 0.9em;
  font-family: 'Courier New', monospace;
}

.progress-log div {
  margin: 3px 0;
  padding: 2px 0;
}

/* ===== KHUNG CHÍNH (MAIN PANEL) ===== */
.main-panel {
  width: 100%;
  max-width: 1400px;
  background: #fff;
  padding: 40px 50px;
  border-radius: 20px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.08);
  box-sizing: border-box;
  margin-bottom: 60px;

  /* ✅ Sửa ở đây */
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 40px;
}

/* ===== PANEL CON (2 khối YouTube + Gemini) ===== */
.panel {
  background: #fff;
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08);
  width: 100%;
  max-width: 420px; /* ✅ giữ khung vừa phải */
  flex: 1 1 400px; /* ✅ cho phép co giãn linh hoạt */
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.panel:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}

/* ===== NÚT ===== */
button {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.1s ease;
}
button:hover {
  opacity: 0.9;
  transform: scale(1.02);
}
.btn-gemini {
  background: linear-gradient(90deg,#ff8a00,#ff6f00);
}
.btn-gpt {
  background: linear-gradient(90deg,#007bff,#0056d2);
}
.btn-key {
  background: #28a745;
}
.btn-key.violet {
  background: #8a2be2;
}

/* ===== FORM ===== */
form {
  margin-bottom: 15px;
  padding: 18px;
  border: 1px solid #eee;
  border-radius: 12px;
  background: #fafafa;
  box-sizing: border-box;
}
label {
  font-weight: 600;
  display: block;
  margin-bottom: 5px;
}
input[type="file"], input[type="text"], input[type="number"], select {
  width: 100%;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 0.95em;
}

/* ===== TIẾN ĐỘ ===== */
#progress-panel {
  max-width: 800px;
  width: 100%;
  margin: 30px auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.1);
  padding: 20px 25px;
}
#progress-status {
  max-height: 180px;
  overflow-y: auto;
  padding: 6px;
  background: #fafafa;
  border: 1px solid #ddd;
  border-radius: 6px;
}
.progress-bar-wrapper {
  background: #e0e0e0;
  height: 22px;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 10px;
}
#progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg,#28a745,#2e8b57);
  transition: width 0.5s;
}

/* ===== FLASH ===== */
.flash {
  background: #fff3cd;
  border: 1px solid #ffeeba;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 20px;
  text-align: center;
  font-weight: 500;
}

/* ===== FOOTER ===== */
footer {
  text-align: center;
  color: #777;
  font-size: 0.9em;
  margin: 40px 0 20px 0;
}

/* ===== RESPONSIVE CHO INDEX ===== */
@media (max-width: 900px) {
  .main-panel {
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 25px;
  }
}
  .main-panel {
    padding: 25px;
    gap: 15px;
  }
  .panel {
    max-width: 100%;
  }
  button {
    font-size: 0.9em;
  }
  .section-title {
    font-size: 1.3em;
  }
}

/* =====================
   🎬 STYLE RIÊNG CHO TRANG CHỈNH SỬA PHỤ ĐỀ
   ===================== */
#editor-container {
  display: flex;
  flex-direction: row;
  height: calc(100vh - 100px);
  overflow: hidden;
  background: #f8f8f8;
}

/* --- VIDEO --- */
#video-pane {
  flex: 2;
  background: #000;
  padding: 10px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-wrapper {
  width: 100%;
  max-width: 960px;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
  position: relative;
}
video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: pointer;
  max-height: 100%;
}

/* --- PHỤ ĐỀ --- */
#subtitle-pane {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  background: #f4f4f4;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  height: 100%;
  -webkit-overflow-scrolling: touch;
}
.subtitle-block {
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 8px;
  background: #fff;
  transition: background 0.2s, border-color 0.2s;
  cursor: pointer;
}
.subtitle-block.active {
  background: #e0f7fa;
  border-color: #00acc1;
}
.subtitle-text {
  width: 100%;
  height: 60px;
  font-size: 15px;
  border: 1px solid #ddd;
  padding: 6px;
  border-radius: 4px;
  resize: vertical;
}

/* --- HÀNH ĐỘNG --- */
#actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px;
  background: #fff;
  box-shadow: 0 -2px 6px rgba(0,0,0,0.1);
}

/* --- RESPONSIVE TRANG EDIT --- */
@media (max-width: 900px) {
  #editor-container {
    flex-direction: column;
    height: auto;
  }
  #video-pane {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    z-index: 10;
  }
  video {
    width: 100%;
    max-height: 45vh;
  }
  #subtitle-pane {
    max-height: 55vh;
    overflow-y: auto;
  }
  #actions {
    flex-direction: column;
  }
}
