* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background-color: #f5f5f5;
    padding: 20px;
    min-height: 100vh;
}

/* 与 body:flex 居中搭配时须写明确宽度，否则 flex 子项会按内容收缩成窄条（刷新时先宽后窄的闪烁） */
#loginContainer {
    width: min(600px, 100%);
    max-width: 600px;
    flex: 0 0 auto;
    margin: 0 auto;
    background-color: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

h1 {
    color: #333;
    margin-bottom: 20px;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
    height: 34px;
    line-height: 18px;
    display: inline-flex;
    align-items: center;
}

.add-btn {
    background-color: #4CAF50;
    color: white;
    margin-bottom: 20px;
    transition: all 0.2s ease;
}

.add-btn:hover {
    background-color: #2e7d32;
    box-shadow: 0 2px 8px rgba(46, 125, 50, 0.4);
    transform: translateY(-1px);
}

.add-btn:active {
    transform: translateY(0);
}

.edit-btn {
    background-color: #2196F3;
    color: white;
    margin-right: 15px;
}

.edit-btn:hover {
    background-color: #0b7dda;
}

.delete-btn {
    background-color: #f44336;
    color: white;
}

.delete-btn:hover {
    background-color: #d32f2f;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
    font-size: 13px;
}

/* 开启新标签页、排序、是否启用列居中对齐 */
th:nth-child(5),
th:nth-child(6),
th:nth-child(7),
td:nth-child(5),
td:nth-child(6),
td:nth-child(7) {
    text-align: center;
}

th {
    background-color: #f8f9fa;
    color: #333;
    font-weight: 600;
}

tr:hover {
    background-color: #f5f5f5;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 2% auto;
    padding: 30px;
    border-radius: 8px;
    width: 500px;
    position: relative;
    max-height: 85vh;
    overflow-y: auto;
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
}

.close:hover {
    color: #000;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #333;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrapper input[type="password"] {
    padding-right: 40px;
}

.password-toggle {
    position: absolute;
    right: 10px;
    cursor: pointer;
    color: #666;
    display: flex;
    align-items: center;
}

.password-toggle:hover {
    color: #333;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.switch-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.switch-group > label:first-child {
    display: inline;
    margin-bottom: 0;
    white-space: nowrap;
}

.form-row-inline {
    display: flex;
    align-items: center;
    gap: 28px;
    flex-wrap: wrap;
}

.form-row-inline .form-row-item {
    margin-bottom: 0;
    flex: 0 1 auto;
}

.tool-category-select {
    min-width: 160px;
    width: 180px;
    height: 40px;
    padding: 0 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: #333;
    outline: none;
    appearance: auto;
}

.tool-category-select:focus {
    border-color: #4e73df;
    box-shadow: 0 0 0 3px rgba(78, 115, 223, 0.12);
}

.form-actions {
    margin-top: 25px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.save-btn {
    background-color: #4CAF50;
    color: white;
}

.save-btn:hover {
    background-color: #45a049;
}

.cancel-btn {
    background-color: #9e9e9e;
    color: white;
}

.cancel-btn:hover {
    background-color: #757575;
}

/* 图标上传样式 */
.icon-upload {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.icon-preview {
    width: 80px;
    height: 80px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.icon-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.icon-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.icon-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-url-input {
    display: flex;
    align-items: center;
}

.icon-url-input input {
    flex: 1;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #3b82f6;
}

input:checked + .slider:before {
    transform: translateX(24px);
}

/* 表格中的开关 */
.table-switch {
    cursor: pointer;
}

.preview-placeholder {
    color: #999;
    font-size: 12px;
    text-align: center;
}

.icon-actions {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.upload-btn {
    background-color: #667eea;
    color: white !important;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    flex: 1;
    text-align: center;
}

.upload-btn:hover {
    background-color: #5a6fd6;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.upload-btn:active {
    transform: translateY(0);
}

.gallery-btn {
    background-color: #9b59b6;
    color: white !important;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    flex: 1;
    text-align: center;
}

.gallery-btn:hover {
    background-color: #8e44ad;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(155, 89, 182, 0.4);
}

.gallery-btn:active {
    transform: translateY(0);
}

/* 图片选择弹窗样式 */
.gallery-content {
    width: 700px;
    display: flex;
    flex-direction: column;
}

.image-gallery {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    max-height: 500px;
    overflow-y: auto;
    padding: 10px 0;
}

.gallery-item {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.gallery-item:hover {
    border-color: #3b82f6;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-loading {
    text-align: center;
    color: #666;
    padding: 40px;
    grid-column: 1 / -1;
}

.gallery-empty {
    text-align: center;
    color: #999;
    padding: 40px;
    grid-column: 1 / -1;
}

/* 操作按钮动画样式 */
.action-btn {
    transition: all 0.2s ease;
}

.action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    filter: brightness(1.1);
}

.action-btn:active {
    transform: translateY(0);
}
