/* ========================
   Base Reset & Typography
======================== */
* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans TC", "PingFang TC",
               "Microsoft JhengHei", sans-serif;
  background: linear-gradient(135deg, #eef2f3, #8e9eab);
  color: #333;
}

/* ---- Navigation Tabs ---- */
.nav-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.nav-link {
  color: #f5f5f5;
  text-decoration: none;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  transition: background 0.25s ease, color 0.25s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.nav-link.active {
  background: #fff;
  color: #4CAF50;
  font-weight: 700;
}


/* ========================
   Navbar
======================== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: #4CAF50;
  color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}

.logo {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#welcomeUser {
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0.95;
}

/* ========================
   Layout & Card
======================== */
.container {
  width: 100%;
  max-width: 960px;
  margin: 5vh auto;
  padding: 0 1rem;
}

.container h2 {
  margin: 0 0 0.75rem 0;
  font-size: 1.35rem;
  text-align: center;
  color: #2f3640;
}

#uploadSection,
.card {
  background: #fff;
  padding: 1.25rem;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.12);
}

/* ========================
   Form & Inputs
======================== */
form {
  display: grid;
  gap: 0.9rem;
}

input[type="file"] {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #e6e6e6;
  border-radius: 10px;
  background: #fafafa;
  transition: border-color 0.2s ease, background 0.2s ease;
}

input[type="file"]:focus {
  outline: none;
  border-color: #4CAF50;
  background: #fff;
}

/* ========================
   Buttons
======================== */
button {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 0.7rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s ease, box-shadow 0.2s ease, background 0.2s ease;
}

button:active { transform: translateY(1px); }

/* Upload */
#uploadBtn {
  background: #4CAF50;
  color: #fff;
  box-shadow: 0 6px 14px rgba(76,175,80,0.25);
}
#uploadBtn:hover { background: #43a047; }

/* Logout */
#logoutBtn {
  background: #e74c3c;
  color: #fff;
  box-shadow: 0 6px 14px rgba(231,76,60,0.25);
}
#logoutBtn:hover { background: #d84335; }

/* ========================
   Progress Bar
======================== */
progress {
  width: 100%;
  height: 10px;
  appearance: none;
  -webkit-appearance: none;
  border: none;
  border-radius: 999px;
  background-color: #eee;
  overflow: hidden;
}
progress::-webkit-progress-bar {
  background-color: #eee;
  border-radius: 999px;
}
progress::-webkit-progress-value {
  background-color: #4CAF50;
  border-radius: 999px;
}
progress::-moz-progress-bar {
  background-color: #4CAF50;
  border-radius: 999px;
}

/* ========================
   Status Box
======================== */
.status {
  font-size: 0.92rem;
  color: #555;
  background: #f7f8f9;
  border: 1px solid #eef1f2;
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  word-break: break-word;
}

/* ========================
   Video Grid
======================== */
#videoList {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); /* 自動填滿 */
  gap: 16px;
  margin-top: 20px;
}

/* 每張卡片固定寬高 */
.video-card {
  width: 200px;       /* 固定寬度 */
  height: 350px;      /* 固定高度 */
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  background: #fff;
  display: flex;          /* 讓內部元素置中 */
  flex-direction: column;
  justify-content: space-between;
}

/* Hover 效果 */
.video-card:hover {
  transform: translateY(-4px) scale(1.03); /* 微微浮起 */
  box-shadow: 0 6px 16px rgba(0,0,0,0.15); /* 陰影加深 */
}

/* 縮圖容器 */
.video-card .thumb-wrapper {
  position: relative;
  width: 100%;
  height: 120px;
  border-radius: 6px;
  overflow: hidden;
}

/* Thumbnail */
/* 縮圖固定高度 */
.video-card img,
.video-card .placeholder {
  width: 100%;
  height: 140px;  /* 縮圖區固定 */
  object-fit: cover;
  border-radius: 6px;
}

/* 播放 Icon */
.video-card .play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 36px;
  color: rgba(255, 255, 255, 0.85);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

/* Hover 時顯示播放 Icon */
.video-card .thumb-wrapper:hover .play-icon {
  opacity: 1;
}

.video-card .placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f0f0;
  color: #888;
  font-size: 14px;
}

/* Title 檔名 */
.video-card a {
  display: block;
  margin-top: 6px;
  font-weight: bold;
  color: #007BFF;
  text-decoration: none;
  white-space: nowrap;      /* 單行 */
  overflow: hidden;
  text-overflow: ellipsis;  /* 超出省略 */
}
.video-card a:hover { text-decoration: underline; }

/* Size 檔案大小 */
.video-card .size {
  color: #666;
  font-size: 12px;
  margin-top: 4px;
}

/* Delete Button 刪除按鈕 */
.video-card button {
  margin-top: 8px;
  background: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  transition: 0.3s;
}
.video-card button:hover { background: #c0392b; }

/* ========================
   Helpers & Responsive
======================== */
.hidden { display: none !important; }

@media (max-width: 640px) {
  .container { margin: 3.5vh auto; }
  .navbar { padding: 0.65rem 0.9rem; }
  .logo { font-size: 1.05rem; }
  #logoutBtn { padding: 0.55rem 0.9rem; }
}

/* ===== Modal Player ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden { display: none; }

.modal-content {
  background: #000;
  padding: 12px;
  border-radius: 10px;
  max-width: 90%;
  width: 800px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  position: relative;
}

.modal-content video {
  width: 100%;
  max-height: 70vh;
  border-radius: 6px;
}

.modal-content .close {
  position: absolute;
  top: 6px;
  right: 12px;
  font-size: 28px;
  font-weight: bold;
  color: #fff;
  cursor: pointer;
}
.modal-content .close:hover {
  color: #f00;
}
