@charset "UTF-8";

:root {
  /* --- 🎨 主題配色設定 (保留您的原設定) --- */
  --primary: #00b3f5;        
  --primary-hover: #2563eb;  
  --accent: #10b981;         
  --danger: #ef4444;         
  
  /* --- 背景色系 --- */
  --bg-body: #0f172a;        
  --bg-panel: #1e293b;       
  --bg-input: #334155;       
  --border: #475569;         
  
  /* --- 文字顏色 --- */
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;

  /* Header 專用藍色 (保留您的原設定) */
  --header-blue: #0094e0; 
  
  /* ★ 修改：將此顏色改為「橘紅色」以符合您的需求 ★ */
  --fav-color: #f03875; 
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", Arial, sans-serif;
  background: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
}

/* --- 1. Header (保留您的漸層設定) --- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;       
  
  /* 使用 min-height 與 height 雙重鎖定 */
  height: 70px;          
  min-height: 70px;      
  box-sizing: border-box; /* 確保 padding 不會撐大高度 */
  
  background: linear-gradient(to right, #137dea, #00aae9);
  backdrop-filter: blur(12px); 
  border-bottom: 2px solid var(--primary); 
  position: sticky;
  top: 0;
  z-index: 1000; /* 提高層級確保不會被遮擋 */
  box-shadow: 0 4px 8px rgba(37, 45, 116, 0.2);
}

/* 確保 Brand 內的 SVG 和文字不會縮得太小 */
.brand { 
  flex-shrink: 0; /* 禁止縮小 */
  height: 100%;   /* 撐滿 Header 高度 */
  display: flex;
  align-items: center;
}

/* --- Buttons --- */
.btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px; /* 一般按鈕保持微圓角 */
  text-decoration: none;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  
  /* ★ 新增：強制不換行，解決按鈕破版問題 ★ */
  white-space: nowrap;
}
.btn:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn:disabled { background: var(--border); cursor: not-allowed; transform: none; }

.btn.secondary { background: var(--bg-input); color: var(--text-main); }
.btn.secondary:hover { background: var(--border); }

/* --- ★ 新增：只顯示我的最愛按鈕樣式 ★ --- */
/* 針對 Toolbar 中的按鈕進行圓角特化，使其與搜尋框風格一致 */
#favToggle {
  border-radius: 50px;
  padding: 8px 20px;
  font-size: 14px;
}

/* 滑鼠移上去 (Hover)：文字變橘紅色 */
#favToggle:hover {
    color: var(--fav-color);
    background: rgba(255, 255, 255, 0.1); /* 微微白底 */
}
/* 啟用狀態 (Active)：實心橘紅背景 */
#favToggle:not(.secondary) {
    background: var(--fav-color) !important;
    color: #fff !important;
    box-shadow: 0 0 10px rgba(255, 87, 34, 0.4);
    border-color: var(--fav-color) !important;
}

/* --- 2. Toolbar (美化版：參考 style.css 設計語言) --- */
.toolbar {
  display: flex; 
  flex-wrap: wrap; 
  gap: 16px;
  align-items: center;
  padding: 20px 24px; /* 增加間距，提升呼吸感 */
  border-bottom: 1px solid var(--border);
  background: var(--bg-body);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search {
  flex: 1; 
  min-width: 250px; 
  position: relative;
}

/* --- 美化後的搜尋框 --- */
.search input {
  width: 100%;
  padding: 12px 20px 12px 48px; /* 左側留白給搜尋圖示 */
  border-radius: 50px; /* 改為圓潤的膠囊造型 */
  border: 1px solid var(--border);
  background-color: var(--bg-input);
  color: var(--text-main);
  outline: none;
  font-size: 15px;
  line-height: 1.5;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* 使用 CSS 注入 SVG 搜尋圖示 */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 18px center; 
}
.search input:hover {
  border-color: var(--text-muted);
  background-color: rgba(255, 255, 255, 0.05);
}
.search input:focus {
  border-color: var(--primary);
  background-color: var(--bg-panel);
  /* 聚焦光暈效果 */
  box-shadow: 0 0 0 4px rgba(0, 179, 245, 0.2), 0 0 15px rgba(0, 179, 245, 0.1); 
  /* 聚焦時圖示變色 */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2300b3f5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
}

/* --- Filter Tags 標籤優化 --- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-tag {
  padding: 6px 16px;
  border-radius: 50px; /* 膠囊造型 */
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}
.filter-tag:hover { 
  color: var(--text-main);
  border-color: var(--primary);
  background: rgba(0, 179, 245, 0.05);
}
.filter-tag.active { 
  background: var(--primary); 
  border-color: var(--primary); 
  color: #fff; 
  box-shadow: 0 4px 12px rgba(0, 179, 245, 0.3);
}

.sorts {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-left: auto; 
}

/* --- 下拉選單 (Select) 美化 --- */
.sorts select {
  width: 100%;
  padding: 10px 36px 10px 16px; /* 右側留白給箭頭 */
  border-radius: 10px;
  border: 1px solid var(--border);
  background-color: var(--bg-input);
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  appearance: none; /* 隱藏原生箭頭 */
  -webkit-appearance: none;
  font-size: 14px;
  transition: all 0.2s;
  
  /* 自定義下拉箭頭 */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.sorts select:hover { border-color: var(--text-muted); }
.sorts select:focus { 
  border-color: var(--primary); 
  box-shadow: 0 0 0 3px rgba(0, 179, 245, 0.2); 
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2300b3f5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* --- Card Grid --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
  padding: 24px;
}

/* --- Card Component --- */
.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  color: var(--text-main);
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  --card-theme: var(--primary); 
}

.card:hover {
  border-color: var(--card-theme);
  transform: translateY(-4px);
  box-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--card-theme);
}

.card .cover {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.card .cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s;
}
.card:hover .cover img { transform: scale(1.05); }

.card .info { padding: 16px; flex: 1; display: flex; flex-direction: column; }
.card .title { font-size: 18px; font-weight: 700; margin-bottom: 8px; line-height: 1.3; }
.card .meta { font-size: 12px; color: var(--text-muted); display: flex; justify-content: space-between; margin-bottom: 12px; }

.card .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.tag {
  font-size: 11px;
  padding: 3px 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
}

.hover-preview {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.95);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  opacity: 0;
  transition: opacity 0.2s;
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 14px;
  line-height: 1.6;
}
.card:hover .hover-preview { opacity: 1; }

/* --- ★ 修改：卡片愛心樣式優化 ★ --- */
.fav {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%; /* 圓形 */
  
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255,255,255,0.2); /* 淡淡的白框 */
  color: rgba(255,255,255,0.8);
  
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: all 0.2s;
}
.fav svg { width: 18px; height: 18px; transition: all 0.2s; }

.fav:hover { background: rgba(0,0,0,0.8); color: #fff; transform: scale(1.1); }

/* 啟用狀態：變為橘紅色 */
.fav.active { background: var(--fav-color); color: #fff; border-color: var(--fav-color); }
.fav.active svg { fill: currentColor; } /* 變實心 */


/* --- Viewer --- */
.viewer { height: calc(100vh - 65px); background: #000; }
.iframe-wrap { height: 100%; width: 100%; }
.tool-frame { width: 100%; height: 100%; border: 0; background: #fff; }

.fullscreen .site-header { display: none; }
.fullscreen .tool-frame { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 9999; }
.fullscreen .viewer { height: 100vh; }

/* RWD */
@media (max-width: 900px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .sorts { margin-left: 0; width: 100%; justify-content: space-between; }
  .brand span { display: none; }
}
/* --- 3. Footer & Static Pages (修改：極簡單行版) --- */

/* 確保 Footer 置底 */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
main {
  flex: 1; 
}

/* 極簡單行頁尾 */
.site-footer {
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  padding: 10px 24px; /* 極小的內距 */
  font-size: 12px;
  color: var(--text-muted);
  
  /* Flex 佈局讓內容置中且在同一行 */
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px; /* 元素間的距離 */
  flex-wrap: wrap; /* 手機版如果太擠會自動換行，避免破版 */
}

.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.site-footer a:hover {
  color: var(--primary);
}

/* 分隔線樣式 (如果你想用 | 符號隔開) */
.footer-divider {
  opacity: 0.3;
  user-select: none;
}

/* 靜態頁面容器 (保持不變) */
.page-container {
  max-width: 800px;
  margin: 40px auto;
  padding: 0 24px;
}
.page-content {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  color: var(--text-main);
}
.page-content h1 {
  margin-top: 0;
  font-size: 24px;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 24px;
}
.page-content h2 { font-size: 18px; margin-top: 24px; color: var(--text-main); }
.page-content p { color: var(--text-muted); line-height: 1.8; margin-bottom: 16px; }
.page-content ul { color: var(--text-muted); line-height: 1.8; padding-left: 20px; }
.page-content li { margin-bottom: 8px; }

.sitemap-list { list-style: none; padding: 0 !important; }
.sitemap-list li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.sitemap-list li a { font-size: 16px; font-weight: 600; color: var(--text-main); text-decoration: none; display: block; }
.sitemap-list li a:hover { color: var(--primary); }
.sitemap-list li span { display: block; font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* --- 4. Theme Toggle & Light Mode (新增) --- */

/* 亮色模式變數覆蓋 (當 html 標籤有 data-theme="light" 時生效) */
[data-theme="light"] {
  --bg-body: #f8fafc;        /* 淺灰白背景 */
  --bg-panel: #ffffff;       /* 純白卡片背景 */
  --bg-input: #f1f5f9;       /* 淺灰輸入框 */
  --border: #cbd5e1;         /* 淺灰邊框 */
  
  --text-main: #0f172a;      /* 深藍黑文字 */
  --text-muted: #64748b;     /* 灰藍色次要文字 */
  
  /* 針對亮色模式微調陰影顏色，避免太髒 */
  --shadow-color: rgba(148, 163, 184, 0.2); 
}

/* 為了讓按鈕在右側不影響置中連結，我們對 Footer 做微調 */
.site-footer {
  position: relative; /* 為絕對定位做準備 */
}

/* 主題切換按鈕樣式 */
.theme-toggle-btn {
  position: absolute;
  right: 24px; /* 固定在右側 */
  top: 50%;
  transform: translateY(-50%);
  
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
}

.theme-toggle-btn:hover {
  background: var(--bg-input);
  color: var(--primary);
  border-color: var(--primary);
}

/* RWD: 手機版空間不足時，取消絕對定位，改為流式排列 */
@media (max-width: 600px) {
  .site-footer {
    flex-direction: column;
    gap: 12px;
    padding-bottom: 20px;
  }
  .theme-toggle-btn {
    position: static; /* 回復正常流 */
    transform: none;
    margin-top: 8px;
  }
}
/* =========================================
   ★ 補回遺失的 Admin 後台專用樣式
   ========================================= */

/* 1. 整體佈局：左側編輯 (彈性) + 右側預覽 (固定 320px) */
.admin-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  align-items: start; /* 確保右側 Sidebar 不會被拉長 */
}

/* RWD: 平板/手機版改為單欄垂直排列 */
@media (max-width: 900px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }
  /* 手機版隱藏右側預覽區的 Sticky 效果，改為在最下方顯示 */
  .preview-sticky {
    position: static !important;
    margin-top: 24px;
  }
}

/* 2. 區塊面板 (繼承新版變數) */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.panel h2 {
  margin-top: 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 20px;
  font-size: 18px;
  color: var(--text-main);
  font-weight: 700;
}

/* 3. 表單網格與欄位 */
.form-grid {
  display: grid;
  gap: 16px;
  /* 預設雙欄，可透過 HTML style 覆蓋 */
  grid-template-columns: 1fr 1fr;
}

/* 手機版強制表單變單欄，避免太擠 */
@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr !important; }
}

.form-row {
  display: grid;
  gap: 8px;
}

.form-row label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

/* 統一所有輸入框樣式 */
.form-row input[type="text"],
.form-row input[type="password"],
.form-row input[type="file"],
.form-row select,
.form-row textarea {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-main);
  width: 100%;
  outline: none;
  font-size: 14px;
  transition: all 0.2s;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 179, 245, 0.2); /* 配合您的藍色主題 */
}

/* 4. 右側預覽區懸浮定位 */
.preview-sticky {
  position: sticky;
  /* 配合 Header 高度 (65px) + 間距 (24px) */
  top: 89px; 
  z-index: 10;
}

.preview-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: block;
  text-align: center;
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* 5. 修正 CodeMirror 編輯器的高度與邊框 */
.CodeMirror {
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 300px;
  font-family: 'Fira Code', Consolas, monospace;
}

/* 針對小網（手機版）的特別調整 */
@media (max-width: 900px) {
  .site-header {
    height: 60px;      /* 手機版稍微收窄但仍保持足夠高度 */
    min-height: 60px;
    padding: 0 15px;
  }
  
  /* 隱藏過長的文字描述，避免撐開高度或導致排版破碎 */
.brand span { 
    display: inline-block; /* 恢復顯示 */
    font-size: 11px;       /* 字體變小 */
    opacity: 0.7;          /* 稍微透明一點 */
    max-width: 350px;      /* 限制最大寬度防止擠爆 */
    white-space: nowrap;   /* 強制不換行 */
    overflow: hidden;      /* 內容過長隱藏 */
    text-overflow: ellipsis; /* 顯示 ... */
  }
}

/* Logo 動畫容器 */
.mini-intro-container {
  position: relative;
  width: 40px; height: 40px;
  display: flex; justify-content: center; align-items: center;
  flex-shrink: 0;
}
.brand-text {
  font-size: 1.8rem !important; /* 加大文字 */
  font-weight: 800;
  color: #fff;
  margin-left: 4px;
}
.logo-badge { position: relative; z-index: 10; display: flex; }
.logo-fx { position: absolute; top: 58%; left: 50%; width: 0; height: 0; z-index: 9; }
.logo-ripple {
  position: absolute; top: 0; left: 0; width: 10px; height: 10px;
  background: #fbbf24; opacity: 0.6; border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
}
.logo-ray {
  position: absolute; top: 0; left: 0; width: 4px; margin-left: -2px;
  margin-top: -7px; height: 14px; background: #fbbf24; border-radius: 2px;
}
.logo-cursor {
  position: absolute;
  width: 18px;
  height: 18px;
  /* 填充改為白色，邊框改為您原本的品牌藍 */
  fill: #fff;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
}