/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

.container {
    min-height: 100vh;
}

/* 导航栏样式 */
.navbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.nav-brand h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-menu li a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: background-color 0.3s;
}

.nav-menu li a:hover {
    background-color: rgba(255,255,255,0.2);
}

/* 页面样式 */
.page {
    display: none;
    padding: 2rem;
    animation: fadeIn 0.3s ease-in;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 统计卡片样式 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    text-align: center;
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card h3 {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
}

/* 图表容器 */
.chart-container {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.chart-area {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 300px;
    background: #f8f9fa;
    border-radius: 5px;
    border: 2px dashed #dee2e6;
}

/* 商户排行榜 */
.merchant-ranking {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* 表格样式 */
.table-container {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: #f8f9fa;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 1px solid #dee2e6;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
}

.data-table tr:hover {
    background-color: #f8f9fa;
}

/* 筛选栏样式 */
.filter-bar {
    background: white;
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.filter-bar input,
.filter-bar select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.9rem;
}

/* 按钮样式 */
button, .btn-primary, .btn-secondary, .btn-danger {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.btn-primary, button:not(.btn-secondary):not(.btn-danger) {
    background: #667eea;
    color: white;
}

.btn-primary:hover, button:not(.btn-secondary):not(.btn-danger):hover {
    background: #5a6fd8;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

/* 分页样式 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

/* 操作栏样式 */
.action-bar {
    margin-bottom: 1rem;
}

/* 管理员页面样式 */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.admin-card {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.admin-stats p {
    margin: 0.5rem 0;
    font-size: 1.1rem;
}

.admin-stats span {
    font-weight: bold;
    color: #667eea;
}

.admin-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.log-container {
    max-height: 300px;
    overflow-y: auto;
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 5px;
    font-family: monospace;
    font-size: 0.8rem;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
}

.close:hover {
    color: #333;
}

/* 表单样式 */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* 状态标签 */
.status-active {
    background: #28a745;
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.8rem;
}

.status-inactive {
    background: #dc3545;
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.8rem;
}

.status-pending {
    background: #ffc107;
    color: #212529;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.8rem;
}

.status-completed {
    background: #28a745;
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.8rem;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .container {
        padding: 0;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .admin-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }

    .nav-menu li a {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }

    .page {
        padding: 1rem;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .filter-bar input,
    .filter-bar select,
    .filter-bar button {
        width: 100%;
        margin: 0;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }

    /* 表格在移动端的优化 */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        font-size: 0.75rem;
        min-width: 800px;
    }

    .data-table th,
    .data-table td {
        padding: 0.4rem;
        white-space: nowrap;
    }

    /* 移动端模态框优化 */
    .modal-content {
        margin: 10% auto;
        width: 95%;
        max-width: none;
        padding: 1.5rem;
    }

    .form-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .form-actions button {
        width: 100%;
    }

    /* 图表区域移动端优化 */
    .chart-area {
        height: 200px;
    }

    #trendChart {
        width: 100%;
        height: 200px;
    }

    /* 分页在移动端的优化 */
    .pagination {
        flex-direction: column;
        gap: 0.5rem;
    }

    .pagination button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .navbar {
        padding: 0.5rem;
    }

    .nav-brand h1 {
        font-size: 1.2rem;
    }

    .page {
        padding: 0.5rem;
    }

    .stat-card {
        padding: 0.8rem;
    }

    .stat-card h3 {
        font-size: 0.8rem;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .chart-container,
    .merchant-ranking {
        padding: 1rem;
    }

    .data-table {
        font-size: 0.7rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.3rem;
    }

    .modal-content {
        margin: 5% auto;
        padding: 1rem;
    }

    .close {
        right: 0.5rem;
        top: 0.5rem;
    }
}

/* 触摸设备优化 */
@media (hover: none) {
    .stat-card:hover {
        transform: none;
    }

    .data-table tr:hover {
        background-color: transparent;
    }

    button:hover,
    .btn-primary:hover,
    .btn-secondary:hover,
    .btn-danger:hover {
        transform: none;
    }
}

/* 工具提示 */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 120px;
    background-color: #555;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -60px;
    opacity: 0;
    transition: opacity 0.3s;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 登录页面样式 */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-form {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
}

.login-form h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #333;
}

.login-form .form-group {
    margin-bottom: 1rem;
}

.login-form input {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.login-form button {
    width: 100%;
    padding: 0.8rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s;
}

.login-form button:hover {
    background: #5a6fd8;
}

.login-error {
    color: #dc3545;
    text-align: center;
    margin-top: 1rem;
    font-size: 0.9rem;
}

/* 权限管理样式 */
.permission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.permission-card {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.permission-card h4 {
    margin-bottom: 0.5rem;
    color: #333;
}

.permission-list {
    list-style: none;
    padding: 0;
}

.permission-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.permission-list li:last-child {
    border-bottom: none;
}

.permission-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.permission-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.permission-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.permission-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .permission-slider {
    background-color: #667eea;
}

input:checked + .permission-slider:before {
    transform: translateX(20px);
}

/* 管理员表格样式 */
.admin-table-container {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.role-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.role-super {
    background: #ff6b6b;
    color: white;
}

.role-admin {
    background: #4ecdc4;
    color: white;
}

.role-operator {
    background: #45b7d1;
    color: white;
}

.role-viewer {
    background: #96ceb4;
    color: white;
}

/* 标签页样式 */
.tab-container {
    margin-bottom: 2rem;
}

.tab-nav {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 1rem;
}

.tab-button {
    background: none;
    border: none;
    padding: 1rem 1.5rem;
    cursor: pointer;
    font-size: 1rem;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.tab-button.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.tab-button:hover:not(.active) {
    background: rgba(102, 126, 234, 0.05);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* 用户头像 */
.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #667eea;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    margin-right: 0.5rem;
}

/* 在线状态指示器 */
.online-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 0.5rem;
}

.online-status.online {
    background: #28a745;
}

.online-status.offline {
    background: #6c757d;
}

/* 移动端管理员页面优化 */
@media (max-width: 768px) {
    .login-container {
        padding: 1rem;
    }

    .login-form {
        padding: 1.5rem;
    }

    .permission-grid {
        grid-template-columns: 1fr;
    }

    .tab-nav {
        flex-wrap: wrap;
    }

    .tab-button {
        flex: 1;
        min-width: 120px;
        padding: 0.8rem 1rem;
        font-size: 0.9rem;
    }

    .admin-table-container {
        overflow-x: auto;
    }
}
