/* 通用样式 - 所有页面共享 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background: #f7f9fc;
    min-height: 100vh;
}

/* 通用容器 */
.container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    padding: 48px 40px;
    max-width: 420px;
    width: 100%;
}

/* Logo样式 */
.logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon {
    width: 56px;
    height: 56px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    font-size: 28px;
}

/* 图标图片样式（用于自定义图片图标） */
.icon-img {
    width: 1em;
    height: 1em;
    vertical-align: middle;
    object-fit: contain;
}

.logo-icon .icon-img {
    width: 32px;
    height: 32px;
}

.mode-icon .icon-img {
    width: 28px;
    height: 28px;
}

.btn-icon .icon-img {
    width: 16px;
    height: 16px;
}

.ms-success-icon .icon-img {
    width: 48px;
    height: 48px;
}

.logo h1 {
    color: #1a1a1a;
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.logo p {
    color: #6b7280;
    font-size: 14px;
    font-weight: 400;
}

/* 表单组 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.2s;
    background: #fafafa;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.08);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #9ca3af;
}

.form-hint {
    font-size: 13px;
    color: #6b7280;
    margin-top: 6px;
    line-height: 1.4;
}

/* 按钮样式 */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-block;
    text-align: center;
    min-width: 100px;
    line-height: 1.4;
}

.btn-primary {
    padding: 12px 24px;
    background: #0078d4;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 120, 212, 0.2);
    min-width: 100px;
    line-height: 1.4;
}

.btn-primary:hover {
    background: #106ebe;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 120, 212, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    padding: 12px 24px;
    background: white;
    color: #374151;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 100px;
    line-height: 1.4;
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.btn-success {
    padding: 12px 24px;
    background: #10b981;
    color: white;
    border: none;
    min-width: 100px;
    line-height: 1.4;
}

.btn-success:hover {
    background: #059669;
}

.btn-warning {
    padding: 12px 24px;
    background: #f59e0b;
    color: white;
    border: none;
    min-width: 100px;
    line-height: 1.4;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-danger {
    padding: 12px 24px;
    background: #ef4444;
    color: white;
    border: none;
    min-width: 100px;
    line-height: 1.4;
}

.btn-danger:hover {
    background: #dc2626;
}

/* 详情按钮 - 微软简约风格，柔和的蓝灰色 */
.btn-detail {
    padding: 12px 24px;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    min-width: 100px;
    line-height: 1.4;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-detail:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
    color: #334155;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.btn-detail:active {
    transform: translateY(0);
    box-shadow: none;
}

/* btn-info 柔和版本 - 降低蓝色饱和度 */
.btn-info {
    padding: 12px 24px;
    background: #64748b;
    color: white;
    border: none;
    min-width: 100px;
    line-height: 1.4;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-info:hover {
    background: #475569;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(71, 85, 105, 0.25);
}

.btn-info:active {
    transform: translateY(0);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    min-width: 50px;
    line-height: 1.3;
}

/* 超小按钮 */
.btn-xs {
    padding: 2px 6px;
    font-size: 11px;
    min-width: 40px;
    line-height: 1.2;
    border-radius: 4px;
}

/* 按钮组 - 用于模态框等场景的多按钮排列 */
.button-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.button-group .btn {
    flex: 1;
    min-width: 0;
}

/*
 * 表单内主按钮全宽：仅用于登录页等单列布局。
 * 注意：勿对全局 form 生效，否则管理后台模态框内「提交」会继承 width:100%、更大 padding，
 * 与同行的「取消」严重不一致。
 */
#loginForm .btn-primary,
#loginForm .btn-secondary {
    width: 100%;
    padding: 14px;
    font-size: 15px;
    border-radius: 10px;
}

#loginForm .btn-secondary {
    margin-top: 12px;
}

/* 模态框内的按钮组 - 确保按钮大小一致 */
.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    align-items: stretch;
}

.modal-buttons .btn {
    flex: 1;
    min-width: 0;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 模态框底部并排按钮：统一尺寸（勿使用全局 form .btn-primary 的全宽/大号字） */
.modal-content form > div[style*="display: flex"],
.modal-content form div[style*="display: flex"] {
    display: flex !important;
    gap: 10px;
    margin-top: 24px;
    align-items: stretch;
}

/* 含 .btn 与仅 .btn-primary/.btn-secondary（首页等）两种写法 */
.modal-content form > div[style*="display: flex"] > .btn,
.modal-content form > div[style*="display: flex"] > .btn-primary,
.modal-content form > div[style*="display: flex"] > .btn-secondary,
.modal-content form div[style*="display: flex"] > .btn,
.modal-content form div[style*="display: flex"] > .btn-primary,
.modal-content form div[style*="display: flex"] > .btn-secondary {
    flex: 1 1 0;
    min-width: 0 !important;
    width: auto !important;
    max-width: none !important;
    margin-top: 0 !important;
    padding: 12px 16px !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    border-radius: 8px !important;
    min-height: 44px;
    box-sizing: border-box;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* 主按钮无描边时与次要按钮 1.5px 边框占位等高 */
.modal-content form > div[style*="display: flex"] > .btn-primary,
.modal-content form > div[style*="display: flex"] > .btn.btn-primary,
.modal-content form div[style*="display: flex"] > .btn-primary,
.modal-content form div[style*="display: flex"] > .btn.btn-primary {
    border: 1.5px solid transparent !important;
}

/* 模态框内表单外底部按钮条（如导入配置） */
.modal-content div[style*="display: flex"][style*="gap"],
.modal-content > div[style*="display: flex"] {
    display: flex !important;
    align-items: stretch;
}

.modal-content div[style*="display: flex"][style*="gap"] .btn,
.modal-content > div[style*="display: flex"] .btn {
    flex: 1 1 0;
    min-width: 0 !important;
    width: auto !important;
    max-width: none !important;
    margin-top: 0 !important;
    padding: 12px 16px !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    border-radius: 8px !important;
    min-height: 44px;
    box-sizing: border-box;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.modal-content div[style*="display: flex"][style*="gap"] .btn-primary,
.modal-content > div[style*="display: flex"] .btn-primary,
.modal-content div[style*="display: flex"][style*="gap"] .btn.btn-primary,
.modal-content > div[style*="display: flex"] .btn.btn-primary {
    border: 1.5px solid transparent !important;
}

/* 消息提示 */
.message {
    padding: 14px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
    display: none;
}

.message.success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.message.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.message.info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* 链接 */
.links {
    text-align: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid #f3f4f6;
}

.links a {
    color: #667eea;
    text-decoration: none;
    font-size: 14px;
    margin: 0 12px;
    font-weight: 500;
}

.links a:hover {
    text-decoration: underline;
}

/* 状态标签 */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.status-active {
    background: #d1fae5;
    color: #065f46;
}

.status-warning {
    background: #fef3c7;
    color: #92400e;
}

.status-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-primary {
    background: #dbeafe;
    color: #1e40af;
}

.badge-info {
    background: #cffafe;
    color: #155e75;
}

/* 应用范围徽章 - 柔和的紫灰色 */
.badge-scope {
    background: #e2e8f0;
    color: #475569;
}

.badge-secondary {
    background: #f1f5f9;
    color: #64748b;
}

/* 加载动画 */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 移动端优化 */
@media (max-width: 480px) {
    body {
        padding: 12px;
    }
    
    .container {
        padding: 32px 24px;
    }
    
    .logo h1 {
        font-size: 22px;
    }
    
    .form-group input,
    .form-group textarea,
    .form-group select {
        font-size: 16px; /* 防止iOS自动缩放 */
    }
    
    .links a {
        display: block;
        margin: 8px 0;
    }
}

/* ==================== 全局加载动画 ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: loading-spin 0.8s linear infinite;
}

.loading-text {
    margin-top: 16px;
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
}

@keyframes loading-spin {
    to { transform: rotate(360deg); }
}

/* 局部加载动画（用于表格等区域） */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: #6b7280;
}

.loading-container .loading-spinner {
    width: 36px;
    height: 36px;
    border-width: 3px;
}

.loading-container .loading-text {
    margin-top: 12px;
    font-size: 13px;
}

