/* General styles */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f5f5f5;
}

#login-container {
    max-width: 400px;
    margin: 50px auto;
    padding: 20px;
    background-color: white;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

#login-container h2 {
    text-align: center;
    margin-bottom: 20px;
}

#login-container div {
    margin-bottom: 15px;
}

#login-container label {
    display: block;
    margin-bottom: 5px;
}

#login-container input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

#login-container button {
    width: 100%;
    padding: 10px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#login-container button:hover {
    background-color: #45a049;
}

#main-container {
    max-width: 1200px;
    margin: 0 auto;
    background-color: white;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 20px;
    overflow-x: auto; /* 确保容器可以水平滚动 */
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

header h1 {
    margin: 0;
    color: #333;
}

#user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

#user-info button {
    padding: 5px 10px;
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#user-info button:hover {
    background-color: #0b7dda;
}

#controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}

#controls select,
#controls input,
#controls button {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
}

#controls button {
    background-color: #2196F3;
    color: white;
    cursor: pointer;
    border: none;
}

#controls button:hover {
    background-color: #0b7dda;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.large-modal {
    width: 90%;
    height: 80%;
}

.modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 5px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-content h3 {
    margin-top: 0;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.form-actions button {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.form-actions button[type="submit"] {
    background-color: #4CAF50;
    color: white;
}

.form-actions button[type="button"] {
    background-color: #f44336;
    color: white;
}

.form-actions button:hover {
    opacity: 0.9;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    table-layout: fixed; /* 固定表格布局 */
}

th, td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #ddd;
    vertical-align: top;
    word-wrap: break-word; /* 确保长内容换行 */
}

th {
    background-color: #f2f2f2;
    font-weight: bold;
    position: sticky; /* 固定表头 */
    top: 0;
}

.narrow {
    width: 60px; /* 设置窄列的固定宽度 */
    text-align: center;
}

th.narrow {
    text-align: center;
    padding: 10px 5px; /* 保持与普通单元格相同的上下padding，但减少左右padding */
    font-weight: bold;
    background-color: #f2f2f2;
    border-bottom: 1px solid #ddd;
}

tr:hover {
    background-color: #f5f5f5;
}

.editable {
    cursor: pointer;
    position: relative;
}

.editable:hover::after {
    content: "✏️";
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.6;
}

.truncated {
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pending-button {
    background-color: #FF9800;
    color: white;
    border: none;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: not-allowed;
    font-size: 12px;
    min-width: 30px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 24px;
    margin: 0 auto;
}


    background-color: #2196F3;
    color: white;
    border: none;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    min-width: 30px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 24px;
    margin: 0 auto; /* 居中按钮 */
}

.delete-button:hover {
    background-color: #0b7dda;
}

.reason-button {
    background-color: #FF9800;
    color: white;
    border: none;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    min-width: 30px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 24px;
    margin: 0 auto;
}

.reason-button:hover {
    background-color: #e68900;
}

.modified {
    text-align: center;
    position: relative;
}

.modified.has-change::before {
    content: "*";
    color: red;
    font-size: 6px;
    position: absolute;
    top: 2px;
    left: 2px;
}

.modified .red-star {
    display: none;
}

.modified.has-change .red-star {
    display: inline;
    color: red;
    font-size: 16px;
}

footer {
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid #eee;
    text-align: center;
}

footer button {
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

footer button:hover {
    background-color: #45a049;
}

.red-star {
    color: red;
}

/* Alert styles */
.alert-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.alert-box {
    display: flex;
    align-items: center;
    padding: 15px;
    border-radius: 5px;
    min-width: 300px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    position: relative;
}

.alert-box.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-box.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-message {
    flex-grow: 1;
    margin-right: 10px;
}

.alert-close-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: inherit;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   Admin Controls - 右浮动下拉框
   ============================================ */
#admin-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

#admin-controls label {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
}

#admin-controls select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff3e0;
    font-size: 13px;
    cursor: pointer;
}

#admin-controls select:focus {
    outline: none;
    border-color: #FF9800;
}

#admin-search-field {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #e3f2fd;
    font-size: 13px;
    cursor: pointer;
}

#admin-search-input {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    width: 150px;
}

#admin-search-btn {
    padding: 6px 12px;
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

#admin-search-btn:hover {
    background-color: #0b7dda;
}

#admin-search-reset-btn {
    padding: 6px 12px;
    background-color: #9e9e9e;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

#admin-search-reset-btn:hover {
    background-color: #757575;
}

/* ============================================
   Footer 布局：New Row 在 Submit 左边
   ============================================ */
#page-footer {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

#page-footer button {
    padding: 10px 20px;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

#save-changes-btn {
    background-color: #4CAF50;
}

#save-changes-btn:hover {
    background-color: #45a049;
}

#add-row-btn {
    background-color: #FF9800;
}

#add-row-btn:hover {
    background-color: #e68900;
}

/* ============================================
   单元格内 * 标记（表示已修改）
   适用于所有 editable 单元格
   ============================================ */
.cell-modified::before {
    content: "*";
    color: red;
    font-size: 8px;
    font-weight: bold;
    position: absolute;
    top: 1px;
    left: 2px;
    line-height: 1;
    pointer-events: none;
}

/* ============================================
   审批表布尔字段 * 标记（字段为 true 时显示）
   ============================================ */
td.bool-true {
    position: relative;
}

td.bool-true::before {
    content: "*";
    color: #e65100;
    font-size: 9px;
    font-weight: bold;
    position: absolute;
    top: 1px;
    left: 2px;
    line-height: 1;
}

/* ============================================
   审批表 Action 字段值（显示在 ID 单元格角标）
   ============================================ */
td.action-cell {
    position: relative;
}

td.action-cell .action-badge {
    display: block;
    font-size: 8px;
    color: #1565C0;
    font-weight: bold;
    line-height: 1;
    margin-top: 1px;
}

/* ============================================
   密码单元格样式
   ============================================ */
.password-cell {
    color: #999;
    font-style: italic;
}

.password-cell::after {
    content: "🔒";
    margin-left: 5px;
    opacity: 0.6;
}

/* ============================================
   Info 类型的提示框
   ============================================ */
.alert-box.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* ============================================
   审批操作弹窗按钮样式
   ============================================ */
.approval-action-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
}

.action-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    min-width: 80px;
}

.reject-btn {
    background-color: #f44336;
    color: white;
}

.reject-btn:hover {
    background-color: #d32f2f;
}

.delete-btn {
    background-color: #9e9e9e;
    color: white;
}

.delete-btn:hover {
    background-color: #757575;
}

.accept-btn {
    background-color: #4CAF50;
    color: white;
}

.accept-btn:hover {
    background-color: #45a049;
}

.confirm-reject-btn {
    background-color: #f44336;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

.cancel-btn {
    background-color: #9e9e9e;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

/* ============================================
   Act 按钮样式
   ============================================ */
.act-button {
    background-color: #2196F3;
    color: white;
    border: none;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    min-width: 30px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 24px;
    margin: 0 auto;
}

.act-button:hover {
    background-color: #0b7dda;
}

.act-button.pending {
    background-color: #FF9800;
}

.act-button.rejected, .act-button.rejected-btn {
    background-color: #f44336;
}

.act-button.accepted {
    background-color: #4CAF50;
}