/* 基础重置和样式 */
:root {
  --primary-color: #3370FF;
  /* 红色：主色 */
  --secondary-color: #F0F0F0;
  /* 米色：辅色 */
  --bg-color: #FFFFFF;
  /* 背景白色为主 */
  --text-color: #333333;
  --header-height: 48px;
  /* 缩小高度，更加精致 */
  --sidebar-width: 240px;
}

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

/* --- 布局容器 --- */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* --- 顶部栏 --- */
.app-header {
  height: var(--header-height);
  /* 设置半透明红底加上毛玻璃效果 */
  background-color: rgba(51, 112, 255, 0.85);
  /* 运用 rgba 来增加微透明度 */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);

  /* 在背景图层上放置带有角度的白色半透明渐变，并放大 2.5倍 以便做动画偏移 */
  background-image: linear-gradient(135deg,
      rgba(255, 255, 255, 0) 15%,
      rgba(255, 255, 255, 0.45) 50%,
      rgba(255, 255, 255, 0) 85%);
  background-size: 250% 250%;
  animation: shimmerFlow 6s ease-in-out infinite alternate;

  /* 给顶部增加细腻的高光亮边，底部增加略深的外投影 */
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.5), 0 4px 15px rgba(51, 112, 255, 0.3);

  display: flex;
  align-items: center;
  position: relative;
  z-index: 10;
  justify-content: space-between;
  padding: 0 24px;
  box-sizing: border-box;
}

/* 动效：让白色的反光带不停地左右滑动 */
@keyframes shimmerFlow {
  0% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

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

.logo-img {
  height: 22px;
  /* 进一步缩小logo面积 */
  width: auto;
  object-fit: contain;
}

.company-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-color);
}

.header-right {
  display: flex;
  align-items: center;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  /* 间距紧凑化 */
  cursor: pointer;
}

.user-avatar {
  background-color: var(--bg-color);
  color: var(--primary-color);
  width: 26px;
  /* 缩小头像 */
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: bold;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.username {
  font-size: 13px;
  /* 字体随之缩小 */
  color: #ffffff;
  font-weight: 500;
}

/* --- 主体区域 --- */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* --- 侧边导航栏 --- */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-color);
  border-right: 1px solid #e0e0e0;
  overflow-y: auto;
}

.nav-menu {
  list-style: none;
  padding: 16px 0;
  margin: 0;
}

.nav-group {
  margin-bottom: 8px;
}

.nav-group-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  font-weight: 600;
  color: var(--text-color);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s;
}

.nav-group-title:hover {
  background-color: var(--secondary-color);
}

.nav-arrow {
  font-size: 12px;
  color: #999;
  transition: transform 0.3s;
}

.nav-submenu {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-item {
  padding: 12px 24px 12px 48px;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
  display: flex;
  align-items: center;
}

.nav-item:hover {
  background-color: var(--secondary-color);
  color: var(--primary-color);
}

.nav-item.active {
  background-color: rgba(51, 112, 255, 0.1);
  /* 红色的10%透明度 */
  color: var(--primary-color);
  font-weight: 500;
  border-right: 3px solid var(--primary-color);
}

/* --- 右侧内容区 --- */
.app-main {
  flex: 1;
  background-color: var(--secondary-color);
  /* 米色为主 */
  overflow-y: auto;
  padding: 24px;
  box-sizing: border-box;
}

/* --- 工具内容区基础布局 --- */
.tool-container {
  display: flex;
  width: 100%;
  height: 100%;
  gap: 24px;
}

.tool-left {
  flex: 0 0 35%;
  background-color: var(--bg-color);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tool-right {
  flex: 1;
  background-color: var(--bg-color);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
}

/* --- 表单元素样式抽象 --- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-color);
}

.form-control {
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  background-color: #fafafa;
  color: #333; /* 正常输入颜色 */
}

.form-control::placeholder {
  color: #999 !important;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  background-color: #fff;
  box-shadow: 0 0 0 3px rgba(51, 112, 255, 0.1);
}

/* --- 日期选择器 (date) 的高级颜色定制 --- */
.form-control[type="date"] {
  color: #999;
}

/* 兼容 Chrome 等 Webkit 浏览器日期内文本的占位色 */
.form-control[type="date"]::-webkit-datetime-edit-year-field,
.form-control[type="date"]::-webkit-datetime-edit-month-field,
.form-control[type="date"]::-webkit-datetime-edit-day-field,
.form-control[type="date"]::-webkit-datetime-edit-text {
  color: #999;
}

/* 当已有值或激活时，强制恢复深色 */
.form-control[type="date"]:focus,
.form-control[type="date"].has-value,
.form-control[type="date"]:valid {
  color: #333;
}
.form-control[type="date"]:focus::-webkit-datetime-edit-year-field,
.form-control[type="date"].has-value::-webkit-datetime-edit-year-field,
.form-control[type="date"]:focus::-webkit-datetime-edit-month-field,
.form-control[type="date"].has-value::-webkit-datetime-edit-month-field,
.form-control[type="date"]:focus::-webkit-datetime-edit-day-field,
.form-control[type="date"].has-value::-webkit-datetime-edit-day-field,
.form-control[type="date"]:focus::-webkit-datetime-edit-text,
.form-control[type="date"].has-value::-webkit-datetime-edit-text {
  color: #333;
}

/* --- 下拉框 (select) 的高级颜色定制 --- */
select.form-control {
  color: #999; /* 默认未选择时灰色 */
}
select.form-control option {
  color: #333; /* 选项列表内黑色 */
}
select.form-control:focus,
select.form-control.has-value {
  color: #333 !important;
}
/* 解决原生 :valid 有时误判空值为 valid 的情况 */
select.form-control[required]:invalid {
  color: #999 !important;
}

textarea.form-control {
  resize: vertical;
  min-height: 240px;
}

select.form-control {
  appearance: none;
  /* 自定义简易下拉三角 */
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
}

/* --- 按钮样式抽象 --- */
.btn-primary {
  padding: 14px 24px;
  background-color: var(--primary-color);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 4px 10px rgba(51, 112, 255, 0.3);
  width: 100%;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(51, 112, 255, 0.35);
}

.btn-primary:active {
  transform: translateY(1px);
  box-shadow: 0 2px 5px rgba(51, 112, 255, 0.2);
}

/* 按钮禁用验证颜色兜底 */
.btn-disabled {
  background: #cccccc !important;
  box-shadow: none !important;
  color: #ffffff !important;
  cursor: pointer;
}

.btn-disabled:hover {
  transform: none !important;
}

/* --- 结果区域抽象与 Markdown 美化 --- */
.result-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eee;
}

.result-content {
  flex: 1;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.8;
  color: #444;
  padding: 10px;
}

.result-placeholder {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #aaa;
  font-style: italic;
}

/* --- Markdown 元素细节样式 --- */
.markdown-h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-color);
  margin: 24px 0 12px 0;
  padding-left: 12px;
  border-left: 4px solid var(--primary-color);
  line-height: 1.4;
}

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

.markdown-h3::before {
  content: "•";
  color: var(--primary-color);
  margin-right: 8px;
  font-size: 20px;
}

.markdown-p {
  margin: 0 0 12px 0;
}

.markdown-bold {
  color: #222;
  font-weight: 700;
}

.markdown-list {
  padding-left: 20px;
  margin: 0 0 16px 0;
  list-style: none;
}

.markdown-list li {
  position: relative;
  margin-bottom: 8px;
}

.markdown-list li::before {
  content: "";
  position: absolute;
  left: -18px;
  top: 10px;
  width: 6px;
  height: 6px;
  background-color: var(--primary-color);
  border-radius: 50%;
  opacity: 0.7;
}

.markdown-quote {
  margin: 16px 0;
  padding: 12px 20px;
  background-color: #f9f9f9;
  border-left: 4px solid #ddd;
  color: #666;
  font-style: italic;
  border-radius: 0 8px 8px 0;
}

.markdown-spacer {
  height: 12px;
}

.markdown-formula {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  background-color: rgba(51, 112, 255, 0.05);
  color: var(--primary-color);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.markdown-frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  align-items: center;
  font-size: 0.85em;
  margin: 0 2px;
  line-height: 1.1;
}

.markdown-frac sup {
  border-bottom: 1px solid currentColor;
  padding: 0 2px;
  position: static;
}

.markdown-frac sub {
  padding: 0 2px;
  position: static;
}

/* 诊断加载转圈动画 */
.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(51, 112, 255, 0.2);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin { 
  to { transform: rotate(360deg); } 
}

/* Markdown 表格样式 */
.markdown-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
  line-height: 1.5;
  border: 1px solid #eee;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.markdown-table th {
  background-color: #f8f9fa;
  color: #333;
  font-weight: 600;
  text-align: left;
  padding: 12px 15px;
  border-bottom: 2px solid #eee;
  border-right: 1px solid #eee;
}

.markdown-table th:last-child {
  border-right: none;
}

.markdown-table td {
  padding: 12px 15px;
  border-bottom: 1px solid #eee;
  border-right: 1px solid #eee;
  color: #555;
  vertical-align: top;
}

.markdown-table td:last-child {
  border-right: none;
}

.markdown-table tr:nth-child(even) {
  background-color: #fafafa;
}

.markdown-table tr:hover {
  background-color: #f1f4f8;
  transition: background-color 0.2s;
}

.markdown-table tr:last-child td {
  border-bottom: none;
}