/* ============================================================
   1. 核心容器與基礎設定 (Container & Base)
   ============================================================ */
#mas-content {
  padding: 20px;
  white-space: pre-wrap;
  position: relative;
  color: #333;
}

#mas-temp-mask {
  position: absolute;
  background-color: rgba(255, 235, 59, 0.4);
  pointer-events: none;
  z-index: 9999;
  border-radius: 2px;
  mix-blend-mode: multiply;
  display: none;
}

.mas-hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
}

.mas-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(50, 50, 50, 0.9);
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  z-index: 10001;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition:
    opacity 0.3s,
    transform 0.3s;
  pointer-events: none;
}

.mas-toast.fade-out {
  opacity: 0;
  transform: translate(-50%, -20px);
}

/* ============================================================
   2. 畫線高亮與重疊邏輯 (Highlight & Selection)
   ============================================================ */
.mas-highlight {
  border-bottom: 2px solid transparent;
  cursor: pointer;
  position: relative;
  display: inline;
  transition:
    transform 0.2s ease,
    background-color 0.2s ease;
  will-change: transform, background-color;
  backface-visibility: hidden;
}

.mas-highlight.others {
  background-color: #eeeeee !important;
  border-bottom: 1px dashed #bdbdbd !important;
  color: #555;
}

.mas-highlight.mine {
  background-color: rgba(255, 241, 118, 0.85) !important;
  border-bottom: 2px solid #fbc02d !important;
  z-index: 1;
  transition:
    outline 0.3s ease,
    background-color 0.2s ease;
}

.mas-highlight.mine .mas-highlight.others {
  background-color: rgba(0, 0, 0, 0.05) !important;
  border-bottom: 1px dashed #666 !important;
}

.mas-highlight:hover {
  z-index: 1000 !important;
}

.mas-highlight.mine:hover {
  background-color: #fff176 !important;
}

.mas-highlight.others:hover {
  background-color: #d1d1d1 !important;
}

.bookmark-target {
  background-color: #fff176 !important;
  outline: 4px solid #ff9800 !important;
  outline-offset: 2px;
  border-radius: 2px;
  transition: all 0.3s ease;
  box-shadow: 0 0 15px rgba(255, 152, 0, 0.5);
}

.mas-highlight-flash {
  animation: masFlash 0.6s ease-in-out 3;
  border-radius: 2px;
  position: relative;
  z-index: 10;
}

@keyframes masFlash {
  0% {
    background-color: rgba(241, 196, 15, 0.3) !important;
    outline: 0px solid rgba(241, 196, 15, 0);
  }
  50% {
    background-color: rgba(241, 196, 15, 1) !important;
    outline: 6px solid rgba(241, 196, 15, 0.5);
    outline-offset: 2px;
  }
  100% {
    background-color: rgba(241, 196, 15, 0.3) !important;
    outline: 0px solid rgba(241, 196, 15, 0);
  }
}

/* ============================================================
   3. 工具列、氣泡與評論框 (Tooltip, Toolbar & Comment Box)
   ============================================================ */
/* Tooltip 氣泡樣式 */
.mas-highlight::after {
  content: attr(data-comment);
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  margin-top: 8px;
  background: #222;
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 18px;
  line-height: 1.5;
  z-index: 9999;
  white-space: pre-wrap;
  min-width: 120px;
  max-width: 280px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  display: none;
}

.mas-highlight::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  margin-top: 2px;
  border-width: 0 6px 6px 6px;
  border-style: solid;
  border-color: transparent transparent #222 transparent;
  z-index: 10000;
  pointer-events: none;
  display: none;
}

/* --- 修改處：Toolbar 拓寬優化 --- */
.mas-toolbar {
  background: #222;
  padding: 15px 20px; /* 增加內距，讓裡面更有呼吸空間 */
  border-radius: 8px; /* 圓角稍微加大更現代 */
  display: flex;
  flex-direction: column; /* 讓按鈕與文字上下排列 */
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);

  /* 💡 核心修正：設定最小寬度防止擠壓 */
  min-width: 320px !important;
  width: max-content !important;

  transition:
    top 0.1s ease-out,
    left 0.1s ease-out;
  pointer-events: auto;
  z-index: 10001 !important;
}

/* 3. 定義顯示時的狀態 */
.mas-toolbar.is-active {
  opacity: 1;
  visibility: visible;
}

.mas-toolbar button {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
}

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

/* 確保裡面的登入提示容器撐滿 */
.mas-login-tip {
  color: #fff;
  font-size: 14px;
  padding: 4px 8px;
  text-align: center;
  min-width: 200px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mas-login-tip p {
  font-size: 15px !important;
  line-height: 1.6 !important;
  margin-bottom: 15px !important;
  font-weight: 500 !important;
  color: #ffffff !important;
  margin: 0 0 12px 0;
}

/* Comment Box 評論框 */
.mas-comment-box {
  background: #fff;
  border: 1px solid #ddd;
  padding: 12px;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  width: 260px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10002 !important;
  position: absolute;
}

.mas-comment-box textarea {
  width: 100%;
  height: 90px;
  border: 1px solid #eee;
  padding: 8px;
  font-size: 18px;
  resize: none;
  display: block;
  box-sizing: border-box;
  border-radius: 4px;
  background-color: #f9f9f9;
}

.mas-comment-box button {
  background: #222;
  color: #fff;
  border: none;
  width: 100%;
  padding: 8px;
  border-radius: 4px;
  cursor: pointer;
  box-sizing: border-box;
}

.btn-delete:hover {
  background-color: #fff1f1 !important;
  transform: scale(1.1);
  transition: all 0.2s;
}

/* ============================================================
   4. 側邊欄與導覽面板 (Sidebar & Navigation)
   ============================================================ */
#mas-nav-toggle {
  position: fixed;
  bottom: 100px;
  right: 30px;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #2c3e50, #4ca1af);
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: 2px solid #fff;
}

#mas-nav-toggle:hover {
  transform: scale(1.1) rotate(-10deg);
  background: linear-gradient(135deg, #34495e, #5bc0de);
}

#mas-nav-toggle .dashicons {
  font-size: 24px;
  width: 24px;
  height: 24px;
}

#mas-nav-sidebar {
  position: fixed;
  top: 0;
  right: -320px;
  width: 320px;
  height: 100vh;
  background: #ffffff;
  box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10000;
  display: flex;
  flex-direction: column;
}

#mas-nav-sidebar.active {
  right: 0;
}

.mas-sidebar-header {
  padding: 15px 20px;
  background: #f8f9fa;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mas-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mas-header-left h3 {
  margin: 0;
  font-size: 18px;
  color: #2c3e50;
}

#mas-nav-count {
  background: #e67e22;
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  margin-left: 5px;
}

.mas-close-btn {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: #95a5a6;
  line-height: 1;
}

.mas-close-btn:hover {
  color: #e74c3c;
}

#mas-nav-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  background: #ffffff;
}

/* 書箋跳轉按鈕 */
#mas-jump-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #ffeb3b, #fbc02d);
  color: #5d4037;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  font-size: 26px;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: 2px solid #fff;
}

#mas-jump-btn:hover {
  transform: scale(1.1) rotate(10deg);
  background: linear-gradient(135deg, #fff176, #ffb300);
}

/* 側邊欄項目樣式 */
.mas-nav-item {
  background: #ffffff;
  border: 1px solid #eee;
  border-left: 4px solid #f1c40f;
  padding: 14px;
  margin-bottom: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.mas-nav-item:hover {
  border-color: #f1c40f;
  background: #fffdf0;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.mas-nav-item.is-mine {
  background: #fffdf5;
  border-color: #ffe58f;
  border-left-color: #f1c40f;
}

.mas-nav-item.is-mine:hover {
  background: #fff9c4;
  box-shadow: 0 4px 12px rgba(241, 196, 15, 0.15);
  transform: translateY(-1px);
}

.mas-nav-item.is-others {
  border-left-color: #90caf9;
}

.mas-nav-item.is-others:hover {
  border-color: #90caf9;
  background: #f0f7ff;
}

body:not(.logged-in) .mas-nav-item {
  border-left-color: #bdbdbd !important;
}

body:not(.logged-in) .mas-nav-item:hover {
  background: #f5f5f5;
  border-color: #999;
}

.mas-nav-exact {
  font-size: 16px;
  color: #2c3e50;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

.mas-nav-comment {
  font-size: 16px;
  font-style: italic;
  color: #7f8c8d;
  font-weight: 500;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

/* ============================================================
   5. 使用者資訊與 Google 按鈕 (User Info & Google Button)
   ============================================================ */
.mas-nav-user-row {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.mas-sidebar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  margin-right: 10px;
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  object-fit: cover;
}

.mas-nav-username {
  font-size: 13px;
  font-weight: 600;
  color: #444;
}

.mas-nav-item.is-mine .mas-nav-username {
  color: #e67e22;
}

.mas-avatar-circle img {
  border-radius: 50%;
  margin-right: 8px;
  border: 2px solid #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Google 按鈕統一樣式 */
.mas-google-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 24px;
  background-color: #ffffff;
  color: #3c4043;
  border: 2px solid #000000;
  border-radius: 48px;
  text-decoration: none;
  transition:
    background-color 0.218s,
    border-color 0.218s,
    box-shadow 0.218s;
  overflow: hidden;
  width: auto;
  max-width: 100%;
  margin: 0 auto;
}

.mas-google-button:hover {
  background-color: #f8f9fa;
  border-color: #000000;
  box-shadow:
    0 1px 3px 0 rgba(0, 0, 0, 0.2),
    0 1px 1px 0 rgba(0, 0, 0, 0.14);
}

.mas-google-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-right: 12px;
}

.mas-google-icon {
  width: 20px;
  height: 20px;
  display: block;
}

/* 其他登入建議樣式 */
#mas-nav-list-container .google-login-link {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #fff;
  color: #757575 !important;
  border: 1px solid #dadce0;
  padding: 10px;
  border-radius: 4px;
  text-decoration: none;
  font-family: "Roboto", arial, sans-serif;
  font-weight: 500;
  transition:
    background-color 0.2s,
    box-shadow 0.2s;
}

#mas-nav-list-container .google-login-link:hover {
  background-color: #f8f9fa;
  box-shadow:
    0 1px 2px 0 rgba(60, 64, 67, 0.302),
    0 1px 3px 1px rgba(60, 64, 67, 0.149);
}

.login-suggestion {
  background-color: #f9f9f9;
  border-radius: 4px;
  margin: 10px;
}

/* ============================================================
   🚀 側邊欄專用：大尺寸全寬按鈕
   ============================================================ */

/* 1. 強制按鈕容器加寬，並處理大圓角 */
#mas-nav-list-container .mas-google-button {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;

  width: 100% !important; /* 強制加寬到 100% */
  max-width: 250px !important; /* 限制最大寬度，避免太長 */
  height: 48px !important; /* 加高，讓大圓角更好看 */
  margin: 10px auto !important; /* 居中並留白 */

  border-radius: 24px !important; /* 高度的一半，達成完美藥丸形 */
  padding: 0 20px !important;
  background-color: #ffffff !important;
  border: 1px solid #747775 !important;
  text-decoration: none !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
}

/* 2. 暴力放大 Logo (針對 SVG) */
#mas-nav-list-container .mas-google-button svg {
  width: 24px !important; /* 放大到 24px */
  height: 24px !important;
  min-width: 24px !important; /* 防止被文字擠壓 */
  margin-right: 12px !important; /* 拉開 Logo 與文字的距離 */
}

/* 3. 調整文字大小與比例 */
#mas-nav-list-container .mas-google-button span,
#mas-nav-list-container

/* 4. 清除外層 login-suggestion 的干擾 */
.login-suggestion {
  padding: 10px 15px !important;
  text-align: center !important;
}

/* --- 共通部分：確保 wrapper 內的按鈕寬度與對齊 --- */
.simple-login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* --- 1. 側邊欄：白底風格 (原本就正常的) --- */
#mas-nav-list-container .simple-login-wrapper .mas-google-button {
  background-color: #ffffff !important;
  border: 1px solid #747775 !important;
}

/* --- 2. 文章 Tooltip：黑底風格優化 --- */
/* 假設 .mas-toolbar 是深色背景 */
.mas-toolbar .simple-login-wrapper .mas-google-button {
  background-color: #ffffff !important; /* Google 按鈕通常維持白底比較規範 */
  border: none !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
}

/* 如果您希望 Tooltip 裡的提示文字顏色跟隨黑底變白 */
.mas-toolbar .mas-login-tip p {
  color: #eee !important;
  font-size: 12px;
}

/* ============================================================
   統一登入提示文字樣式 (Tooltip & Sidebar)
   ============================================================ */

/* 1. 統一文字大小與風格 */
.mas-login-tip p,
.login-suggestion p {
  font-size: 15px !important; /* 從 18px 調降，避免在氣泡中太擠 */
  line-height: 1.6 !important;
  font-weight: 500 !important;
  margin: 12px 0 0 0 !important; /* 統一與按鈕的間距 */
  text-align: center !important;
}

/* 2. 針對文章 Tooltip (黑底白字) */
.mas-toolbar .mas-login-tip p {
  color: #ffffff !important;
}

/* 3. 針對側邊列 (白底灰字) */
#mas-nav-list-container .login-suggestion p {
  color: #666666 !important;
  padding: 0 10px; /* 增加一點左右內距，避免貼邊 */
}

/* 4. 確保 Google 按鈕在兩邊都不會變形 */
.simple-login-wrapper .mas-google-button {
  min-width: 200px !important;
  height: 44px !important; /* 稍微調小一點點，讓整體更精緻 */
}

/* --- 針對文章 Tooltip 內的 Google 按鈕間距優化 --- */
.mas-toolbar .simple-login-wrapper .mas-google-button {
  gap: 12px !important; /* 💡 這是最直接的方法：增加 Flex 間距 */
  padding-left: 16px !important;
  padding-right: 16px !important;
}

/* 確保內部的 Logo (SVG) 有外距，以防 gap 不生效 */
.mas-toolbar .simple-login-wrapper .mas-google-button svg,
.mas-toolbar .simple-login-wrapper .mas-google-button .mas-google-icon {
  margin-right: 10px !important; /* 強制推開文字 */
}

/* 確保文字不會縮小，維持視覺平衡 */
.mas-toolbar .simple-login-wrapper .mas-google-button span {
  letter-spacing: 0.5px !important; /* 稍微增加字距，讓文字在黑底氣泡中更易讀 */
}

#mas-nav-list-container .mas-google-button span {
  font-size: 16px !important; /* 🎯 關鍵：縮小側邊欄文字 */
  font-weight: 600 !important;
  color: #444444 !important;
}

/* 🎯 修正處：文章中的登入文字變大 */
.mas-toolbar .mas-google-button span {
  font-size: 16px !important; /* 👈 放大，讓使用者在氣泡中看得清楚 */
  font-weight: 600 !important;
  color: #1f1f1f !important;
}
