/* ========================================================================
   管理后台样式文件
   ======================================================================== */

/* 导入设计系统变量 */
@import url('design-system.css');

/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family-sans);
    font-size: 14px;
    line-height: var(--line-height-normal);
    color: var(--text-primary);
    background-color: var(--bg-secondary);
}

/* ========================================================================
   金融配色方案 - 与首页保持一致
   ======================================================================== */
:root {
    /* 管理后台专用主色（后台页不加载 style.css，变量带默认值，否则主按钮透明、白字看不见，10-10 修）*/
    --admin-primary: var(--finance-primary, #0f766e);
    /* 信任蓝青 */
    --admin-primary-hover: var(--finance-primary-dark, #0d625b);
    --admin-secondary: var(--finance-accent, #f59e0b);
    /* 琥珀色 */
    --admin-success: var(--stock-down);
    /* 跌-绿 */
    --admin-error: var(--stock-up);
    /* 涨-红 */
    --admin-cta: var(--finance-cta, #0369a1);

    /* 原有紫色渐变保留为备选 */
    --legacy-primary: #667eea;
    --legacy-primary-hover: #5a6fd8;
}

/* ========================================================================
   登录页面样式
   ======================================================================== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--admin-primary) 0%, var(--admin-primary-hover) 100%);
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header i {
    font-size: 48px;
    color: var(--admin-primary);
    margin-bottom: 10px;
}

.login-header h2 {
    color: #333;
    font-weight: 600;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.login-form input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--admin-primary);
    box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.2);
}

.login-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--admin-primary) 0%, var(--admin-primary-hover) 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
}

.login-btn:hover {
    transform: translateY(-1px);
}

.login-btn i {
    margin-right: 8px;
}

.error-message {
    background: #fee;
    color: #c33;
    padding: 10px;
    border-radius: 4px;
    margin-top: 15px;
    border: 1px solid #fcc;
}

/* 表单验证状态 */
.form-group {
    position: relative;
}

.form-group.valid input,
.form-group.valid textarea {
    border-color: var(--admin-success);
}

.form-group.valid::after {
    content: '✓';
    position: absolute;
    right: 12px;
    top: 38px;
    color: var(--admin-success);
    font-weight: bold;
}

.form-group.invalid input,
.form-group.invalid textarea {
    border-color: var(--admin-error);
}

.form-group.invalid .error-text {
    display: block;
    color: var(--admin-error);
    font-size: 12px;
    margin-top: 4px;
}

.form-group .error-text {
    display: none;
}

/* ========================================================================
   主界面布局
   ======================================================================== */
.main-container {
    display: grid;
    grid-template-areas: 
        "header header"
        "sidebar content";
    grid-template-columns: 250px 1fr;
    grid-template-rows: 60px 1fr;
    height: 100vh;
}

/* 顶部导航栏 */
.top-header {
    grid-area: header;
    background: white;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-left h1 {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

/* 移动端菜单按钮 */
#mobile-menu-toggle {
    display: none;
}

@media (max-width: 768px) {
    #mobile-menu-toggle {
        display: inline-flex;
    }

    .header-left h1 {
        font-size: 16px;
    }
}

.header-left i {
    color: var(--admin-primary);
    margin-right: 8px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info {
    color: #666;
    font-size: 13px;
}

.user-info i {
    margin-right: 5px;
}

.logout-btn {
    padding: 6px 12px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    color: #666;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

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

/* 侧边栏 */
.sidebar {
    grid-area: sidebar;
    background: white;
    border-right: 1px solid #e5e5e5;
    padding: 20px 0;
}

.sidebar-nav ul {
    list-style: none;
}

.nav-item {
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: #f8f9fa;
}

.nav-item.active {
    background: var(--bg-glass);
    border-left-color: var(--admin-primary);
    color: var(--admin-primary);
}

.nav-item i {
    width: 20px;
    margin-right: 10px;
}

/* 主内容区域 */
.main-content {
    grid-area: content;
    padding: 20px;
    overflow-y: auto;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

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

.content-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* ========================================================================
   按钮样式
   ======================================================================== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 按钮加载状态 */
.btn.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn.loading::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 16px;
    height: 16px;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-right-color: transparent;
    animation: spin 0.75s linear infinite;
}

.btn-primary {
    background: var(--admin-primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--admin-primary-hover);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

/* ========================================================================
   搜索面板
   ======================================================================== */
.search-panel {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.search-form .form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    align-items: end;
}

.form-group {
    flex: 1;
    min-width: 120px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
    font-size: 12px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--admin-primary);
    box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.2);
}

/* ========================================================================
   数据表格
   ======================================================================== */
.table-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e5e5e5;
}

.table-info {
    font-size: 13px;
    color: #666;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    cursor: pointer;
}

.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th,
.data-table td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid #e5e5e5;
}

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table tbody tr:hover {
    background: #f8f9fa;
}

.data-table .actions {
    display: flex;
    gap: 5px;
}

.data-table .btn {
    padding: 4px 8px;
    font-size: 11px;
}

/* ========================================================================
   分页控件
   ======================================================================== */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e5e5e5;
}

.pagination-info {
    font-size: 13px;
    color: #666;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

#page-numbers {
    display: flex;
    gap: 5px;
}

.page-number {
    padding: 4px 8px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    font-size: 12px;
    border-radius: 3px;
    transition: all 0.2s;
}

.page-number:hover {
    background: #f8f9fa;
}

.page-number.active {
    background: var(--admin-primary);
    color: white;
    border-color: var(--admin-primary);
}

/* ========================================================================
   模态框
   ======================================================================== */
.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: 1000;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e5e5;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #666;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid #e5e5e5;
    background: #f8f9fa;
}

.stock-info {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    font-weight: 500;
    color: #333;
}

/* ========================================================================
   加载和消息提示
   ======================================================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-spinner {
    text-align: center;
    color: var(--admin-primary);
}

.loading-spinner i {
    font-size: 24px;
    margin-bottom: 10px;
}

.message-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
}

.message {
    padding: 12px 20px;
    margin-bottom: 10px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s ease;
}

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

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

.message.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ========================================================================
   个人设置页面样式
   ======================================================================== */
.profile-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    max-width: 600px;
}

.profile-card h3 {
    margin-bottom: 20px;
    color: #333;
    font-size: 18px;
    font-weight: 600;
    border-bottom: 1px solid #e5e5e5;
    padding-bottom: 10px;
}

.profile-info {
    display: grid;
    gap: 15px;
}

.info-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5;
}

.info-item:last-child {
    border-bottom: none;
}

.info-item label {
    font-weight: 500;
    color: #555;
    width: 120px;
    flex-shrink: 0;
}

.info-item span {
    color: #333;
    flex: 1;
}

/* 文本颜色辅助类 */
.text-success {
    color: var(--admin-success) !important;
}

.text-danger {
    color: var(--admin-error) !important;
}

.text-warning {
    color: var(--admin-secondary) !important;
}

.text-info {
    color: var(--admin-primary) !important;
}

/* ========================================================================
    骨架屏加载状态 (Skeleton Loading States)
    ======================================================================== */

/* 骨架屏基础动画 */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* 表格骨架屏 */
.table-skeleton-row {
    height: 48px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    border-bottom: 1px solid #e5e5e5;
}

.table-skeleton-cell {
    height: 16px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 2px;
}

/* 暗黑模式骨架屏 */
@media (prefers-color-scheme: dark) {
    .skeleton {
        background: linear-gradient(90deg, #1f2937 25%, #374151 50%, #1f2937 75%);
    }
}

/* 尊重减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    .skeleton {
        animation: none;
    }
}

/* ========================================================================
    可访问性增强 (Accessibility Enhancements)
    ======================================================================== */

/* 屏幕阅读器专用样式 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 增强焦点可见性 */
*:focus-visible {
    outline: 3px solid var(--admin-primary);
    outline-offset: 2px;
}

/* 交互元素必须有足够的点击区域 */
button,
a {
    min-height: 44px;
    min-width: 44px;
}

/* 为小按钮添加padding以增加点击区域 */
.btn-sm {
    padding: 6px 12px;
    min-height: 32px;
}

/* 跳过导航链接 */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--admin-primary);
    color: white;
    padding: 8px 16px;
    z-index: 10000;
    transition: top 0.3s;
}

.skip-to-content:focus {
    top: 0;
}

/* 高对比度模式支持 */
@media (prefers-contrast: more) {
    body {
        background-color: #ffffff;
        color: #000000;
    }

    .login-box,
    .table-container,
    .search-panel,
    .modal-content {
        border: 2px solid #000000;
    }
}

/* 减少运动偏好 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================================================
    响应式设计
    ======================================================================== */
@media (max-width: 768px) {
    .main-container {
        grid-template-areas:
            "header"
            "content";
        grid-template-columns: 1fr;
        grid-template-rows: 60px 1fr;
    }

    .sidebar {
        display: none;
    }

    /* 移动端导航菜单 */
    .sidebar.mobile-visible {
        display: block;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 999;
        background: white;
        overflow-y: auto;
    }

    .search-form .form-row {
        flex-direction: column;
        gap: 10px;
    }

    .table-wrapper {
        font-size: 12px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 4px;
    }

    /* 数据表格在移动端显示为卡片 */
    @media (max-width: 480px) {
        .table-wrapper {
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
        }

        .data-table {
            min-width: 800px;
        }
    }

    .pagination-container {
        flex-direction: column;
        gap: 10px;
    }

    .info-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .info-item label {
        width: auto;
    }

    /* 响应式模态框 */
    .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 20px auto;
    }

    /* 登录框在移动端优化 */
    .login-box {
        padding: 30px 20px;
        width: 95%;
    }

    .login-btn {
        min-height: 48px;
    }
}
