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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: #0f0f0f;
  color: #f1f1f1;
  line-height: 1.6;
}

.container {
  max-width: 1920px;
  margin: 0 auto;
  padding: 20px;
}

/* 頂部標題 */
header {
  padding: 20px 0;
  border-bottom: 1px solid #272727;
  margin-bottom: 20px;
}

header h1 {
  font-size: 28px;
  font-weight: 600;
  color: #fff;
}

/* Tab 分頁 */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 30px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.tabs::-webkit-scrollbar {
  height: 6px;
}

.tabs::-webkit-scrollbar-track {
  background: #0f0f0f;
}

.tabs::-webkit-scrollbar-thumb {
  background: #3f3f3f;
  border-radius: 3px;
}

.tab {
  padding: 10px 24px;
  background-color: #272727;
  border: none;
  border-radius: 8px;
  color: #aaa;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.2s;
}

.tab:hover {
  background-color: #3f3f3f;
  color: #fff;
}

.tab.active {
  background-color: #f1f1f1;
  color: #0f0f0f;
}

/* 影片網格 */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  padding: 10px 0;
}

.video-card {
  cursor: pointer;
  transition: transform 0.2s;
}

.video-card:hover {
  transform: scale(1.02);
}

.video-thumbnail {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 比例 */
  background-color: #272727;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 12px;
}

.video-thumbnail img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-thumbnail.loading {
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-thumbnail.loading::after {
  content: '載入中...';
  position: absolute;
  color: #aaa;
  font-size: 14px;
}

.video-info {
  padding: 0 8px;
}

.video-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.video-title {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: #f1f1f1;
  line-height: 1.4;
  max-height: 2.8em;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.download-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background-color: #3f3f3f;
  border: none;
  border-radius: 50%;
  color: #f1f1f1;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.download-btn:hover {
  background-color: #065fd4;
  transform: scale(1.1);
}

.video-folder {
  margin-top: 8px;
  padding: 4px 8px;
  background-color: #3f3f3f;
  color: #aaa;
  font-size: 12px;
  border-radius: 4px;
  display: inline-block;
}

/* 密碼輸入對話框 */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background-color: #212121;
  padding: 40px;
  border-radius: 12px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
  margin-bottom: 12px;
  font-size: 24px;
  color: #fff;
}

.modal-content p {
  margin-bottom: 20px;
  color: #aaa;
  font-size: 14px;
}

.modal-content input[type="password"] {
  width: 100%;
  padding: 12px;
  margin-bottom: 20px;
  background-color: #0f0f0f;
  border: 1px solid #3f3f3f;
  border-radius: 8px;
  color: #f1f1f1;
  font-size: 16px;
  outline: none;
}

.modal-content input[type="password"]:focus {
  border-color: #065fd4;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal-buttons button {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

#submitPassword {
  background-color: #065fd4;
  color: #fff;
}

#submitPassword:hover {
  background-color: #0458b8;
}

#cancelPassword {
  background-color: #3f3f3f;
  color: #f1f1f1;
}

#cancelPassword:hover {
  background-color: #4f4f4f;
}

.error-message {
  color: #ff4444;
  font-size: 14px;
  margin-top: 12px;
  margin-bottom: 0;
  min-height: 20px;
}

/* 影片播放對話框 */
.video-modal-content {
  max-width: 90vw;
  width: 1200px;
  background-color: #181818;
  padding: 0;
  overflow: hidden;
}

.video-modal-content h2 {
  padding: 20px 24px;
  margin: 0;
  background-color: #212121;
  font-size: 20px;
  color: #f1f1f1;
  border-bottom: 1px solid #3f3f3f;
}

.video-modal-content video {
  width: 100%;
  max-height: 75vh;
  background-color: #000;
  display: block;
}

.close-button {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  background-color: rgba(0, 0, 0, 0.7);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
  z-index: 1001;
}

.close-button:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

/* 空狀態 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #aaa;
}

.empty-state h3 {
  font-size: 20px;
  margin-bottom: 12px;
  color: #ccc;
}

.empty-state p {
  font-size: 14px;
}

/* 響應式設計 */
@media (max-width: 768px) {
  .video-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }

  .tabs {
    gap: 6px;
  }

  .tab {
    padding: 8px 16px;
    font-size: 13px;
  }

  header h1 {
    font-size: 24px;
  }
}
