/* ========== Shortcut Panel Styles ========== */

/* Tab Bar - 居中显示 */
.shortcut-tabs {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 12px 0 8px;
  clear: both;
  width: 100%;
  position: relative;
  z-index: 100;
}

.shortcut-tab {
  border: none;
  outline: none;
  font-size: 13px;
  padding: 6px 18px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.04);
  cursor: pointer;
  color: #666;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.shortcut-tab:hover {
  background: rgba(0, 0, 0, 0.08);
}

.shortcut-tab.active {
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  color: #333;
  font-weight: 500;
}

/* 编辑工具栏 - 绝对定位在右侧 */
.shortcut-edit-toolbar {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 101;
}

.shortcut-edit-btn {
  padding: 6px 14px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  background: white;
  font-size: 12px;
  color: #666;
  cursor: pointer;
  transition: all 0.15s ease;
}

.shortcut-edit-btn:hover {
  border-color: #25a942;
  color: #25a942;
}

.shortcut-edit-btn.active {
  background: #25a942;
  border-color: #25a942;
  color: white;
}

/* 编辑模式下的 item */
.m-shortcut-panel .item.is-editing {
  position: relative;
  cursor: grab;
}

.m-shortcut-panel .item.is-editing:active {
  cursor: grabbing;
}

.m-shortcut-panel .item.is-editing:hover {
  transform: scale(1.02);
}

.m-shortcut-panel .item.sortable-ghost {
  opacity: 0.4;
}

.m-shortcut-panel .item.sortable-chosen {
  transform: scale(1.05);
  z-index: 100;
}

/* 删除按钮 - 定位在图标右上角 */
.shortcut-delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ef4444;
  color: white;
  border: 2px solid white;
  cursor: pointer;
  font-size: 14px;
  line-height: 16px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.m-shortcut-panel .item.is-editing .shortcut-delete-btn {
  opacity: 1;
}

.shortcut-delete-btn:hover {
  background: #dc2626;
}

/* 添加按钮 - 使用 .icon 结构，继承现有样式 */
.shortcut-add-icon {
  background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%) !important;
  color: white !important;
  font-size: 28px !important;
  line-height: 54px !important;
  font-weight: 300;
}

/* 展开全部按钮 - 使用 .icon 结构，继承现有样式 */
.shortcut-expand-icon {
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.shortcut-expand-icon svg {
  width: 24px;
  height: 24px;
  color: #43e97b;
}

/* 字母图标 */
.shortcut-letter-icon {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  /* display: flex; */
  /* align-items: center; */
  /* justify-content: center; */
  margin: 0 auto;
  font-size: 24px;
  font-weight: 600;
  color: white;
  text-transform: uppercase;
}

/* 登录提示 */
.shortcut-login-hint {
  text-align: center;
  height: 100px;
  line-height: 100px;
  /* padding: 30px 20px; */
  font-size: 13px;
  color: #999;
  width: 100%;
}

.shortcut-login-hint a {
  color: #25a942;
  text-decoration: none;
}

.shortcut-login-hint a:hover {
  text-decoration: underline;
}

/* ========== 弹窗样式 - 参照 nav-settings-* ========== */

/* 背景模糊层 - 参照 nav-settings-backdrop */
.shortcut-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 9998;
}

.shortcut-popup-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* 弹窗容器 - 参照 nav-settings-shell */
.shortcut-popup-root {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 760px;
  max-width: 90%;
  max-height: 80vh;
  background: rgba(240, 240, 240, 0.8);
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(150, 150, 150, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.shortcut-popup-backdrop.show .shortcut-popup-root {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.shortcut-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  position: relative;
}

.shortcut-popup-title {
  margin: 10px 0;
  font-weight: 600;
  color: #333;
}

/* 关闭按钮 - 参照 nav-settings-close */
.shortcut-popup-close {
  position: absolute;
  top: 16px;
  right: 22px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #999;
  font-size: 24px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shortcut-popup-close:hover {
  color: #333;
  transform: rotate(90deg);
}

.shortcut-popup-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 22px 22px;
}

/* 表格样式 - 参照 search-engine-table */
.shortcut-table-header,
.shortcut-table-row {
  display: grid;
  grid-template-columns: 28px 42px minmax(80px, 1fr) minmax(180px, 2fr) 110px;
  align-items: center;
  column-gap: 8px;
  font-size: 13px;
}

.shortcut-table-header {
  padding: 4px 4px 6px;
  color: #6b7280;
}

.shortcut-table-row {
  padding: 4px 4px;
  border-radius: 8px;
}

.shortcut-table-row:nth-child(odd) {
  background: rgba(150, 150, 150, 0.15);
}

.shortcut-table-row:nth-child(even) {
  background: transparent;
}

.shortcut-table-row.sortable-ghost {
  opacity: 0.7;
}

.shortcut-table-row.sortable-chosen {
  background: rgba(37, 169, 66, 0.15);
  z-index: 10000;
  position: relative;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.shortcut-drag-handle {
  cursor: grab;
  user-select: none;
  color: #9ca3af;
  font-size: 14px;
}

.shortcut-drag-handle:active {
  cursor: grabbing;
}

.shortcut-table-icon-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.shortcut-table-icon-cell img,
.shortcut-table-icon-cell .shortcut-letter-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: cover;
}

.shortcut-table-name {
  font-size: 13px;
  color: #333;
}

.shortcut-table-url {
  font-size: 12px;
  color: #25a942;
  word-break: break-all;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shortcut-table-url:hover {
  text-decoration: underline;
}

.shortcut-table-delete,
.shortcut-table-edit {
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.shortcut-table-delete {
  background: rgba(248, 113, 113, 0.12);
  color: #b91c1c;
}

.shortcut-table-delete:hover {
  background: rgba(248, 113, 113, 0.2);
}

.shortcut-table-edit {
  background: rgba(37, 169, 66, 0.12);
  color: #166534;
}

.shortcut-table-edit:hover {
  background: rgba(37, 169, 66, 0.2);
}

/* 弹窗底部操作按钮区域 - 参照 search-engine__actions */
.shortcut-popup-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  justify-content: flex-start;
}

.shortcut-popup-btn {
  border: 1px solid #e5e5e5;
  border-radius: 2px;
  background: white;
  cursor: pointer;
  overflow: hidden;
  display: block;
  padding: 0 10px;
  height: 20px;
  text-align: center;
  font-size: 13px;
  line-height: 20px;
}

.shortcut-popup-btn:hover {
  color: #333;
  text-decoration: none;
  background: #eaeaea;
}

.shortcut-popup-btn.primary {
  background: #2bc54d;
  color: white;
  border-color: #26ab43;
  height: 25px;
  line-height: 25px;
}

.shortcut-popup-btn.primary:hover {
  background: #25a942;
}

/* 添加/编辑表单弹窗 - 参照 nav-settings-shell */
.shortcut-form-popup {
  position: fixed;
  z-index: 10002;
  width: 360px;
  max-width: 90%;
  background: rgba(240, 240, 240, 0.85);
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(150, 150, 150, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 22px;
}

.shortcut-form-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #333;
}

.shortcut-form-group {
  margin-bottom: 12px;
}

.shortcut-form-label {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
}

.shortcut-form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  font-size: 14px;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
}

.shortcut-form-input:focus {
  outline: none;
  border-color: #25a942;
}

.shortcut-form-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  font-size: 14px;
  background: white;
  cursor: pointer;
}

.shortcut-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.shortcut-form-btn {
  flex: 1;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.shortcut-form-btn.primary {
  background: #25a942;
  color: white;
}

.shortcut-form-btn.primary:hover {
  background: #1f9438;
}

.shortcut-form-btn.secondary {
  background: rgba(0, 0, 0, 0.05);
  color: #666;
}

.shortcut-form-btn.secondary:hover {
  background: rgba(0, 0, 0, 0.1);
}

/* 图标预览 */
.shortcut-icon-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 8px;
  margin-top: 8px;
}

.shortcut-icon-preview-img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
}

.shortcut-icon-preview-letter {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: white;
}

.shortcut-icon-preview-text {
  font-size: 12px;
  color: #666;
}

/* ========== 暗色模式 ========== */
body.theme-dark .shortcut-tab {
  background: rgba(255, 255, 255, 0.08);
  color: #ccc;
}

body.theme-dark .shortcut-tab:hover {
  background: rgba(255, 255, 255, 0.12);
}

body.theme-dark .shortcut-tab.active {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

body.theme-dark .shortcut-edit-btn {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: #ccc;
}

body.theme-dark .shortcut-popup-root {
  background: rgba(30, 30, 30, 0.5);
  border-color: rgba(150, 150, 150, 0.5);
}

body.theme-dark .shortcut-popup-title {
  color: #e5e7eb;
}

body.theme-dark .shortcut-popup-close {
  color: #b0b0b0;
}

body.theme-dark .shortcut-popup-close:hover {
  color: #e5e7eb;
}

body.theme-dark .shortcut-popup-header,
body.theme-dark .shortcut-table-header {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

body.theme-dark .shortcut-table-row:nth-child(odd) {
  background: rgba(255, 255, 255, 0.03);
}

body.theme-dark .shortcut-table-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

body.theme-dark .shortcut-table-name {
  color: #e5e7eb;
}

body.theme-dark .shortcut-table-delete {
  background: rgba(248, 113, 113, 0.15);
  color: #fca5a5;
}

body.theme-dark .shortcut-table-delete:hover {
  background: rgba(248, 113, 113, 0.25);
}

body.theme-dark .shortcut-table-edit {
  background: rgba(37, 169, 66, 0.15);
  color: #86efac;
}

body.theme-dark .shortcut-table-edit:hover {
  background: rgba(37, 169, 66, 0.25);
}

body.theme-dark .shortcut-popup-btn {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.2);
  color: #eee;
}

body.theme-dark .shortcut-popup-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

body.theme-dark .shortcut-popup-btn.primary {
  background: #2bc54d;
  color: white;
  border-color: #26ab43;
}

body.theme-dark .shortcut-popup-btn.primary:hover {
  background: #25a942;
}

body.theme-dark .shortcut-form-popup {
  background: #2a2a2a9a;
  border-color: rgba(255, 255, 255, 0.1);
}

body.theme-dark .shortcut-form-title {
  color: #eee;
}

body.theme-dark .shortcut-form-input,
body.theme-dark .shortcut-form-select {
  background: #333;
  border-color: rgba(255, 255, 255, 0.1);
  color: #eee;
}

body.theme-dark .m-shortcut-panel .shortcut-add-item {
  border-color: rgba(255, 255, 255, 0.15) !important;
}

body.theme-dark .shortcut-expand-text {
  color: #ccc;
}

/* ========== 自动暗色模式 ========== */
@media (prefers-color-scheme: dark) {
  body.auto-theme .shortcut-tab {
    background: rgba(255, 255, 255, 0.08);
    color: #ccc;
  }

  body.auto-theme .shortcut-tab.active {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
  }

  body.auto-theme .shortcut-edit-btn {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: #ccc;
  }

  body.auto-theme .shortcut-popup-root {
    background: rgba(30, 30, 30, 0.98);
    border-color: rgba(255, 255, 255, 0.1);
  }

  body.auto-theme .shortcut-form-popup {
    background: #2a2a2a9a;
    border-color: rgba(255, 255, 255, 0.1);
  }

  body.auto-theme .shortcut-form-input,
  body.auto-theme .shortcut-form-select {
    background: #333;
    border-color: rgba(255, 255, 255, 0.1);
    color: #eee;
  }

  body.auto-theme .m-shortcut-panel .shortcut-add-item {
    border-color: rgba(255, 255, 255, 0.15) !important;
  }
}
