body {
    font-family: sans-serif;
    line-height: 1.6;
    padding: 20px;
    background-color: #f4f4f4;
}

.container {
    max-width: 1000px;
    margin: auto;
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

h1,
h2 {
    text-align: center;
    color: #333;
}

.logout-link {
    float: right;
    margin-top: -40px;
}

form {
    margin-bottom: 20px;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #f9f9f9;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
}

/* 表格里的删除等操作表单不要套用页面大表单的卡片样式 */
table td form {
    display: inline-flex;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    gap: 6px;
    align-items: center;
    vertical-align: middle;
}

table td button.delete-link,
table td .button.delete {
    background: none;
    border: none;
    padding: 0;
    margin-left: 8px;
    color: #d9534f;
    cursor: pointer;
    font-size: 14px;
}

/* 挂在表格外、只给删除按钮提交用的空表单 */
form.inline-action {
    display: none;
}

/* 生成卡密表单按网格排列，避免字段挤在一行 */
#generate-kami-form {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    align-items: end;
}

#generate-kami-form .form-span {
    grid-column: 1 / -1;
}

.package-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.package-preset {
    border: 1px solid #5bc0de;
    background: #fff;
    color: #31708f;
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
}

.package-preset.is-inactive {
    opacity: 0.55;
    border-style: dashed;
}

.package-preset.is-selected {
    background: #5bc0de;
    color: #fff;
}

label {
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
    font-size: 14px;
}

input[type="number"],
input[type="text"],
input[type="password"],
input[type="submit"],
select {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 14px;
}

input[type="submit"] {
    background-color: #5cb85c;
    color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s ease;
    align-self: flex-end;
    /* 与其他输入框底部对齐 */
    height: 37px;
    /* 与其他输入框高度一致 */
}

input[type="submit"]:hover {
    background-color: #4cae4c;
}

.message {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
    clear: both;
}

.success {
    background-color: #dff0d8;
    color: #3c763d;
    border: 1px solid #d6e9c6;
}

.error {
    background-color: #f2dede;
    color: #a94442;
    border: 1px solid #ebccd1;
}

.filter-search-form {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-bottom: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    font-size: 14px;
}

th,
td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

th {
    background-color: #f2f2f2;
    color: #333;
}

tr:nth-child(even) {
    background-color: #f9f9f9;
}

.status-used {
    color: #a94442;
}

.status-unused {
    color: #3c763d;
}

.generated-cards {
    margin-top: 15px;
    padding: 10px;
    border: 1px dashed #ccc;
    border-radius: 4px;
    background-color: #e9f5e9;
    max-height: 150px;
    overflow-y: auto;
}

/* 弹窗样式 */
.modal {
    display: none;
    /* 默认隐藏 */
    position: fixed;
    /* 固定定位 */
    z-index: 1000;
    /* 置于顶层 */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    /* Enable scroll if needed */
    background-color: rgba(0, 0, 0, 0.5);
    /* 半透明黑色背景 */
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    /* 垂直居中，水平自动 */
    padding: 30px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    /* 最大宽度 */
    border-radius: 8px;
    position: relative;
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}

.modal-close-btn {
    color: #aaa;
    position: absolute;
    /* 相对于 .modal-content 定位 */
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.modal-close-btn:hover,
.modal-close-btn:focus {
    color: black;
    text-decoration: none;
}

/* 修改密码和登出按钮的容器 */
.header-buttons {
    display: flex;
    justify-content: flex-end;
    /* 将按钮推到右边 */
    align-items: center;
    /* 垂直居中 */
    margin-bottom: 15px;
    /* 在按钮下方留出空间 */
    /* height: 37px; */
    /* 可以根据按钮高度设置容器高度，或用 align-items */
}

/* 修改密码和登出按钮公共样式 */
.admin-header-btn {
    padding: 8px 15px;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    /* float: right; */
    /* 移除 float */
    /* margin-top: -45px; */
    /* 移除 margin-top */
    text-decoration: none;
    /* 如果是链接则去除下划线 */
    display: inline-block;
    /* 使链接表现像按钮 */
    box-sizing: border-box;
    /* 包含 padding 和 border */
}

/* 修改密码按钮特定样式 (左边的按钮) */
.change-password-btn {
    background-color: #f0ad4e;
    /* 黄色按钮 */
    margin-left: 10px;
    /* 保持左边距，与右侧按钮隔开 */
}

.change-password-btn:hover {
    background-color: #ec971f;
}

/* 登出按钮特定样式 (右边的按钮) */
.logout-btn {
    background-color: #d9534f;
    /* 红色按钮 */
    /* 不需要额外边距，因为它会自然靠右 */
}

.logout-btn:hover {
    background-color: #c9302c;
}

/* 登录页面的样式（如果需要分离，也放在这里） */
.login-container {
    background: #fff;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
    width: 300px;
    text-align: center;
}

/* 如果登录页面有独立的body样式，可以考虑添加特定的class */
/* 例如 body.login-page { ... } */
body.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* 登录表单内的元素 */
.login-container h1 {
    margin-bottom: 20px;
    color: #333;
}

.login-container input[type="text"],
.login-container input[type="password"] {
    width: calc(100% - 22px);
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.login-container input[type="submit"] {
    width: 100%;
    padding: 10px;
    background-color: #5cb85c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

.login-container input[type="submit"]:hover {
    background-color: #4cae4c;
}

.login-container .error {
    color: #a94442;
    background-color: #f2dede;
    border: 1px solid #ebccd1;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.login-container .g-recaptcha {
    margin-bottom: 15px;
    transform: scale(0.9);
    transform-origin: 0 0;
    display: inline-block; /* 使 transform 生效 */
}

header {
    border-bottom: 1px solid #eee;
    margin-bottom: 20px;
    padding-bottom: 15px;
}

header h1 {
    margin: 0 0 15px 0;
    font-size: 24px;
    text-align: left; /* 标题左对齐 */
}

header nav {
    display: flex; /* 使用 Flexbox 布局 */
    flex-wrap: wrap; /* 允许换行 */
    align-items: center; /* 垂直居中对齐 */
    gap: 10px; /* 设置元素之间的间距 */
}

/* 将导航链接<a>样式设置为按钮样式 */
header nav a {
    padding: 8px 15px;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none; /* 去除下划线 */
    display: inline-block;
    box-sizing: border-box;
    background-color: #5bc0de; /* 统一设置为蓝色按钮 */
    transition: background-color 0.3s ease;
    text-align: center;
}

header nav a:hover {
    background-color: #31b0d5; /* 悬停时加深蓝色 */
}

/* 活动导航链接样式 */
header nav a.active {
    background-color: #31708f; /* 活动链接使用更深的蓝色 */
    font-weight: bold;
}

/* 登出链接样式 - 保持红色 */
header nav a[href*="action=logout"] {
     background-color: #d9534f;
}
header nav a[href*="action=logout"]:hover {
     background-color: #c9302c;
}

/* 修改密码按钮特定样式 (黄色按钮) */
.change-password-btn {
    background-color: #f0ad4e;
    /* margin-left: 10px; */ /* 移除左边距，使用 flex gap */
    /* float: right; */ /* 移除浮动 */
    /* 确保继承或包含基础按钮样式 */
    padding: 8px 15px;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    display: inline-block;
    box-sizing: border-box;
    transition: background-color 0.3s ease;
}

/* --- Settings Page Specific Styles --- */

/* 整体表单容器 */
.settings-form {
    border: none; /* 移除 settings-form 的边框，因为 section 会有 */
    padding: 0; /* 移除 settings-form 的内边距 */
    background-color: transparent; /* 移除背景色 */
    display: flex; /* 改回 flex，按 section 垂直排列 */
    flex-direction: column;
    gap: 25px; /* section 之间的垂直间距 */
}

/* 新增：包裹两个 section 的布局容器 */
.settings-layout-container {
    display: flex;
    flex-direction: row; /* 水平排列 */
    gap: 25px; /* section 之间的水平间距 */
}

/* 每个设置区域的容器 */
.settings-section {
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 20px;
    background-color: #f9f9f9;
    flex: 1; /* 让每个 section 占据可用空间的一半 */
}

.settings-section h3 {
    text-align: left; /* 标题左对齐 */
    margin-top: 0;
    margin-bottom: 20px;
    color: #337ab7; /* 蓝色标题 */
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

/* 表单网格布局 */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); /* 响应式网格，最小宽度 300px */
    gap: 20px; /* 网格项之间的间距 */
}

/* 默认表单组 */
.settings-form .form-group {
    display: flex;
    flex-direction: column; /* 标签在输入框上方 */
}

/* 跨列的表单组 */
.settings-form .form-group.wide {
    grid-column: span 2; /* 占据两列 */
}

/* 特定输入框样式调整 */
.settings-form input[type="text"],
.settings-form input[type="number"],
.settings-form input[type="password"],
.settings-form input[type="email"],
.settings-form input[type="url"],
.settings-form select {
    width: 100%; /* 输入框宽度占满其网格单元 */
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 14px;
}

.settings-form label {
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
    font-size: 14px;
}

.settings-form small {
    font-size: 0.9em;
    color: #777; /* 稍微调深一点颜色 */
    margin-top: 5px; /* 增加一点上方间距 */
}

/* 单选按钮组容器 */
.settings-form .radio-group-container {
    display: flex;
    flex-direction: column; /* 垂直排列支付宝和微信组 */
    gap: 10px; /* 组之间的间距 */
}

.settings-form .radio-group {
    display: flex;
    align-items: center;
    margin-top: 0; /* 覆盖之前的 margin-top */
}

.settings-form .radio-group input[type="radio"] {
    margin-right: 5px;
}

.settings-form .radio-group label {
    margin-right: 20px; /* 单选按钮选项之间的间距 */
    font-weight: normal;
    margin-bottom: 0; /* 移除标签下边距 */
}

/* 表单操作按钮区域 */
.form-actions {
    grid-column: 1 / -1; /* 让按钮容器跨越所有列 */
    display: flex;
    justify-content: flex-end; /* 按钮右对齐 */
    margin-top: 15px; /* 在按钮上方增加一些间距 */
}

.settings-form .button {
    /* 可以继承 admin.css 的 .button 样式 */
    /* 如果需要特定样式，可以在这里添加 */
    padding: 10px 20px; /* 增大按钮填充 */
}

/* --- End Settings Page Specific Styles --- */ 