/* ==================== 全域導覽列與使用者區 ==================== */
:root{
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #667eea;
  --primary-600: #5568d3;
  --ring: rgba(102,126,234,.28);
  --shadow-sm: 0 2px 10px rgba(0,0,0,.08);
  --shadow-md: 0 8px 24px rgba(0,0,0,.12);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
}

*{ -webkit-tap-highlight-color: transparent; }

/* 更一致的 focus 樣式（鍵盤操作更清楚） */
:where(a, button, input, select, textarea, [role="button"]):focus-visible{
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
  border-color: var(--primary);
}

.navbar {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 1000 !important;
  background: white !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
  padding: 15px 30px !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
}

/* 導覽列內搜尋（與下方「目前展覽」對齊置中） */
.navbar-with-search {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 24px;
}
.navbar-with-search .navbar-center {
  flex: 1;
}
.navbar-center {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
}
.navbar-search {
  width: 100%;
  max-width: 460px;
  display: flex !important;
  align-items: center !important;
  gap: 8px;
}
/* 左側 spacer 與按鈕同寬，讓搜尋框本身對齊頁面中央 */
.navbar-search .search-btn-spacer {
  flex: 0 0 auto;
  width: 70px;
}
.navbar-search .search-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.navbar-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #888;
  pointer-events: none;
  z-index: 1;
}
.navbar-search .search-icon svg {
  display: block;
}
.navbar-search input {
  flex: 1;
  width: 100%;
  height: 36px;
  padding: 0 14px 0 36px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  box-sizing: border-box;
  text-align: left;
}
.navbar-search input::placeholder {
  text-align: left;
}
.navbar-search input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}
.navbar-search button {
  flex: 0 0 auto;
  min-width: 70px;
  height: 36px;
  padding: 0 18px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-sizing: border-box;
}
.navbar-search button:hover {
  background: #5568d3;
}

/* Logo 品牌區 */
.navbar-brand {
  font-size: 20px;
  font-weight: 600;
  color: #333;
}

.navbar-brand a {
  text-decoration: none;
  color: inherit;
  display: inline-block;
}

.navbar-brand img {
  height: 40px !important;
  vertical-align: middle !important;
}

/* 使用者操作區（登入/註冊/設定） */
.navbar-user {
  display: flex !important;
  align-items: center !important;
  gap: 20px;
}

.navbar-mobile-actions,
.mobile-search-panel,
.mobile-menu-overlay,
.mobile-menu-panel{
  display: none;
}

.mobile-icon-btn{
  appearance: none;
  border: 1px solid rgba(15,23,42,.12);
  background: #f3f4f6;
  color: #111827;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
}

/* ==================== 全站內容頂部留白（避免各頁不一致） ==================== */
/* 很多頁面各自定義 .container padding-top，會造成「導覽列下方空隙」不一致；
   這裡用全域規則統一，讓所有頁面（含首頁）視覺一致。 */
.container{
  padding-top: 100px !important;
}

/* 使用者信箱顯示 */
.user-email {
  color: #666;
  font-size: 14px;
}

/* 導覽連結按鈕 */
.nav-link {
  background: #667eea;
  color: white;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 6px;
  transition: all 0.3s;
  box-shadow: 0 2px 4px rgba(102, 126, 234, 0.2);
}

.nav-link:hover {
  background: #5568d3;
  box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
  transform: translateY(-1px);
}

/* ==================== 通用按鈕 ==================== */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.3s;
  display: inline-block;
}

.btn-primary {
  background: #667eea;
  color: white;
}

.btn-primary:hover {
  background: #5568d3;
}

.btn-secondary {
  background: #95a5a6;
  color: white;
}

.btn-secondary:hover {
  background: #7f8c8d;
}

/* ==================== 通用表單控件 ==================== */
input[type="text"],
input[type="search"],
input[type="url"],
input[type="date"],
input[type="number"],
select,
textarea{
  border: 1px solid var(--border);
  border-radius: 10px;
}

/* ==================== Chip / 篩選膠囊 ==================== */
.chips{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  justify-content:center;
}
.chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 14px;
  border-radius:999px;
  text-decoration:none;
  font-size:14px;
  font-weight:600;
  color:#4c51bf;
  background:#eef2ff;
  border:1px solid rgba(102,126,234,.18);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, color .15s ease;
  user-select:none;
}
.chip:hover{
  background:#c7d2fe;
  color:#4338ca;
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(67,56,202,.12);
}
.chip--active{
  background: var(--primary);
  color:#fff;
  border-color: rgba(255,255,255,.25);
  box-shadow: 0 10px 22px rgba(102,126,234,.22);
}

/* ==================== 列表篩選列 ==================== */
.filters-bar{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  justify-content:center;
  align-items:center;
  margin: -10px 0 24px;
}
.filters-form{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  justify-content:center;
  align-items:center;
}
.filters-label{
  font-size:13px;
  color: var(--muted);
  font-weight:700;
}
.filters-select{
  height: 36px;
  padding: 0 12px;
  font-size: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

/* ==================== 訊息提示 ==================== */
.flash-messages {
  margin-bottom: 20px;
}

.flash-message {
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 10px;
}

.flash-success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.flash-error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.flash-info {
  background: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

/* ==================== 響應式導覽列 ==================== */
@media (max-width: 768px) {
  /* 手機：改成 FB 風格上方橫列（logo + icon） */
  .navbar {
    padding: 8px 12px !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px;
    /* 手機改用 sticky：不遮住內容 */
    position: sticky !important;
    top: 0;
  }

  .container{
    padding-top: 16px !important;
  }

  .navbar-with-search { display: flex !important; }

  .navbar-brand {
    display: flex;
    justify-content: flex-start !important;
    align-items: center;
    width: auto !important;
  }

  .navbar-brand img {
    height: 32px !important;
  }

  .navbar-mobile-actions{
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .navbar-center{ display: none !important; }

  .navbar-user {
    display: none !important;
  }

  /* 手機上隱藏返回類按鈕（使用手機系統返回手勢） */
  .back-link,
  .btn-back,
  .btn-quiet {
    display: none !important;
  }

  .mobile-search-panel{
    display: none;
    position: absolute;
    left: 10px;
    right: 10px;
    top: calc(100% + 8px);
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 12px 24px rgba(15,23,42,.16);
    z-index: 1100;
  }
  .mobile-search-panel.is-open{ display: block; }
  .mobile-search-form{
    display: flex;
    gap: 8px;
    align-items: center;
  }
  .mobile-search-form input{
    flex: 1;
    height: 36px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 0 12px;
  }
  .mobile-search-form button{
    height: 36px;
    border: none;
    border-radius: 8px;
    background: #667eea;
    color: #fff;
    padding: 0 12px;
    font-weight: 600;
  }

  .mobile-menu-overlay{
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.38);
    z-index: 1200;
  }
  .mobile-menu-overlay.is-open{ display: block; }

  .mobile-menu-panel{
    display: block;
    position: fixed;
    top: 0;
    right: 0;
    width: min(82vw, 320px);
    height: 100vh;
    background: #fff;
    box-shadow: -12px 0 28px rgba(0,0,0,.18);
    transform: translateX(100%);
    transition: transform .22s ease;
    z-index: 1210;
  }
  .mobile-menu-panel.is-open{ transform: translateX(0); }

  .mobile-menu-head{
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 14px;
    border-bottom: 1px solid #e5e7eb;
  }
  .mobile-menu-close{
    border: none;
    background: #f3f4f6;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
  }
  .mobile-menu-body{
    padding: 10px 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .mobile-menu-link{
    text-decoration: none;
    color: #1f2937;
    padding: 10px 12px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    font-weight: 600;
  }
  .mobile-menu-link:hover{ background: #eef2ff; }
  .mobile-menu-lang{
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid #e5e7eb;
  }
  body.mobile-menu-open{
    overflow: hidden;
  }
}

@media (max-width: 480px) {
  .navbar {
    padding: 6px 10px !important;
    position: sticky !important;
    top: 0;
  }

  .container{
    padding-top: 14px !important;
  }

  .navbar-brand img {
    height: 28px !important;
  }

  /* 超小螢幕直接隱藏 email，只保留按鈕與圖示 */
  .user-email {
    display: none !important;
  }

  .navbar-brand { justify-content: flex-start !important; }
}

/* ==================== 社群風三欄殼（類臉書） ==================== */
.app-shell{
  --side-w: 260px;
  --rail-w: 320px;
  --main-w: 760px; /* 中間資訊流最大寬（類 FB） */
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, var(--main-w)) var(--rail-w);
  gap: 18px;
  align-items: start;
  width: 100%;
  justify-content: space-between; /* 左右貼邊，中間保持固定最大寬 */
}

.app-shell__side{
  position: sticky;
  top: 88px; /* navbar 高度附近 */
  max-height: calc(100vh - 100px);
  overflow: auto;
  padding-right: 4px;
}

.app-shell__main{
  min-width: 0;
}

.feed{
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* 首頁 ICON 快捷列（類 FB 上方 ICON 導覽） */
.icon-nav{
  display:flex;
  justify-content:center;
  align-items:center;
  gap: 16px;
  padding: 8px 0 4px;
}
.icon-nav__btn{
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: none;
  background: transparent;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 22px;
  cursor:pointer;
  text-decoration:none;
  color: #4b5563;
  position: relative;
  transition: background .15s ease, transform .15s ease, color .15s ease;
}
.icon-nav__btn:hover{
  background: rgba(15,23,42,.06);
  transform: translateY(-1px);
}
.icon-nav__btn.is-active{
  background: rgba(102,126,234,.18);
  color: #1f2937;
}
.icon-nav__btn span{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}

/* 左側：階層式捷徑 */
.side-nav{
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 6px 4px;
}
.side-nav__section + .side-nav__section{
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.side-nav__title{
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  margin: 6px 10px 8px;
  display:flex;
  align-items:center;
  justify-content: space-between;
}
.side-nav__title--summary{
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.side-nav__title--summary::-webkit-details-marker{ display:none; }
.side-nav__chev{ opacity:.65; font-size: 12px; }

.side-nav__item{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 14px;
  text-decoration:none;
  color: var(--text);
  transition: background .12s ease, transform .12s ease;
}
.side-nav__item:hover{
  background: rgba(15,23,42,.055);
  transform: translateY(-1px);
}
.side-nav__item.is-active{
  background: rgba(102,126,234,.14);
}
.side-nav__icon{
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(15,23,42,.05);
  display:flex;
  justify-content:center;
  align-items:center;
  opacity: .95;
}
.side-nav__label{
  font-weight: 750;
  font-size: 15px;
}

/* FB 風：側欄更像「捷徑清單」的外框 */
.app-shell__side--left{
  padding-top: 4px;
}

/* 右側：資訊欄 */
.right-rail{
  display:flex;
  flex-direction: column;
  gap: 12px;
}
.rail-card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 14px 14px;
}
.rail-card__title{
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 10px;
}
.rail-list{
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}
.rail-list__item + .rail-list__item{ margin-top: 6px; }
.rail-muted{ color: var(--muted); font-size: 13px; }
.rail-actions{
  display:flex;
  flex-direction: column;
  gap: 8px;
}
.rail-link{
  text-decoration:none;
  color: var(--primary-600);
  font-weight: 700;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(102,126,234,.08);
  border: 1px solid rgba(102,126,234,.18);
}
.rail-link:hover{
  background: rgba(102,126,234,.14);
}
.rail-chips{
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip--soft{
  background: rgba(102,126,234,.08);
  color: #4338ca;
  border: 1px solid rgba(102,126,234,.16);
  font-weight: 700;
}

/* 主欄：貼文卡 */
.post-card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.post-card__header{
  display:flex;
  align-items:flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 10px;
}
.post-card__title{
  font-weight: 800;
  font-size: 16px;
  color: var(--text);
  margin: 0;
}
.post-card__meta{
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
}
.post-card__body{
  padding: 0 16px 14px;
  color: var(--text);
}
.post-card__actions{
  display:flex;
  gap: 10px;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border);
}
.btn-quiet{
  background: rgba(15,23,42,.04);
  color: var(--text);
  border: 1px solid rgba(15,23,42,.08);
}
.btn-quiet:hover{ background: rgba(15,23,42,.06); }

/* 右上角「⋯」更多（純樣式，JS 由各頁需要時加） */
.kebab{
  appearance: none;
  border: 1px solid rgba(15,23,42,.18);
  background: #ffffff;
  color: #111827;
  border-radius: 999px;
  width: 34px;
  height: 34px;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  box-shadow: 0 6px 14px rgba(15,23,42,.18);
}
.kebab:hover{
  background: #f8fafc;
  border-color: rgba(15,23,42,.28);
}

.photo-menu{
  position:absolute;
  top:10px;
  right:10px;
  z-index:10;
}
.photo-menu-panel{
  position:absolute;
  top:40px;
  right:0;
  min-width:160px;
  background:#fff;
  border-radius:10px;
  box-shadow:0 10px 25px rgba(15,23,42,.18);
  padding:6px 0;
  display:none;
}
.photo-menu-item{
  width:100%;
  padding:8px 14px;
  border:none;
  background:transparent;
  text-align:left;
  font-size:13px;
  cursor:pointer;
}
.photo-menu-item:hover{
  background:rgba(15,23,42,.04);
}
.photo-menu-item-danger{
  color:#b91c1c;
}

/* RWD：平板改雙欄；手機單欄 */
@media (max-width: 992px){
  .app-shell{
    grid-template-columns: var(--side-w) minmax(0, 1fr);
    justify-content: start;
  }
  .app-shell__side--right{ display:none; }
}
@media (max-width: 768px){
  .app-shell{
    grid-template-columns: 1fr;
    justify-content: start;
  }
  .app-shell__side--left{ display:none; }
  .app-shell__side{ position: static; max-height: none; }
}

