/* assets/css/components.css */
/* 負責：獨立元件樣式 (按鈕、卡片、標籤、搜尋框、Tabs) */

/* --- 搜尋框 (Search Input) --- */
#search-input { 
  flex: 1; 
  padding: 12px 16px; 
  font-size: 16px; 
  border: 2px solid #cbd5e1; 
  border-radius: 12px; 
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); 
  transition: border-color 0.2s, box-shadow 0.2s; 
  width: 100%; 
  box-sizing: border-box;
}
#search-input:focus { 
  border-color: var(--brand); 
  box-shadow: 0 0 0 4px var(--ring); 
}

/* --- 工具列按鈕 (Tool Buttons) --- */
.tool-btn, .filter-toggle-btn, .map-toggle-btn { 
  padding: 10px 18px; 
  font-size: 15px; 
  border-radius: 12px; 
  font-weight: 600; 
  cursor: pointer; 
  transition: all 0.2s; 
  border: 2px solid #cbd5e1; 
  background: #fff; 
  color: #475569; 
  white-space: nowrap; 
  display: inline-flex; 
  align-items: center; 
  justify-content: center;
}
.tool-btn:hover, .filter-toggle-btn:hover { 
  background: #f1f5f9; 
  transform: translateY(-1px); 
}
.map-toggle-btn { 
  color: var(--brand); 
  border-color: var(--brand); 
}
.map-toggle-btn.active { 
  background: var(--brand); 
  color: #fff; 
  box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3); 
}

/* --- 篩選 Tabs --- */
.tabs-container { 
  margin: 12px 0; 
  overflow-x: auto; 
  scrollbar-width: none; 
}
.tabs-container::-webkit-scrollbar { display: none; }

.tabs { 
  display: flex; 
  gap: 8px; 
  padding-bottom: 4px; 
}
.tabs label { 
  -webkit-user-select: none; 
  user-select: none; 
  cursor: pointer; 
  font-size: 14px; 
  color: #065f46; 
  border: 1px solid #d1fae5; 
  background: #ecfdf5; 
  padding: 8px 16px; 
  border-radius: 99px; 
  transition: all .2s; 
  white-space: nowrap; 
  font-weight: 500; 
  display: inline-flex; 
  align-items: center; 
  gap: 4px; 
}
.tabs-input { position: absolute; opacity: 0; }
.tabs-input:checked + label { 
  background: var(--brand); 
  color: #fff; 
  border-color: var(--brand); 
  box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3); 
  transform: scale(1.05); 
}

.category-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin: 12px 0 6px 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.category-header::before {
  content: '';
  display: block;
  width: 4px;
  height: 14px;
  background: var(--brand);
  border-radius: 2px;
}

/* --- 篩選面板開關動畫 --- */
.filter-panel {
  max-height: 1000px; 
  opacity: 1;
  overflow: hidden;
  transition: max-height 0.4s ease-in-out, opacity 0.3s ease-in-out, margin 0.3s ease;
  margin-top: 10px;
}
.filter-panel.collapsed {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  pointer-events: none; 
}

/* ==========================================================================
   Modern Vertical Card (新版沉浸式卡片樣式)
   ========================================================================== */

.card { 
    display: flex; 
    flex-direction: column; /* 改為直式排列 */
    padding: 0; /* 移除內距，讓圖片滿版 */
    gap: 0;
    overflow: hidden;
    background: var(--panel-card); 
    border: 1px solid var(--border); 
    border-radius: 16px; 
    box-shadow: var(--shadow); 
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); 
    position: relative; 
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    cursor: pointer;
}
.card:hover { 
  transform: translateY(-4px); 
  box-shadow: 0 12px 20px -5px rgba(0, 0, 0, 0.1); 
  border-color: var(--brand); 
}
.card.hidden, .card.expired-hidden { display: none !important; }

/* 上方圖片區塊 */
.card-cover {
  position: relative;
  width: 100%;
  height: 200px; /* 固定高度，確保版面整齊 */
  background: #f1f5f9;
  overflow: hidden;
}

.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
  transition: transform 0.5s ease;
}

.card-cover:hover img {
  transform: scale(1.05); /* 滑鼠移過去圖片微放大 */
}

/* 浮動標籤 (日期/評分) - 絕對定位在左上角 */
.float-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 4px 8px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  font-weight: 700;
  line-height: 1.1;
  z-index: 2;
  pointer-events: none;
}

.date-badge .fb-month { font-size: 10px; color: #ef4444; text-transform: uppercase; }
.date-badge .fb-day { font-size: 18px; color: #1e293b; }

.rating-badge { flex-direction: row; gap: 2px; background: #fffbeb; color: #b45309; border: 1px solid #fcd34d; }
.spot-badge { background: #eff6ff; border: 1px solid #bfdbfe; font-size: 18px; }

/* 浮動收藏按鈕 - 絕對定位在右上角 */
.card-fav-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.8);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  z-index: 2;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  color: #cbd5e1;
}
.card-fav-btn:hover { transform: scale(1.1); background: #fff; }
.card-fav-btn.active { background: #fff; color: #db2777; text-shadow: 0 2px 4px rgba(219, 39, 119, 0.2); }

/* 下方內容區塊 */
.card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card-top-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
}

.region-pill {
  background: #f1f5f9;
  color: #475569;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.dist-pill {
  color: #059669;
  font-weight: 500;
  background: #ecfdf5;
  padding: 2px 6px;
  border-radius: 4px;
}

/* 狀態標籤美化 */
.status-tag { padding: 2px 6px; border-radius: 4px; font-weight: bold; font-size: 11px; }
.status-tag.running { background: #fff1f2; color: #e11d48; border: 1px solid #fecdd3; }
.status-tag.soon { background: #f0f9ff; color: #0284c7; }
.status-tag.today { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.status-tag.closed { background: #f3f4f6; color: #9ca3af; }
.status-tag.reg { background: #e0e7ff; color: #4338ca; }
.status-tag.fee { background: #ffedd5; color: #c2410c; }

.card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.4;
  margin: 2px 0;
  /* 限制兩行 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-info {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.info-row {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.info-row.price { color: #d97706; font-weight: 500; }

.card-tags {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  height: 28px; /* 固定高度 */
  overflow: hidden;
}
.tag { 
  font-size: 11px; 
  padding: 2px 8px; 
  border-radius: 99px; 
  background: #f1f5f9; 
  border: 1px solid #cbd5e1; 
  color: #475569; 
  margin: 0;
  font-weight: 500; 
}
/* Tag 顏色定義 */
.tag[data-cat*="市集"], .tag[data-cat*="美食"] { background: #fff7ed; color: #c2410c; border-color: #fdba74; }
.tag[data-cat*="親子"] { background: #fdf2f8; color: #be185d; border-color: #f9a8d4; }
.tag[data-cat*="展覽"] { background: #eff6ff; color: #1d4ed8; border-color: #93c5fd; }
.tag[data-cat*="戶外"] { background: #f0f9ff; color: #0369a1; border-color: #7dd3fc; }

/* 底部按鈕區 */
.card-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.main-actions { display: flex; gap: 8px; }
.sub-actions { display: flex; gap: 4px; }

.action-btn { 
  background: #f8fafc; 
  color: #64748b; 
  border: 1px solid #e2e8f0; 
  border-radius: 8px; 
  padding: 6px 12px; 
  font-size: 13px; 
  font-weight: 600; 
  cursor: pointer; 
  transition: all .2s; 
  text-decoration: none; 
  display: inline-flex; 
  align-items: center; 
  gap: 4px; 
  line-height: normal; 
}
.action-btn:hover { background: #f1f5f9; color: var(--ink); border-color: #cbd5e1; transform: translateY(-1px); }
.btn-fb { background: #1877f2; color: #fff; border-color: #1877f2; }
.btn-ig { background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%); color: #fff; border: none; }
.btn-form { background: #10b981; color: #fff; border-color: #10b981; }

.icon-btn {
  background: #fff;
  border: 1px solid #e2e8f0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #64748b;
  font-size: 14px;
  transition: all 0.2s;
  text-decoration: none;
}
.icon-btn:hover { background: #f8fafc; color: #0f172a; border-color: #cbd5e1; }
.btn-line-icon { background: #06c755; color: #fff; border-color: #06c755; font-weight: bold; }

/* 卡片進場動畫 */
@keyframes slideUpFade { 
  from { opacity: 0; transform: translateY(30px); } 
  to { opacity: 1; transform: translateY(0); } 
}
.card:not(.skeleton-card) { 
  opacity: 0; 
  animation: slideUpFade 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) forwards; 
}

/* --- 浮動按鈕 (FAB) --- */
.fab-random { 
    position: fixed; 
    bottom: 115px; 
    right: 16px; 
    background: var(--brand); 
    color: white; 
    border: none; 
    border-radius: 50px; 
    padding: 12px 20px; 
    font-size: 15px; 
    font-weight: 700; 
    box-shadow: 0 4px 15px rgba(20, 184, 166, 0.5); 
    z-index: 20002; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    transition: all 0.2s; 
    animation: float 3s ease-in-out infinite; 
}
.fab-random:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(20, 184, 166, 0.6); }
.fab-random:active { transform: scale(0.95); }
@keyframes float { 
  0% { transform: translateY(0px); } 
  50% { transform: translateY(-5px); } 
  100% { transform: translateY(0px); } 
}

.reset { position: fixed; right: 16px; bottom: 170px; z-index: 9998; }
#reset-filters-label { 
  background: var(--brand); 
  color: #fff; 
  border: none; 
  border-radius: 999px; 
  padding: 10px 12px; 
  font-size: 13px; 
  cursor: pointer; 
  box-shadow: 0 10px 24px #14b8a647; 
}

/* --- Dark Mode 元件調整 --- */
html[data-theme="dark"] .card { background: var(--panel-card); border-color: #334155; }
html[data-theme="dark"] .card-cover { background: #334155; }
html[data-theme="dark"] .tool-btn, 
html[data-theme="dark"] .filter-toggle-btn, 
html[data-theme="dark"] .map-toggle-btn { background: #134e4a; color: #a7f3d0; border-color: #0f766e; }
html[data-theme="dark"] .pill { background: #164e63; color: #67e8f9; border-color: #083344; }
html[data-theme="dark"] .tag { background: #064e3b; color: #a7f3d0; border-color: #052e16; }
html[data-theme="dark"] .float-badge { background: rgba(30, 41, 59, 0.95); color: #fff; }
html[data-theme="dark"] .date-badge .fb-day { color: #f1f5f9; }
html[data-theme="dark"] .rating-badge { background: #451a03; border-color: #78350f; color: #fcd34d; }
html[data-theme="dark"] .region-pill { background: #334155; color: #cbd5e1; }
html[data-theme="dark"] .icon-btn { background: #1e293b; border-color: #334155; color: #94a3b8; }
html[data-theme="dark"] .action-btn { background: #1e293b; border-color: #334155; color: #94a3b8; }
html[data-theme="dark"] .card-footer { border-color: #334155; }