/* ==========================================================================
   教學資源D1網站 - 現代極致視覺美學系統 (v29 - 資源類型篩選與單元分類雙重對應連動)
   檔名：20260808_style_v29.css
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Noto+Sans+TC:wght@300;400;500;700&display=swap');

:root {
  /* 全站黃金對齊寬度 (1060px) */
  --layout-max-width: 1060px;

  /* HSL 和諧高階暗色調系統 */
  --bg-dark: hsl(222, 47%, 7%);
  --bg-card: hsla(217, 33%, 12%, 0.75);
  --bg-card-hover: hsla(217, 33%, 17%, 0.85);
  --bg-glass: hsla(222, 47%, 11%, 0.85);
  
  --border-color: hsla(217, 33%, 25%, 0.5);
  --border-glow: hsla(199, 89%, 48%, 0.6);
  
  /* 多資源類型專屬代表色彩 */
  --type-deck: hsl(199, 89%, 48%);       /* 簡報 - 寶藍 */
  --type-article: hsl(160, 84%, 39%);    /* 部落格文章 - 翡翠綠 */
  --type-ai: hsl(270, 85%, 60%);         /* AI資訊 - 紫羅蘭 */
  --type-tool: hsl(32, 95%, 53%);        /* 教學工具 - 琥珀橘 */

  --primary: hsl(199, 89%, 48%);
  --primary-hover: hsl(199, 89%, 58%);
  --accent: hsl(160, 84%, 39%);
  --accent-hover: hsl(160, 84%, 49%);
  --danger: hsl(346, 84%, 61%);
  --warning: hsl(38, 92%, 50%);
  
  --text-main: hsl(210, 40%, 98%);
  --text-muted: hsl(215, 20%, 65%);
  --text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 全域重設 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', 'Noto Sans TC', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 0% 0%, hsla(217, 70%, 15%, 0.5) 0px, transparent 50%),
    radial-gradient(at 100% 100%, hsla(199, 70%, 15%, 0.3) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* 1. 最頂部橫幅 (Hero Banner) */
.hero-banner-container-b {
  width: 100%;
  max-width: var(--layout-max-width);
  margin: 1.25rem auto 0.75rem auto;
  padding: 0;
  display: flex;
  justify-content: center;
  background: transparent;
}

.hero-banner-img-b {
  width: 100%;
  max-width: var(--layout-max-width);
  height: auto;
  display: block;
  background: transparent;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  transition: var(--transition);
}

.hero-banner-img-b:hover {
  transform: translateY(-2px);
  border-color: var(--border-glow);
  box-shadow: 0 16px 40px hsla(199, 89%, 48%, 0.25);
}

/* 2. Header & 導航整合列 - 1060px 滿版緊鎖對齊 */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 0.55rem 0;
  width: 100%;
}

.header-container {
  max-width: var(--layout-max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0.25rem;
  flex-wrap: nowrap;
}

.search-box-header {
  position: relative;
  width: 120px;
  flex-shrink: 1;
}

.search-input-header {
  width: 100%;
  padding: 0.32rem 0.4rem 0.32rem 1.7rem;
  background: hsla(222, 47%, 7%, 0.75);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.76rem;
  outline: none;
  transition: var(--transition);
}

.search-input-header:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px hsla(199, 89%, 48%, 0.3);
}

.search-icon-header {
  position: absolute;
  left: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* 資源類型選單與單元分類選單 (互相對應) */
.type-select-wrapper, .category-select-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.type-select {
  background: hsla(199, 89%, 48%, 0.15);
  border: 1px solid var(--border-glow);
  color: var(--primary);
}

.category-select {
  background: hsla(217, 33%, 18%, 0.85);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.type-select, .category-select {
  appearance: none;
  -webkit-appearance: none;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.32rem 1.5rem 0.32rem 0.55rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  outline: none;
  white-space: nowrap;
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.type-select:hover, .category-select:hover {
  border-color: var(--primary);
}

.select-arrow {
  position: absolute;
  right: 0.45rem;
  pointer-events: none;
  font-size: 0.65rem;
  color: var(--primary);
}

/* 新增資源下拉選單按鈕 */
.dropdown-menu-wrapper {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}

.dropdown-menu {
  position: absolute;
  top: 115%;
  left: 0;
  background: var(--bg-dark);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 25px rgba(0,0,0,0.6);
  min-width: 170px;
  display: none;
  flex-direction: column;
  z-index: 200;
  overflow: hidden;
}

.dropdown-menu.active {
  display: flex;
}

.dropdown-item {
  padding: 0.5rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-main);
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition);
  width: 100%;
}

.dropdown-item:hover {
  background: hsla(199, 89%, 48%, 0.25);
  color: #fff;
}

.counter-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: hsla(217, 33%, 14%, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-left: 0;
  vertical-align: middle;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.32rem 0.5rem;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), hsl(199, 89%, 40%));
  color: #fff;
  box-shadow: 0 4px 14px hsla(199, 89%, 48%, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover), var(--primary));
  transform: translateY(-2px);
  box-shadow: 0 6px 20px hsla(199, 89%, 48%, 0.5);
}

.btn-secondary {
  background: hsla(217, 33%, 20%, 0.7);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: hsla(217, 33%, 28%, 0.9);
  border-color: var(--border-glow);
  transform: translateY(-2px);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), hsl(160, 84%, 30%));
  color: #fff;
}

.btn-accent:hover {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
  transform: translateY(-2px);
}

.btn-purple {
  background: linear-gradient(135deg, var(--type-ai), hsl(270, 85%, 45%));
  color: #fff;
}

.btn-orange {
  background: linear-gradient(135deg, var(--type-tool), hsl(32, 95%, 40%));
  color: #fff;
}

.btn-danger {
  background: hsla(346, 84%, 61%, 0.2);
  color: var(--danger);
  border: 1px solid hsla(346, 84%, 61%, 0.4);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-warning {
  background: linear-gradient(135deg, var(--warning), hsl(38, 92%, 40%));
  color: #fff;
  box-shadow: 0 4px 14px hsla(38, 92%, 50%, 0.3);
}

.btn-warning:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px hsla(38, 92%, 50%, 0.5);
}

/* 3. 主內容區容器 */
.main-layout {
  width: 100%;
  max-width: var(--layout-max-width);
  margin: 1.5rem auto;
  padding: 0;
  flex: 1;
}

.deck-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  width: 100%;
}

@media (max-width: 1024px) {
  .deck-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .deck-grid {
    grid-template-columns: 1fr;
  }
}

.deck-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  width: 100%;
}

.deck-card.protected-card {
  border-color: hsla(38, 92%, 50%, 0.4);
}

.deck-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0;
  transition: var(--transition);
}

.deck-card[data-type="article"]::before {
  background: linear-gradient(90deg, var(--type-article), #6ee7b7);
}

.deck-card[data-type="ai"]::before {
  background: linear-gradient(90deg, var(--type-ai), #c084fc);
}

.deck-card[data-type="tool"]::before {
  background: linear-gradient(90deg, var(--type-tool), #fbbf24);
}

.deck-card.protected-card::before {
  background: linear-gradient(90deg, var(--warning), var(--danger));
}

.deck-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-glow);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.deck-card:hover::before {
  opacity: 1;
}

.deck-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.type-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
}

.type-badge.type-deck {
  background: hsla(199, 89%, 48%, 0.15);
  color: var(--type-deck);
  border: 1px solid hsla(199, 89%, 48%, 0.3);
}

.type-badge.type-article {
  background: hsla(160, 84%, 39%, 0.15);
  color: #6ee7b7;
  border: 1px solid hsla(160, 84%, 39%, 0.3);
}

.type-badge.type-ai {
  background: hsla(270, 85%, 60%, 0.15);
  color: #c084fc;
  border: 1px solid hsla(270, 85%, 60%, 0.3);
}

.type-badge.type-tool {
  background: hsla(32, 95%, 53%, 0.15);
  color: #fbbf24;
  border: 1px solid hsla(32, 95%, 53%, 0.3);
}

.deck-category {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.lock-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
  background: hsla(38, 92%, 50%, 0.15);
  color: var(--warning);
  border: 1px solid hsla(38, 92%, 50%, 0.3);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.deck-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.deck-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  line-height: 1.4;
  color: var(--text-main);
}

.deck-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.deck-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  border-top: 1px solid hsla(217, 33%, 25%, 0.3);
}

.card-actions {
  display: flex;
  gap: 0.4rem;
}

/* 4. 網頁底部 (Footer) */
.app-footer {
  margin-top: auto;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  padding: 1.75rem 1.25rem;
  text-align: center;
  width: 100%;
}

.footer-container {
  max-width: var(--layout-max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.footer-copy {
  font-size: 0.9rem;
  color: var(--text-muted);
  letter-spacing: 0.2px;
}

.footer-motto {
  font-size: 0.95rem;
  font-weight: 600;
  color: #6ee7b7;
  letter-spacing: 0.3px;
  margin-top: 0.2rem;
  text-shadow: 0 0 10px hsla(160, 84%, 39%, 0.3);
}

/* Modal 播放器與驗證 */
.viewer-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #000;
  display: none;
  flex-direction: column;
}

.viewer-modal.active {
  display: flex;
}

.viewer-header {
  height: 50px;
  background: hsla(222, 47%, 10%, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
}

.viewer-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-frame {
  flex: 1;
  width: 100%;
  height: calc(100vh - 50px);
  border: none;
  background: #fff;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

.modal-content-small {
  max-width: 440px;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: hsla(217, 33%, 12%, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--primary);
}

.form-textarea {
  min-height: 200px;
  font-family: monospace;
  font-size: 0.85rem;
  line-height: 1.4;
  white-space: pre;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: hsla(217, 33%, 10%, 0.5);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--primary);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  font-size: 0.9rem;
  white-space: nowrap;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
