/* css/style.css (完整版 - 包含個人/地圖擴充) */

/* --- 1. 新架構 (莫蘭迪) 基礎樣式 --- */
:root {
    --morandi-bg: #F0F3F4;       /* 柔和的背景色 (近白) */
    --morandi-primary: #6F9B94;  /* 主要藍綠色 (導覽列背景) */
    --morandi-secondary: #AEC9C1; /* 次要/點綴色 (懸停) */
    --morandi-text: #4A4A4A;     /* 主要文字顏色 (深灰) */
    --morandi-accent: #5A7D78;   /* 強調色 (目前分頁) */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background-color: var(--morandi-bg);
    color: var(--morandi-text);
    min-height: 1500px;
}

/* --- 2. 新架構 (莫蘭迪) 導覽列樣式 --- */
.navbar {
    position: sticky;
    top: 0;
    width: 100%;
    background-color: var(--morandi-primary);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px; 
}

.nav-tabs {
    display: flex;
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow-x: auto; 
    flex-shrink: 1; 
    min-width: 0; 
}

.tab-link {
    padding: 14px 20px;
    text-decoration: none;
    color: var(--morandi-bg);
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: block;
    white-space: nowrap;
}

.tab-link:hover {
    background-color: var(--morandi-secondary);
    color: var(--morandi-text);
}

.tab-link.active {
    background-color: var(--morandi-accent);
    color: white;
}

/* --- 3. 新架構 內容區塊樣式 --- */
.content-area {
    margin: 10px;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #ffffff;
    transition: opacity 0.3s ease-in-out;
}

/* --- 4. V5 移植樣式 (天氣, 新聞, 股票) --- */

.content-area h2 {
    color: initial;
    border-bottom: none;
    padding-bottom: 0;
    margin-top: initial;
}

.header {
  background:linear-gradient(135deg,#7ba8a3 0,#9dbfbb 100%);
  padding: 20px 32px;
  border-radius:24px;
  color:white;
  margin-bottom: 24px;
  box-shadow:0 8px 30px rgba(123,168,163,0.25);
}
.header-top {
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom: 0;
  gap:20px;
}
.greeting-section {
  font-weight:700;
  font-size: 24px;
  flex-shrink: 0;
  min-width: 250px;
}
.datetime {margin-top:6px; font-weight:500; font-size:14px; opacity:0.9;}
.location-selector {
  background:rgba(255 255 255 / 26%);
  border:2px solid rgba(255 255 255 / 38%);
  border-radius:10px;
  font-size:13px;
  color:white;
  padding: 5px 10px;
  cursor:pointer;
  backdrop-filter:blur(12px);
  transition:background 0.3s,border 0.3s;
  flex-shrink: 0;
}
.location-selector:hover, .location-selector:focus {
  background:rgba(255 255 255 / 34%);
  border-color:rgba(255 255 255 / 60%);
  outline:none;
}
.weather-forecast-horizontal {
  display:grid;
  gap: 8px;
  grid-template-columns:repeat(7,1fr);
  flex: 1;
  margin: 0 20px;
}
.weather-day-h {
  background:rgba(255 255 255 / 23%);
  border-radius:12px;
  padding: 10px 5px;
  border:2px solid rgba(255 255 255 / 12%);
  text-align:center;
  min-width: 0;
}
.weather-date-h {font-size:12px; font-weight:700; margin-bottom:4px;}
.weather-emoji-h {font-size:28px; margin-bottom:2px; display:block; user-select:none;}
.weather-temp-h {font-size:14px; font-weight:700;}
.weather-rain-h {font-size:11px; margin-top:2px; color:#def1f0aa; opacity: 0.9;}
.weather-desc-h {display: none;}
.weather-loading {
  grid-column:span 7;
  text-align:center;
  padding:22px 0;
  color:white;
  font-weight:700;
}

.info-section {
  display:flex;
  gap: 20px;
  flex-wrap:wrap;
  margin-bottom: 20px; 
}
.news-card {
  flex:1;
  min-width:400px;
  max-width:720px;
  background:white;
  border-radius:20px;
  box-shadow:0 8px 32px #a6b7b68e;
  padding: 16px 20px;
}
.section-header {
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:10px;
  flex-wrap:wrap;
  gap:10px;
}
.section-title {
  display:flex;
  gap:8px;
  font-weight:700;
  font-size: 18px;
  color:#578f89;
  align-items:center;
}
.section-icon {
  background:linear-gradient(135deg,#7ba8a3,#9dbfbb);
  border-radius:8px;
  color:white;
  width: 28px;
  height: 28px;
  display:grid;
  place-items:center;
  font-weight:900;
  font-size: 15px;
}
.news-tabs { display:flex; gap: 8px; }
.news-tab {
  border-radius:10px;
  background:#f3fbfb;
  color:#578f89;
  font-weight:600;
  font-size: 13px;
  padding: 5px 14px;
  border:2px solid #cee2df;
  cursor:pointer;
  transition:background-color 0.3s ease,border-color 0.3s ease;
  user-select:none;
}
.news-tab.active,.news-tab:hover {
  background:#7ba8a3;
  border-color:#7ba8a3;
  color:white;
}

/* ★ [新聞優化] 新增的子分類頁籤樣式 ★ */
.sub-news-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eef3f3;
    overflow-x: auto;
}
.sub-news-tab {
    background: #f1f7f5;
    color: #3e7e72;
    border: none;
    border-radius: 8px;
    padding: 6px 16px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
    white-space: nowrap;
}
.sub-news-tab:hover {
    background-color: #e6f0ee;
}
.sub-news-tab.active {
    background-color: #5A7D78; /* 使用導覽列的強調色 */
    color: white;
}
/* 預設隱藏，由 JS 控制顯示 */
.sub-news-tabs.hidden {
    display: none;
}


.refresh-btn {
  font-weight:600;
  background:#7ba8a3;
  color:white;
  border:none;
  border-radius:10px;
  padding: 5px 14px;
  cursor:pointer;
  font-size: 13px;
  transition:background-color 0.3s ease;
}
.refresh-btn:disabled {opacity:0.5; cursor:not-allowed;}
.news-list { list-style:none; max-height: 400px; overflow-y:auto; padding:0; }
.news-item {
  border-left:4px solid #86b4a9;
  margin-bottom: 6px;
  background:#f1f7f5;
  border-radius:10px;
  padding: 10px 14px;
  font-weight:600;
  color:#3a6259;
  cursor:pointer;
  transition:background 0.3s ease;
}
.news-item:hover { background:#9ac2b9; color:white; }
.news-item-title { font-size: 14px; margin-bottom: 4px; }
.news-item-meta {
  margin-top:4px;
  font-weight:400;
  font-size:12px;
  color:#58716b;
  display:flex;
  justify-content:space-between;
}
.news-loading {text-align:center;padding:20px;color:#7a9794;font-weight:600;}

.stock-card {
  flex-basis:360px;
  background:white;
  border-radius:20px;
  padding: 16px 20px;
  box-shadow:0 8px 30px #a2b8b39e;
  display:flex;
  flex-direction:column;
  gap: 12px;
}
.stock-tabs { display:flex; gap:10px; margin-top: 2px; }
.stock-tab {
  padding: 6px 20px;
  border-radius:10px;
  border:2px solid #a6cdc5;
  background:#ccede9;
  font-size: 15px;
  font-weight:700;
  color:#3e7e72;
  cursor:pointer;
  transition:all 0.28s ease;
  user-select:none;
}
.stock-tab.active, .stock-tab:hover {
  border-color:#7ba8a3;
  background:#7ba8a3;
  color:white;
}
.stock-search { display:flex; gap: 8px; }
.stock-search-input {
  padding: 10px 14px;
  border-radius:12px;
  font-size: 14px;
  font-weight:600;
  border:2px solid #a1d1c4;
  background:#dbece8;
  color:#376655;
  flex:1;
  transition:border-color 0.3s ease;
}
.stock-search-input:focus { outline:none; border-color:#7ba8a3; }
.stock-add-btn {
  background:#7ba8a3;
  border-radius:12px;
  padding: 10px 20px;
  cursor:pointer;
  font-size: 14px;
  font-weight:700;
  color:white;
  border:none;
  transition:background-color 0.3s ease;
}
.stock-add-btn:hover { background:#628775; }
.stock-list {
  max-height:400px;
  overflow-y:auto;
  display:flex;
  flex-direction:column;
  gap: 8px;
}
.stock-item {
  background:#cee3db;
  border-radius:12px;
  padding: 10px 14px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  cursor:pointer;
  transition:background-color 0.3s ease;
  font-weight:700;
  color:#3c786c;
}
.stock-item:hover { background:#7ba8a3; color:white; }
.stock-info {
  display:flex;
  flex-direction:column;
  gap: 3px;
  text-align:left;
  min-width: 6rem;
}
.stock-symbol { font-size: 1.1rem; }
.stock-name { font-weight:400; font-size: 0.8rem; color:#4a655c; }
.stock-price-info { text-align:right; min-width:7rem; }
.stock-price { font-size: 1.2rem; }
.stock-change { font-size: 0.85rem; }
.stock-up { color:#e2646a; }
.stock-down { color:#2e7052; }
.stock-neutral { color:#50766e; }

/* --- 5. V5 卡片共用樣式 --- */
.card {
  background: white;
  border-radius: 20px;
  box-shadow: 0 8px 30px #a2b8b36e;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px; 
}
.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: #578f89;
  border-bottom: 2px solid #e0ebea;
  padding-bottom: 8px;
}
.card-icon {
  font-size: 15px;
}

/* --- 6. V5 "搜尋列" 共用樣式 --- */
.search-input {
  flex:1;
  font-size: 14px;
  border-radius:12px;
  padding: 10px 16px;
  border:2px solid #a3bbb9;
  transition:all 0.3s ease;
  font-weight:400;
}
.search-input:focus {
  outline:none;
  border-color:#7ba8a3;
  box-shadow:0 0 0 4px rgba(123 168 163 / 0.2);
}
.search-btn {
  background-color:#7ba8a3;
  border-radius:12px;
  border:none;
  color:white;
  font-size: 14px;
  font-weight:700;
  cursor:pointer;
  padding: 10px 20px;
  transition:background-color 0.35s ease;
}
.search-btn:hover {background-color:#618577;}

/* --- 7. V5 移植樣式 ("工作" 分頁) --- */
.work-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.todo-input-area {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.todo-input-area .search-input { flex: 1; }
.todo-list {
  list-style: none;
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
}
.todo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #f1f7f5;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 600;
  color: #3a6259;
}
.todo-item-text {
  flex: 1;
  cursor: pointer;
  user-select: none;
  font-size: 15px;
}
.todo-item.completed .todo-item-text {
  text-decoration: line-through;
  opacity: 0.6;
  color: #58716b;
}
.todo-delete-btn {
  background: #e2646a;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 4px 8px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.3s;
}
.todo-delete-btn:hover { background: #c95056; }

.pomodoro-timer-display {
  font-size: 4rem;
  font-weight: 700;
  color: #578f89;
  text-align: center;
  margin: 10px 0;
}
.pomodoro-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}
.pomodoro-controls .search-btn,
.pomodoro-controls .refresh-btn {
  padding: 10px 24px;
  font-size: 15px;
}
.pomodoro-status {
  text-align: center;
  font-weight: 600;
  color: #3e7e72;
}

.quick-notes {
  width: 100%;
  min-height: 300px;
  border: 2px solid #a1d1c4;
  background: #f1f7f5;
  border-radius: 12px;
  padding: 12px;
  font-family: 'Microsoft JhengHei', 'PingFang TC', sans-serif;
  font-size: 14px;
  resize: vertical;
  color: #376655;
}
.quick-notes:focus {
  outline: none;
  border-color: #7ba8a3;
  box-shadow: 0 0 0 4px rgba(123, 168, 163, 0.2);
}
.notes-saved-status {
  font-size: 12px;
  color: #58716b;
  text-align: right;
  margin-top: 6px;
  opacity: 0.8;
}

/* --- 8. "工作快捷列" 樣式 (★ 優化 ★) --- */
.quick-links-bar {
  display: flex;
  gap: 16px; 
  overflow-x: auto; 
  padding: 10px 4px;
}
.quick-link-item {
  display: flex;
  flex-direction: column; 
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  /* ★ [優化] min-width 改為 width，確保間距一致 */
  width: 80px; 
}
.quick-link-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #cce3db;
  color: #3e7e72;
  font-weight: 700;
  font-size: 20px;
  transition: background 0.3s, box-shadow 0.3s;
  overflow: hidden; /* ★ [優化] 新增：裁切圖片圓角 */
}
.quick-link-name {
  font-size: 13px;
  font-weight: 600;
  color: #3a6259;
  
  /* ★ [優化] 新增：文字截斷，顯示 ... */
  width: 100%;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quick-link-item:hover .quick-link-icon {
  background: #b8d4cb;
  box-shadow: 0 4px 12px #b8cac7;
}

/* ★ [優化] 新增 Favicon 圖片樣式 ★ */
.quick-link-favicon {
    width: 100%; /* 填滿容器 */
    height: 100%; /* 填滿容器 */
    object-fit: cover; /* 確保圖片填滿 */
}


/* --- 9. "快捷列編輯" 樣式 --- */
.quick-link-edit-btn {
    background: #cce3db;
    border: none;
    color: #3e7e72;
    font-weight: 600;
    font-size: 12px;
    padding: 2px 10px;
    border-radius: 8px;
    cursor: pointer;
    margin-left: auto; 
    transition: background 0.3s, color 0.3s;
}
.quick-link-edit-btn:hover { background: #b8d4cb; }

.quick-link-edit-btn.editing {
    background: #e2646a;
    color: white;
}

.quick-link-item {
    position: relative; 
}
.quick-link-delete-btn {
    display: none; 
    position: absolute;
    top: -8px;
    right: -2px;
    background: #e2646a;
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-weight: 700;
    cursor: pointer;
    font-size: 14px;
    line-height: 20px; 
    text-align: center;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.quick-links-bar.editing .quick-link-delete-btn {
    display: block;
}

.quick-link-add-btn .quick-link-icon {
    background: #eef3f3;
    color: #7a9794;
    font-size: 24px;
}
.quick-link-add-btn:hover .quick-link-icon {
    background: #dde9e7;
    box-shadow: none;
}

.quick-link-form {
    border-top: 2px solid #e0ebea;
    padding-top: 16px;
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.quick-link-form h3 {
    color: #578f89;
    margin: 0;
    font-size: 16px;
}
.quick-link-form .search-input {
    background: #f1f7f5;
}
.quick-link-form-controls {
    display: flex;
    gap: 10px;
}

/* --- 10. V5 移植：首頁 搜尋、地圖、快捷區塊 --- */
.search-section {
  display:flex;
  gap:10px;
  margin-bottom: 20px;
}

.map-card-full {
  background: white;
  border-radius: 20px;
  box-shadow: 0 8px 32px #a6b7b68e;
  padding: 16px 20px;
  margin-top: 20px;
  margin-bottom: 20px;
}
.map-card-full .section-header {
  gap: 16px;
}
.map-search-box {
  display: flex;
  flex: 1;
  gap: 10px;
  min-width: 250px;
  max-width: 600px;
}
.map-content {
  margin-top: 12px;
}
.map-content iframe {
  border-radius: 12px;
  border: 2px solid #cee2df;
  width: 100%;
  height: 350px;
}

.main-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.project-item {
  background: #f1f7f5;
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.3s, box-shadow 0.3s;
}
.project-item:hover {
  background: #e6f0ee;
  box-shadow: 0 4px 12px #b8cac7;
}
.project-name { font-weight: 700; color: #3a6259; margin-bottom: 4px; font-size: 15px; }
.project-desc { font-size: 13px; color: #58716b; }

.tool-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f1f7f5;
  padding: 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.3s;
}
.tool-item:hover { background: #e6f0ee; }
.tool-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #cce3db;
  color: #3e7e72;
  font-weight: 700;
}
.tool-info { flex: 1; }
.tool-name { font-weight: 700; color: #3a6259; font-size: 15px; }
.tool-url { font-size: 13px; color: #58716b; }

.link-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.quick-link {
  background: #f1f7f5;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 600;
  color: #3a6259;
  cursor: pointer;
  transition: background 0.3s;
}
.quick-link:hover { background: #e6f0ee; }

.bookmark-section { display: flex; flex-direction: column; gap: 8px; }
.bookmark-category {
  font-weight: 700;
  color: #3e7e72;
  margin-top: 6px;
}
.bookmark-link {
  padding-left: 10px;
  border-left: 3px solid #cce3db;
  font-weight: 600;
  color: #3a6259;
  cursor: pointer;
}
.bookmark-link:hover { color: #7ba8a3; }


/* --- 11. 擴充分頁："新聞" 頁面 (★ 優化 ★) --- */
.full-news-list {
  list-style: none;
  padding: 0;
  max-height: none; 
}
.full-news-item {
  border-bottom: 1px solid #eef3f3;
  margin-bottom: 12px;
  padding: 12px 8px;
  cursor: pointer;
  transition: background-color 0.3s;
  
  /* ★ [新聞優化] 改為 flex 排版 */
  display: flex;
  gap: 16px;
  align-items: flex-start; /* 頂部對齊 */
}
.full-news-item:hover {
  background-color: #f1f7f5;
  border-radius: 8px;
}

/* ★ [新聞優化] 新增圖片容器樣式 */
.full-news-image-container {
    width: 120px; /* 統一寬度 */
    height: 80px; /* 統一高度 */
    flex-shrink: 0; /* 避免被壓縮 */
    border-radius: 8px;
    overflow: hidden;
    background-color: #f1f7f5; /* 預設背景色 */
}
/* ★ [新聞優化] 新增圖片樣式 */
.full-news-image {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 裁切以填滿 */
}
/* ★ [新聞優化] 新增無圖片時的替代圖示 */
.full-news-image-container.placeholder {
    display: grid;
    place-items: center;
    font-size: 24px;
    color: #a6cdc5;
}

/* ★ [新聞優化] 新增文字內容容器 */
.full-news-content {
    flex: 1; /* 佔滿剩餘空間 */
    min-width: 0; /* 允許 flex 壓縮 */
}

.full-news-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #3a6259;
  margin-bottom: 6px;
}
.full-news-meta {
  font-size: 0.8rem;
  color: #58716b;
  margin-bottom: 8px;
}
.full-news-desc {
  font-size: 0.9rem;
  color: #4A4A4A;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;  
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- 12. 擴充分頁："地圖" 頁面 --- */
.full-map-card {
  margin: -10px; 
  height: calc(100vh - 120px); 
  display: flex;
  flex-direction: column;
}
.full-map-content {
  flex: 1; 
  margin-top: 12px;
}

/* ★★★ [地圖修正] ★★★
 * 將 #fullMapFrame 改為 .full-map-content .g-map-iframe
 * 以匹配 map.html 中的 <iframe class="g-map-iframe">
 */
.full-map-content .g-map-iframe {
  border-radius: 12px;
  border: 2px solid #cee2df;
  width: 100%;
  height: 100%; 
}

/* [新] 地圖快捷按鈕 */
.map-controls {
    display: flex;
    gap: 10px;
    margin-left: 10px;
}
.search-btn.compact {
    padding: 8px 12px; /* 較小的按鈕 */
    font-size: 13px;
}

/* --- 13. 導覽列右側資訊 --- */
.nav-info-right {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-right: 10px; 
    flex-shrink: 0; 
}
.nav-weather,
.nav-datetime {
    color: var(--morandi-bg);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap; 
}
.nav-weather {
    font-weight: 700; 
}
.nav-weather-emoji {
    font-size: 16px;
    margin-right: 4px;
}

/* --- 14. ★ 擴充分頁："個人" 頁面 ★ --- */

/* 每日隨筆 */
.daily-log-input-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.daily-log-input-area .quick-notes {
    min-height: 100px; /* 較小的輸入框 */
}
.daily-log-input-area .search-btn {
    align-self: flex-end; /* 按鈕靠右 */
}
.daily-log-list {
    list-style: none;
    padding: 0;
    margin-top: 10px;
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column-reverse; /* [新] 讓最新日誌在最上面 */
}
.log-entry {
    background: #f1f7f5;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 10px;
    border-left: 4px solid #AEC9C1;
}
.log-entry-timestamp {
    font-size: 0.8rem;
    font-weight: 600;
    color: #578f89;
    margin-bottom: 6px;
}
.log-entry-content {
    font-size: 0.95rem;
    color: #3a6259;
    white-space: pre-wrap; /* 保留換行 */
    word-wrap: break-word; /* 避免長單字溢出 */
}
