/* 全局重置：全屏基础 */
:root {
    --border-color: #e5e7eb;
    --border-radius: 8px;
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.06);
    --spacing: 15px;
    /* 统一配色变量 */
    --tip-bg: #f5f7fa;
    --tip-border: #dee2e6;
    --tip-text: #555;
    --tip-padding: 8px 12px;
}
html, body {
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    background-color: #f8f9fa;
    box-sizing: border-box; /* 关键修改：统一盒模型，避免尺寸计算错误 */
}
* {
    box-sizing: border-box; /* 关键修改：所有元素使用border-box盒模型 */
}

/* 返回按钮样式 */
.editor-back-btn {
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 9999;
    padding: 8px 16px;
    background: #165DFF;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-decoration: none;
}
.editor-back-btn:hover {
    background: #0D47A1;
    color: white;
    text-decoration: none;
}

/* 全屏编辑器容器 */
.excel-fullscreen-container {
    width: 100vw;
    height: 100vh;
    padding: var(--spacing);
    /*padding-top: 60px; /* 给返回按钮留出空间 */
    display: flex;
    flex-direction: column;
    position: relative; /* 关键：添加相对定位，避免子元素溢出导致尺寸变化 */
}

/* 操作栏：自适应 + 适配全屏 */
.excel-toolbar {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: var(--spacing);
    flex-wrap: wrap;
    padding: 15px 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: #fff;
    box-shadow: var(--shadow-light);
    width: 100%;
}

/* 标题输入框样式 */
.table-title-input {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    width: 240px;
    transition: border-color 0.2s;
}
.table-title-input:focus {
    border-color: #165DFF;
    outline: none;
    box-shadow: 0 0 0 2px rgba(22, 93, 255, 0.1);
}
.table-title-input:disabled {
    background: #f9fafb;
    color: #666;
    cursor: not-allowed;
}

/* 通用按钮样式（新增：适配导入/导出/打印按钮） */
.excel-btn {
    padding: 8px 20px;
    background: #165DFF;
    color: white;
    border: 1px solid #165DFF !important;
    border-radius: 6px !important;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    flex-shrink: 0;
}
.excel-btn:hover {
    background: #0D47A1;
    border-color: #0D47A1 !important;
    box-shadow: 0 2px 4px rgba(22, 93, 255, 0.2);
}
.excel-btn-secondary {
    background: #6B7280;
    border-color: #6B7280 !important;
}
.excel-btn-secondary:hover {
    background: #4B5563;
    border-color: #4B5563 !important;
}

/* ========== 新增：成员管理样式 ========== */
.member-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: #f9fafb;
}
.member-input {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    width: 120px;
}
.member-input:focus {
    border-color: #165DFF;
    outline: none;
}

/* ========== 新增：成员下拉菜单样式 ========== */
.member-dropdown {
    position: relative;
    display: inline-block;
}
.member-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0; /* 右侧对齐，避免遮挡输入框 */
    min-width: 200px;
    max-height: 200px; /* 限制最大高度，避免溢出 */
    overflow-y: auto; /* 超出时滚动 */
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    z-index: 1000; /* 确保在最上层显示 */
    padding: 8px;
    margin-top: 4px;
}
.member-dropdown-menu.active {
    display: block;
}
/* 下拉菜单项样式 */
.member-dropdown-menu .member-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    border-bottom: 1px solid #f3f4f6;
}
.member-dropdown-menu .member-item:last-child {
    border-bottom: none;
}
.member-dropdown-menu .member-info {
    font-size: 14px;
    color: #333;
}
.member-dropdown-menu .delete-btn {
    padding: 2px 8px;
    background: #f53f3f;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}
.member-dropdown-menu .delete-btn:hover {
    background: #d92d2d;
}
.member-dropdown-menu .creator-tag {
    font-size: 12px;
    color: #165DFF;
    background: #e8f3ff;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 8px;
}

/* 权限下拉框样式 */
#permissionSelect {
    padding: 6px 12px;
    border: 1px solid var(--border-color) !important;
    border-radius: 6px !important;
    font-size: 14px;
    color: #333;
    transition: border-color 0.2s;
    flex-shrink: 0;
}
#permissionSelect:focus {
    border-color: #165DFF;
    outline: none;
    box-shadow: 0 0 0 2px rgba(22, 93, 255, 0.1);
}

/* Luckysheet核心容器：全屏（关键修改） */
#luckysheet-container {
    flex: 1; /* 占满剩余高度 */
    width: 100%;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--border-radius) !important;
    position: relative;
    overflow: hidden; /* 保留overflow，但移除padding-bottom */
    height: calc(100% - var(--spacing) - 80px); /* 固定高度计算，避免flex重绘变化 */
}

/* 关键修复：调整底部栏样式，避免遮挡且不影响容器尺寸 */
.luckysheet-statistic-bar,
.luckysheet-sheet-bar {
    z-index: 999 !important;
    position: absolute !important; /* 改为绝对定位，相对于容器 */
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 28px !important; /* 固定底部栏高度 */
}

/* 关键：给表格内容区域留出底部栏空间，不影响容器整体尺寸 */
.luckysheet-grid-container {
    padding-bottom: 28px !important;
}

/* 自动保存提示 */
.auto-save-tip {
    position: fixed;
    bottom: 40px; /* 调整位置，避开底部栏 */
    right: 20px;
    padding: 8px 16px;
    background: #00B42A;
    color: white;
    border-radius: 6px;
    display: none;
    z-index: 9999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #009a24;
}

/* 状态提示（核心优化：配色+间距与操作栏统一） */
.status-tip {
    color: var(--tip-text);
    font-size: 14px;
    padding: var(--tip-padding);
    border-radius: var(--border-radius);
    background: var(--tip-bg);
    border: 1px solid var(--tip-border);
    text-align: right;
    white-space: nowrap; /* 自适应内容宽度 */
    margin-left: auto; /* 靠右对齐 */
    margin-right: 0; /* 消除右侧间隙 */
    flex-shrink: 0; /* 防止被挤压变形 */
    /* 新增：覆盖原有内联样式，保持样式统一 */
    font-size: 12px;
    line-height: 1.5;
    color: #666;
    margin-top: 5px;
    word-wrap: break-word;
}

/* 只读提示 */
.readonly-tip {
    margin-bottom: var(--spacing);
    padding: 12px 15px;
    background: #fff7e6;
    border: 1px solid #ffc53d !important;
    border-radius: var(--border-radius) !important;
    color: #fa8c16;
    width: 100%;
}

/* 只读水印 */
.readonly-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    color: rgba(0,0,0,0.1);
    pointer-events: none;
    z-index: 1;
    user-select: none;
}

/* 隐藏类 */
.hidden {
    display: none !important;
}

/* 打印样式适配（新增） */
@media print {
    body * { visibility: hidden; }
    #luckysheet-container, #luckysheet-container * { visibility: visible; }
    #luckysheet-container { 
        position: absolute; 
        left: 0; 
        top: 0; 
        width: 100%;
        border: none !important;
        height: 100% !important;
    }
    .luckysheet-cell { border: 1px solid #000 !important; }
    .luckysheet-header-col, .luckysheet-header-row { background: #eee !important; }
    .editor-back-btn, .excel-toolbar, .auto-save-tip, .readonly-tip, .readonly-watermark { display: none !important; }
    .luckysheet-statistic-bar, .luckysheet-sheet-bar { display: none !important; }
}

/* 响应式适配 */
@media (max-width: 768px) {
    :root {
        --spacing: 10px;
        --tip-padding: 6px 10px; /* 移动端缩小内边距 */
    }
    .excel-toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .table-title-input, .member-input {
        width: 100%;
    }
    .member-group {
        width: 100%;
        flex-wrap: wrap;
    }
    .member-dropdown-menu {
        width: 100%;
        right: 0;
    }
    .status-tip {
        text-align: left;
        margin-left: 0; /* 移动端取消靠右 */
        width: 100%;
        white-space: normal;
        font-size: 13px; /* 移动端缩小字体 */
    }
    .editor-back-btn {
        top: 10px;
        left: 10px;
        padding: 6px 12px;
        font-size: 12px;
    }
    #luckysheet-container {
        height: calc(100% - var(--spacing) - 120px); /* 适配移动端高度 */
    }
}

/* ========== 新增：锁定提示样式（整合内联CSS） ========== */
.lock-tip { 
    background: #fff7e6; 
    color: #fa8c16; 
    padding: 8px 15px; 
    text-align: center; 
    font-size: 14px; 
    border-bottom: 1px solid #ffe58f; 
    margin-bottom: 10px; 
}
.lock-check-tip { 
    font-size: 12px; 
    color: #999; 
    margin-left: 10px; 
}
/* 最后编辑者信息样式高亮 */
.last-editor-info {
    color: #0ca821;
    font-weight: 500;
}
/* 最后编辑者容器样式 */
.last-editor-wrap {
    display: inline-block;
}
/* 完全锁定状态样式高亮 */
.full-lock-tag {
    color: #dc3545;
    font-weight: 600;
}

/* ========== 新增：无访问权限页面样式（整合内联CSS） ========== */
/* 单独给无权限页面重置body样式，避免和编辑器冲突 */
body.no-access-page {
    height: 100vh;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fa;
    overflow: auto; /* 恢复滚动，适配小屏幕 */
}
.no-access-container {
    width: 90%;
    max-width: 500px;
    padding: 30px;
    border: 1px solid #f5d6d6;
    border-radius: 8px;
    background: #fef2f2;
    text-align: center;
}
.no-access-container .btn {
    margin: 10px 5px;
    padding: 8px 20px;
    border-radius: 6px;
    text-decoration: none;
    display: inline-block;
}
.no-access-container .btn-primary {
    background: #165DFF;
    color: white;
    border: 1px solid #165DFF;
}
.no-access-container .btn-outline-primary {
    background: white;
    color: #165DFF;
    border: 1px solid #165DFF;
}
.no-access-container h2 {
    color: #f53f3f;
    margin-bottom: 20px;
}

/* ========== 新增：打印设置弹窗样式（不修改原有样式） ========== */
/* 弹窗遮罩层 */
.print-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99999; /* 高于所有现有元素（包括返回按钮的9999） */
}
/* 弹窗内容容器 */
.print-modal-content {
  background: #fff;
  padding: 20px;
  border-radius: var(--border-radius); /* 复用全局圆角变量，保持样式统一 */
  width: 400px;
  max-width: 90vw; /* 适配移动端 */
  box-shadow: var(--shadow-light); /* 复用全局阴影变量 */
  border: 1px solid var(--border-color); /* 复用全局边框色 */
}
/* 弹窗标题 */
.print-modal h3 {
  margin: 0 0 15px 0;
  font-size: 18px;
  color: #333;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}
/* 选项组 */
.print-option {
  margin-bottom: 12px;
}
.print-option label {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  color: #666;
}
/* 弹窗内输入框/下拉框样式（复用现有样式变量，保持视觉统一） */
.print-option input, .print-option select {
  width: 100%;
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
}
.print-option input:focus, .print-option select:focus {
  border-color: #165DFF;
  outline: none;
  box-shadow: 0 0 0 2px rgba(22, 93, 255, 0.1);
}
/* 弹窗按钮组 */
.print-modal-btns {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.print-modal-btns button {
  padding: 8px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}
/* 确认按钮（复用现有主按钮配色） */
.print-btn-confirm {
  background: #165DFF;
  color: white;
  border: 1px solid #165DFF !important;
}
.print-btn-confirm:hover {
  background: #0D47A1;
  border-color: #0D47A1 !important;
  box-shadow: 0 2px 4px rgba(22, 93, 255, 0.2);
}
/* 取消按钮（复用现有次要按钮配色） */
.print-btn-cancel {
  background: #6B7280;
  color: white;
  border: 1px solid #6B7280 !important;
}
.print-btn-cancel:hover {
  background: #4B5563;
  border-color: #4B5563 !important;
}

/* ========== 兼容调整：原有打印样式优化（仅补充，不修改） ========== */
@media print {
  /* 隐藏打印弹窗（避免打印时显示） */
  .print-modal {
    display: none !important;
  }
  /* 优化自定义打印表格的样式（和原有Luckysheet打印样式统一） */
  .print-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 14px;
  }
  .print-table td, .print-table th {
    border: 1px solid #000 !important;
    padding: 6px;
    text-align: center;
  }
  /* 修复原有打印样式：确保自定义打印内容可见 */
  body * {
    visibility: visible !important;
  }
  /* 仅隐藏无关元素（保留原有隐藏规则，补充弹窗） */
  .editor-back-btn, .excel-toolbar, .auto-save-tip, .readonly-tip, .readonly-watermark,
  .luckysheet-statistic-bar, .luckysheet-sheet-bar, .print-modal {
    display: none !important;
    visibility: hidden !important;
  }
}

/* ========== 移动端适配：打印弹窗响应式调整 ========== */
@media (max-width: 768px) {
  .print-modal-content {
    width: 90%;
    padding: 15px;
  }
  .print-modal-btns {
    flex-direction: column;
    gap: 8px;
  }
  .print-modal-btns button {
    width: 100%;
  }
}