/* 模态框样式 - 现代简约设计 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(8px);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: 16px;
  width: 90%;
  max-width: 480px;
  box-shadow: var(--shadow-strong);
  overflow: hidden;
  animation: scaleIn 0.25s cubic-bezier(0.4, 0.0, 0.2, 1);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

@keyframes scaleIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px;
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.modal-header h2 {
  margin: 0;
  color: var(--color-primary);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.close-btn {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
  opacity: 0.7;
}

.close-btn:hover {
  background-color: rgba(0, 0, 0, 0.05);
  opacity: 1;
  transform: rotate(90deg);
}

/* 表单样式 */
#add-website-form,
#add-category-form,
#rename-category-form {
  padding: 28px;
  background: var(--bg-secondary);
}

.form-group {
  margin-bottom: 24px;
}

.form-group label {
  display: block;
  margin-bottom: 10px;
  color: var(--color-primary);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.2px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--search-border);
  border-radius: 10px;
  font-size: 15px;
  transition: all 0.2s ease;
  box-sizing: border-box;
  background: var(--bg-primary);
  color: var(--color-primary);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.form-group input::placeholder {
  color: rgba(0, 0, 0, 0.4);
  opacity: 0.7;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 32px;
}

.form-actions button {
  flex: 1;
  padding: 14px 24px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.3px;
}

.btn-cancel {
  background-color: rgba(0, 0, 0, 0.03);
  color: var(--color-primary);
  border: 1px solid var(--search-border);
}

.btn-cancel:hover {
  background-color: rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

.btn-submit {
  background: var(--color-accent);
  color: white;
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2);
}

.btn-submit:hover {
  background: var(--btn-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(52, 152, 219, 0.3);
}

/* 深色主题适配 */
[data-theme="dark"] .modal-content {
  border: 1px solid rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .close-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .form-group select:focus {
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

[data-theme="dark"] .form-group input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] .btn-cancel {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--color-primary);
}

[data-theme="dark"] .btn-cancel:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .btn-submit {
  background: var(--color-accent);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
}

[data-theme="dark"] .btn-submit:hover {
  background: var(--btn-hover);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.35);
}

/* 自定义网站卡片样式 */
.custom-site {
  position: relative;
}

.card-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: none;
  gap: 5px;
  z-index: 10;
}

.custom-site:hover .card-actions {
  display: flex;
}

.card-actions button {
  background: rgba(0, 0, 0, 0.6);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  font-size: 12px;
}

.card-actions button:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: scale(1.1);
}

.edit-btn:hover {
  background: #667eea !important;
}

.delete-btn:hover {
  background: #e74c3c !important;
}

/* 新闻侧边栏样式 */
.news-sidebar {
  position: fixed;
  right: 0;
  top: 0;
  width: 40%;
  max-width: 800px;
  min-width: 500px;
  height: 100vh;
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  box-shadow: -5px 0 30px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s ease;
  z-index: 100;
  display: flex;
  flex-direction: row;
  border-left: 1px solid var(--sidebar-border);
}

.news-main-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.news-sidebar.collapsed {
  transform: translateX(100%);
}

.sidebar-header {
  padding: 25px 30px 25px 150px;
  background: var(--sidebar-bg);
  color: var(--btn-text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--btn-text);
}

.sidebar-toggle {
  position: absolute;
  left: -50px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--sidebar-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--sidebar-border);
  color: var(--btn-text);
  width: 50px;
  height: 80px;
  border-radius: 10px 0 0 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all 0.3s;
  box-shadow: -3px 0 15px rgba(0, 0, 0, 0.2);
}

.sidebar-toggle:hover {
  background: rgba(40, 40, 60, 0.95);
  left: -53px;
}

/* 新闻分类标签容器 */
.news-tabs-container {
  flex-shrink: 0;
  width: 120px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* 垂直居中 */
  align-items: stretch;
  /* 子元素横向拉伸 */
  padding: 20px 0;
}

/* 新闻分类标签 */
.news-tabs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 15px;
}

.news-tab {
  padding: 12px 15px;
  background: var(--sidebar-tab-bg);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: var(--btn-text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  white-space: nowrap;
}

.news-tab:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  color: var(--btn-text);
  transform: translateX(5px);
}

.news-tab.active {
  background: var(--sidebar-tab-active);
  border-color: transparent;
  color: var(--btn-text);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* 轮播容器 */
.carousel-wrapper {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.carousel-container {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

/* 自定义滚动条 */
.carousel-container::-webkit-scrollbar {
  width: 8px;
}

.carousel-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

.carousel-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.carousel-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* 新闻列表 */
.news-list {
  padding: 10px 25px;
  min-height: 100%;
}

/* 平台标题 */
.platform-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  margin: 0 0 20px 0;
  background: var(--sidebar-news-item);
  border-radius: 12px;
  border-left: 4px solid var(--color-accent);
}

.platform-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--btn-text);
  letter-spacing: 0.5px;
}

.platform-update-time {
  font-size: 13px;
  color: var(--btn-text);
  opacity: 0.8;
  font-weight: 500;
}

/* 新闻项 */
.news-item {
  margin-bottom: 16px;
  padding: 18px 20px;
  background: var(--sidebar-news-item);
  border-radius: 12px;
  border-left: 3px solid transparent;
  transition: all 0.3s ease;
  cursor: pointer;
}

.news-item:hover {
  background: var(--sidebar-news-hover);
  border-left-color: var(--color-accent);
  transform: translateX(-5px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.news-item a {
  color: var(--btn-text);
  text-decoration: none;
  display: block;
}

.news-title {
  font-size: 15px;
  line-height: 1.7;
  margin-bottom: 10px;
  color: var(--btn-text);
  font-weight: 500;
  letter-spacing: 0.3px;
}

.news-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.news-platform,
.news-tag,
.news-update-time {
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 14px;
  background: var(--sidebar-tab-bg);
  color: var(--btn-text);
  font-weight: 500;
}

.news-platform {
  background: var(--tag-platform);
  color: var(--btn-text);
  font-weight: 600;
}

.news-update-time {
  background: var(--tag-time);
  color: var(--btn-text);
}

.news-tag {
  background: var(--tag-hot);
  color: var(--btn-text);
  font-weight: 600;
}

.loading,
.no-news {
  padding: 50px 30px;
  text-align: center;
  color: var(--btn-text);
  opacity: 0.7;
  font-size: 15px;
  font-weight: 500;
}

/* 主内容区域调整 */
.main-content {
  margin-right: 0;
  transition: margin-right 0.3s ease;
}

.news-sidebar:not(.collapsed)~.container .main-content {
  margin-right: 40%;
}

/* 添加网站卡片样式优化 */
.add-card {
  border: 3px dashed rgba(255, 255, 255, 0.6) !important;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%) !important;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.add-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.add-card:hover::before {
  opacity: 1;
}

.add-card:hover {
  border-color: rgba(255, 255, 255, 0.9) !important;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.25) 0%, rgba(118, 75, 162, 0.25) 100%) !important;
  transform: translateY(-8px) scale(1.02);
  box-shadow: var(--shadow-strong);
}

.add-card i {
  font-size: 52px;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 12px;
  transition: all 0.3s ease;
}

.add-card:hover i {
  transform: rotate(90deg) scale(1.1);
  color: white;
}

.add-card a {
  color: rgba(255, 255, 255, 0.95) !important;
  font-weight: 600;
  font-size: 16px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.add-card .site-subtitle {
  color: rgba(255, 255, 255, 0.85) !important;
  font-size: 13px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* 响应式设计 */
@media (max-width: 1600px) {
  .news-sidebar {
    width: 35%;
    min-width: 450px;
  }

  .carousel-container {
    display: block !important;
    /* Ensure visible in sidebar */
  }

  .news-sidebar:not(.collapsed)~.container .main-content {
    margin-right: 35%;
  }
}

@media (max-width: 1400px) {
  .news-sidebar {
    width: 380px;
    min-width: 380px;
  }

  .news-sidebar:not(.collapsed)~.container .main-content {
    margin-right: 380px;
  }
}

@media (max-width: 1200px) {
  .news-sidebar {
    width: 350px;
    min-width: 350px;
  }

  .news-sidebar:not(.collapsed)~.container .main-content {
    margin-right: 350px;
  }
}

@media (max-width: 768px) {

  /* 移动端侧边栏基础样式 */
  .news-sidebar {
    width: 100%;
    min-width: 100%;
    z-index: 1000;
    flex-direction: column;
    height: 100vh;
  }

  .news-sidebar:not(.collapsed)~.container .main-content {
    margin-right: 0;
  }

  /* 移动端切换按钮样式优化 */
  /* Expanded State (Sidebar Visible): Hide toggle button, use close button instead */
  .news-sidebar:not(.collapsed) .sidebar-toggle {
    display: none;
  }

  .sidebar-toggle {
    left: auto;
    right: 0;
    top: 0;
    transform: none;
    width: 44px;
    height: 44px;
    border-radius: 0;
    background: var(--color-accent);
    opacity: 0.9;
    z-index: 1002;
  }

  .sidebar-toggle:hover {
    left: auto;
    right: 0;
    background: var(--color-accent);
  }

  /* Collapsed State (Sidebar Hidden): Button needs to stick out to be visible */
  .news-sidebar.collapsed .sidebar-toggle {
    right: auto;
    /* Override right: 0 from above */
    left: -44px;
    /* Position it to the left of the sidebar edge */
    top: 10px;
    border-radius: 10px 0 0 10px;
    /* Rounded on left side */
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.2);
  }

  .modal-content {
    width: 95%;
    margin: 20px;
  }

  /* 移动端标签容器改为顶部横向排列 */
  .news-tabs-container {
    width: 100%;
    flex-direction: row;
    flex-shrink: 0;
    border-right: none;
    border-bottom: 1px solid var(--sidebar-border);
    padding: 20px 12px 12px 12px;
    /* 增加顶部间距，避免贴顶 */
    padding-right: 60px !important;
    /* 强制预留60px空间，防止被关闭按钮(44px)遮挡 */
    overflow-x: auto;
    white-space: nowrap;
    background: var(--sidebar-bg);
    justify-content: flex-start;
    /* 修复左侧遮挡严重问题，从头开始排列 */
  }

  /* 标签列表容器 */
  .news-tabs {
    display: flex;
    flex-direction: row;
    /* padding: 0 8px;  <-- Removed to avoid conflict with .news-tabs-container padding */
    gap: 8px;
    width: auto;
  }

  /* 单个标签样式 */
  .news-tab {
    padding: 8px 12px;
    font-size: 13px;
    flex-shrink: 0;
  }

  .sidebar-header {
    padding: 20px 25px 20px 120px;
  }

  /* 新闻列表区域调整 */
  .news-main-content {
    flex: 1;
    overflow-y: auto;
    width: 100%;
  }

  .news-list {
    padding: 15px 20px;
  }

  /* 移动端关闭按钮 - 优化样式 */
  .mobile-sidebar-close {
    display: none;
    /* 暂时隐藏关闭按钮，使用右滑关闭 */
    /* display: flex;     <-- 已隐藏，如需恢复请取消注释此行并注释上一行 */
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    right: 0;
    width: 44px;
    /* 与顶部栏高度一致 */
    height: 44px;
    border-radius: 0 0 0 12px;
    background: rgba(0, 0, 0, 0.2);
    /* 半透明背景，更协调 */
    backdrop-filter: blur(4px);
    color: rgba(255, 255, 255, 0.9);
    border: none;
    font-size: 18px;
    cursor: pointer;
    z-index: 1003;
    /* 比其他元素高 */
    transition: all 0.2s ease;
  }

  .mobile-sidebar-close:hover {
    background: rgba(0, 0, 0, 0.4);
  }

  /* Ensure news content is visible on mobile */
  .news-sidebar .carousel-container {
    display: block !important;
    position: static;
    /* Override possible fixed positioning from desktop ticker */
    width: 100%;
    height: 100%;
    margin: 0;
  }
}

/* 拖拽相关样式已迁移到theme.css */

.link-card:not(.add-card):hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}