/* CSS变量定义 - 只保留浅色调 */
:root {
  /* 浅色主题变量 */
  --text-color: #333;
  --text-secondary: #777;
  --card-bg-color: #fff;
  --border-color: #ddd;
  --code-bg-color: #f8f9fa;
  --input-bg-color: #fff;
  --primary-color: #007bff;
  --primary-hover-color: #0056b3;
  --primary-color-rgb: 0, 123, 255;
  --success-color: #28a745;
  --success-hover-color: #218838;
  --danger-color: #dc3545;
  --warning-color: #ffc107;
  --error-color: #dc3545;
  --link-color: #007bff;
  --header-bg-color: #e9ecef;
  --header-text-color: #333;
  --row-alt-bg-color: #f2f2f2;
}

/* 全局字体优化 */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden; /* 防止水平滚动条 */
  margin: 0;
  padding: 0;
  color: #333;
}

/* 滚动条美化 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

/* PFIC Calculator Page Styles */
.pfic-container {
  width: 100%;
  height: 100vh;               /* 明确限定一屏高度 */
  padding: 5px;
  box-sizing: border-box;
  overflow: hidden;            /* 禁止整体滚动 */
  color: #333;
}

.pfic-title {
  font-size: 24px;
  font-weight: bold;
  margin: 0 0 5px 0;
  color: #333;
  text-align: left;
  padding-left: 5px;
}

.pfic-subtitle {
  font-size: 14px;
  color: #777;
  margin: 0 0 20px 0;
  text-align: left;
  padding-left: 5px;
}

/* Three-column layout */
.pfic-main-content {
  display: flex;
  gap: 15px;
  justify-content: space-between;
  height: calc(100% - 20px); /* 减去标题所占空间 */
  overflow: hidden; /* 防止整体滚动 */
}

.pfic-left-column {
  flex: 0 0 28%;
}

.pfic-middle-column {
  flex: 0 0 30%;
}

.pfic-right-column {
  flex: 0 0 40%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 15px;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 5px;
}

.pfic-section {
  background-color: #fff;
  border-radius: 10px; /* 更圆润的边角 */
  padding: 18px; /* 增加内边距 */
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08); /* 更精致的阴影 */
  border: 1px solid rgba(0, 0, 0, 0.05); /* 微妙的边框 */
  margin-bottom: 15px; /* 👈 新增：拉开 section 间距 */
}

.pfic-section-title {
  font-size: 17px;
  margin: 0 0 18px 0;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
  color: #333;
  font-weight: 600;
  letter-spacing: 0.3px; /* 微调字间距 */
}

/* 指令区样式改进 */
.pfic-instruction-list {
  margin-top: 15px;
}

.pfic-instruction-item {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px dashed #eee;
}

.pfic-instruction-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

/* Input styles */
.pfic-label {
  display: block;
  font-size: 15px;
  font-weight: bold;
  color: #3080d0;
  margin-bottom: 8px;
  letter-spacing: 0.2px;
}

/* 重要！添加强制颜色样式 */
.pfic-instruction-item h4 {
  color: #3080d0 !important;
  font-weight: bold !important;
  margin-bottom: 8px;
  font-size: 15px;
}

.pfic-instruction-item p {
  font-size: 14px;
  line-height: 1.6;
  color: #555;
  margin-top: 5px;
}

.pfic-file-input-wrapper {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
  gap: 10px;
  flex-direction: row;
  justify-content: flex-start;
}

.pfic-file-input {
  display: inline-block;
  font-size: 14px;
  cursor: pointer;
  padding: 8px;
  border: 2px dashed #ddd;
  border-radius: 6px;
  background-color: #fafafa;
  width: 100%;
  transition: all 0.2s ease;
}

.pfic-file-input:hover {
  border-color: #007bff;
  background-color: #f0f7ff;
}

/* 文件名显示样式 */
#pficFileName {
  font-size: 14px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
  padding: 6px 10px;
  background-color: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
  border: 1px solid #ddd;
}

/* CSV提示信息样式增强 */
.pfic-file-hint {
  font-size: 13px;
  margin: 12px 0 15px;
  padding: 10px 12px;
  border-radius: 6px;
  background-color: rgba(255, 193, 7, 0.1);
  border-left: 3px solid #ffc107;
  color: #333;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 添加空类别错误提示样式 */
.pfic-empty-category {
  padding: 15px;
  background-color: rgba(255, 0, 0, 0.05);
  border-left: 3px solid #dc3545;
  color: #dc3545;
  border-radius: 6px;
  margin-bottom: 15px;
  font-size: 14px;
}

/* 保持原有日期字段和下拉菜单并排布局 */
.pfic-date-container {
  display: flex;
  flex-wrap: nowrap;
  gap: 15px;
  width: 100%;
}

/* 所有 .pfic-date-container 之间有底部间距，除了最后一组 */
.pfic-date-container:not(:last-child) {
  margin-bottom: 18px;
}

/* 子元素配置行（PFIC开始/结束、货币、税年、汇率、单价） */
.pfic-date-container .pfic-config-row {
  flex: 1;
  margin-bottom: 0;
  min-width: 0;
  max-width: calc(50% - 10px);
}

/* 三栏容器：仅用于三栏平分 */
.pfic-date-container.pfic-three-cols {
  display: flex;
  gap: 5px;
  width: 100%;
}

/* 三个区块平均宽度（考虑两个5px间距） */
.pfic-date-container.pfic-three-cols .pfic-config-row {
  width: calc((100% - 10px) / 3);
  display: flex;
  flex-direction: column;
}

/* 强制 input/select 撑满父容器 */
.pfic-date-container.pfic-three-cols .pfic-input,
.pfic-date-container.pfic-three-cols .pfic-select {
  width: 100%;
  box-sizing: border-box;
}


/* 👇 去掉数字输入框的上下箭头 */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield; /* Firefox */
}

/* 修复选择类型下拉框宽度问题 */
.pfic-category-select {
  width: 200px !important;
  max-width: 200px !important;
  min-width: 140px !important;
  padding: 9px 28px 9px 12px;
  border-radius: 6px;
  border: 1px solid #ddd;
  font-size: 14px;
  appearance: none;
  -webkit-appearance: none;
  background-color: #fff;
  color: #333;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23333333' 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 10px center;
  background-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  margin-left: auto;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: all 0.2s ease;
}

.pfic-category-select:hover {
  border-color: #b3d7ff;
}

.pfic-category-select option {
  background-color: #fff;
  color: #333;
  padding: 8px;
}

/* 添加选择框默认选项的样式 */
.pfic-category-select option[value=""] {
  color: #dc3545 !important; /* 红色文本 */
  font-weight: 500 !important;
}

/* 为选择框添加表单验证外观 */
.pfic-category-select:invalid {
  border-color: #dc3545;
  background-color: rgba(220, 53, 69, 0.05);
}

/* 当选择"-- Select Type --"时，让选择框文本显示为红色 */
.pfic-category-select:has(option[value=""]:checked) {
  color: #dc3545 !important;
  border-color: #dc3545;
}

.pfic-button {
  padding: 10px 18px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
  letter-spacing: 0.3px;
}

.pfic-browse-button {
  background-color: #007bff;
  color: white;
}

.pfic-browse-button:hover {
  background-color: #0056b3;
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.pfic-config-row {
  margin-bottom: 16px;
}

.pfic-inline-row {
  display: flex;
  gap: 10px;
}

.pfic-inline-row > div {
  flex: 1;
}

/* Improved select styling for better contrast */
.pfic-select {
  width: 100%;
  padding: 10px 16px;
  border-radius: 6px;
  border: 1px solid #ddd;
  background-color: #fff;
  color: #333;
  font-size: 14px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='currentColor' 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 10px center;
  background-size: 14px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: all 0.2s ease;
}

.pfic-select:hover {
  border-color: #b3d7ff;
}

.pfic-select option {
  background-color: #ffffff;
  color: #333333;
  padding: 10px;
}

.pfic-input {
  width: 90%;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid #ddd;
  background-color: #fff;
  color: #333;
  font-size: 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: all 0.2s ease;
}

.pfic-input:hover {
  border-color: #b3d7ff;
}

.pfic-input:focus,
.pfic-select:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 5px rgba(0, 123, 255, 0.4);
}

/* Action section */
.pfic-action-section {
  margin-top: 20px;
  display: flex;
  justify-content: center;
}

.pfic-calculate-button {
  background-color: #4caf50;
  color: white;
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: bold;
  border-radius: 8px;
  border: none;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.5px;
}

.pfic-calculate-button:hover:not(:disabled) {
  background-color: #3d9140;
  transform: translateY(-2px);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.15);
}

.pfic-calculate-button:disabled {
  background-color: #9e9e9e;
  cursor: not-allowed;
  opacity: 0.7;
}

/* Data mapping area */
.pfic-data-mapping {
  margin-top: 15px;
}

.pfic-category-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
  padding: 10px 12px;
  border-radius: 6px;
  background-color: #f8f9fa;
  border: 1px solid #eee;
  transition: all 0.2s ease;
}

.pfic-category-item:hover {
  background-color: #f0f7ff;
  border-color: #d0e1fd;
}

.pfic-category-item.even-row {
  background-color: #f8f9fa;
}

.pfic-category-item.odd-row {
  background-color: #ffffff;
}

.pfic-category-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 12px;
  font-weight: 500;
}

/* Results area */
.pfic-results-area {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}


.pfic-results-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  background-color: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 6px;
}


/* 视图容器 */
.pfic-view {
  flex: 1;
  min-height: 0; /* 允许内容收缩 */
  display: flex;
  flex-direction: column;
}

#pficMappingView {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}


.pfic-category-mapping {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.pfic-category-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 5px 10px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 结果视图 */
#pficResultsView {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* 日志内容区域 */
#pficLogContent {
  height: calc(100% - 15px); /* 留出空间给下载按钮 */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px;
  background: #fff;
  border-radius: 4px;
  border: 1px solid #ddd;
}

/* 下载区域 */
.pfic-download-section {
  flex-shrink: 0;
  margin-top: 10px;
  padding: 10px 0 0;
  border-top: 1px solid #ddd;
  text-align: center;
}

.pfic-placeholder-text {
  color: #777;
  font-style: italic;
  text-align: center;
  padding: 15px 0;
  font-size: 14px;
}

/* Log entries */
.pfic-log-entry {
  margin-bottom: 8px;
  padding: 5px 0;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 13.5px;
  line-height: 1.5;
}

.pfic-log-time {
  color: #777;
  margin-right: 8px;
  font-weight: 500;
}

.pfic-log-info .pfic-log-message {
  color: #333;
}

.pfic-log-success .pfic-log-message {
  color: #28a745;
  font-weight: 500;
}

.pfic-log-error .pfic-log-message {
  color: #dc3545;
  font-weight: 500;
}

.pfic-log-warning .pfic-log-message {
  color: #ffc107;
  font-weight: 500;
}

.pfic-log-config .pfic-log-message {
  color: #d9534f;
  font-weight: 500;
}

/* Download section */
.pfic-download-button {
  background-color: #28a745;
  color: white;
  padding: 12px 24px;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  letter-spacing: 0.3px;
}

.pfic-download-button:hover {
  background-color: #218838;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* 链接样式 - 增强版 */
.pfic-template-link {
  color: #007bff !important;
  text-decoration: underline !important;
  cursor: pointer;
  font-weight: bold !important;
  font-size: 14px !important;
  padding: 5px 10px !important;
  border-radius: 4px !important;
  background-color: rgba(0, 123, 255, 0.1) !important;
  transition: all 0.2s ease !important;
  display: inline-block !important;
}

.pfic-template-link:hover {
  background-color: rgba(0, 123, 255, 0.2) !important;
  text-decoration: underline !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1) !important;
}

/* 下载链接区域样式 */
.pfic-download-link {
  margin: 18px 0;
  padding: 10px 12px;
  background-color: rgba(0, 123, 255, 0.05);
  border-radius: 6px;
  border-left: 3px solid #007bff;
  display: inline-block;
  transition: all 0.2s ease;
}

.pfic-download-link:hover {
  background-color: rgba(0, 123, 255, 0.1);
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* FIFO表格样式 */
.pfic-fifo-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 18px;
  background-color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border-radius: 6px;
  overflow: hidden; /* 确保圆角生效 */
}

.pfic-fifo-table th,
.pfic-fifo-table td {
  padding: 10px 12px;
  text-align: right;
  border: 1px solid #eee;
  font-size: 13.5px;
}

.pfic-fifo-table th {
  background-color: #e9ecef;
  color: #333;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 12.5px;
  letter-spacing: 0.5px;
}

.pfic-fifo-table tr:nth-child(even) {
  background-color: #f2f2f2;
}

.pfic-fifo-table tr:hover {
  background-color: #f0f7ff;
}

/* 映射视图标题部分 */
.pfic-mapping-header {
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Tips 按钮样式 */
.pfic-tips-btn {
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pfic-tips-btn:hover {
  background-color: #0056b3;
  transform: translateY(-1px);
}

.pfic-header-tips {
  margin-bottom: 18px;
  padding: 12px 15px;
  background-color: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13.5px;
  line-height: 1.5;
}

.pfic-header-tips ul {
  margin-top: 8px;
  padding-left: 25px;
}

.pfic-header-tips li {
  margin-bottom: 8px;
}

.pfic-header-tips li strong {
  font-weight: 600;
}

.pfic-header-tips li em {
  font-style: italic;
}

.clean-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 5px;
  border-bottom: 1px solid #ddd;
}

.pfic-mapping-title {
  margin: 0;
  font-size: 16px;
}

.pfic-tips-btn {
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
}

.pfic-header-tips {
  margin-bottom: 15px;
  padding: 10px;
  background-color: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.4;
}

.pfic-header-tip-list {
  margin-top: 5px;
  padding-left: 20px;
}

.pfic-tip-warning {
  color: red;
}

.hide {
  display: none;
}

.pfic-disclaimer-box {
  background-color: #f8f9fa;
  padding: 20px;
  border-radius: 6px;
  border: 1px solid #e2e6ea;
  margin-bottom: 20px;
  font-size: 0.95rem;
}

.pfic-disclaimer-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: #333;
}

.pfic-disclaimer-body p {
  margin-bottom: 12px;
  line-height: 1.6;
  color: #444;
}

.pfic-disclaimer-note {
  font-style: italic;
  color: #666;
  font-size: 0.92em;
}
