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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

/* 管理容器 */
.admin-container {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: 250px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.sidebar-menu {
    list-style: none;
    padding: 20px 0;
}

.menu-item {
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.menu-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-left-color: #fff;
}

.menu-item.active {
    background-color: rgba(255, 255, 255, 0.2);
    border-left-color: #fff;
}

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

/* 主内容区 */
.main-content {
    flex: 1;
    margin-left: 250px;
    display: flex;
    flex-direction: column;
}

/* 头部 */
.header {
    background: white;
    padding: 20px 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

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

.user-info {
    color: #666;
}

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

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

.btn-secondary:hover {
    background: #5a6268;
}

.btn-logout {
    background: #dc3545;
    color: white;
}

.btn-logout:hover {
    background: #c82333;
}

/* 内容区域 */
.content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

/* 页面切换 */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.stat-info h3 {
    font-size: 28px;
    font-weight: 700;
    color: #333;
    margin-bottom: 5px;
}

.stat-info p {
    color: #666;
    font-size: 14px;
}

/* 图表区域 */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.chart-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chart-card h3 {
    margin-bottom: 20px;
    color: #333;
    font-size: 18px;
}



.activity-list {
    max-height: 300px;
    overflow-y: auto;
}

.activity-item {
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.activity-info {
    flex: 1;
}

.activity-time {
    color: #666;
    font-size: 12px;
}

/* 页面头部 */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-header h2 {
    font-size: 24px;
    color: #333;
}

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

/* 筛选器 */
.filters {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.search-input, .filter-select, .date-input {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    min-width: 200px;
}

.search-input:focus, .filter-select:focus, .date-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 表格样式 */
.table-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: #f8f9fa;
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #dee2e6;
}

.data-table td {
    padding: 15px;
    border-bottom: 1px solid #dee2e6;
}

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

/* 状态标签 */
.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

/* 通用状态样式 */
.status {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    display: inline-block;
}

.status.active {
    background: #d4edda;
    color: #155724;
}

.status.success {
    background: #d1ecf1;
    color: #0c5460;
}

.status.warning {
    background: #fff3cd;
    color: #856404;
}

.status.inactive {
    background: #f8d7da;
    color: #721c24;
}

.status.used {
    background: #cce5ff;
    color: #004085;
}

.status-unused {
    background: #d4edda;
    color: #155724;
}

.status-used {
    background: #cce5ff;
    color: #004085;
}

.status-expired {
    background: #f8d7da;
    color: #721c24;
}

.status-distributed {
    background: #fff3cd;
    color: #856404;
}

.status-undistributed {
    background: #e2e3e5;
    color: #383d41;
}

.status-online {
    color: #28a745;
}

.status-offline {
    color: #dc3545;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

.pagination button {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pagination button:hover {
    background: #f8f9fa;
}

.pagination button.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

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

.modal-header h3 {
    margin: 0;
    color: #333;
}

.close {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
}

.close:hover {
    color: #333;
}

.modal-body {
    padding: 25px;
}

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

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

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* 设置页面 */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.setting-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.setting-card h3 {
    margin-bottom: 20px;
    color: #333;
    font-size: 18px;
}

.setting-item {
    margin-bottom: 20px;
}

.setting-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

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

/* 加载动画 */
.loading {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .admin-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        overflow-x: auto;
    }

    .sidebar ul {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-around;
        padding: 10px;
    }

    .sidebar li {
        margin: 5px;
        min-width: 120px;
        text-align: center;
    }

    .main-content {
        margin-left: 0;
        padding: 10px;
    }

    .header {
        padding: 10px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .charts-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .page-header h2 {
        font-size: 1.5rem;
    }

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

    .filters input,
    .filters select,
    .filters button {
        width: 100%;
        margin: 0;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        min-width: 600px;
        font-size: 12px;
    }

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

    .btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .modal-content {
        width: 95%;
        margin: 10px;
        max-height: 90vh;
        overflow-y: auto;
    }

    .form-group {
        margin-bottom: 15px;
    }

    .form-group label {
        font-size: 14px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* 防止iOS缩放 */
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.2rem;
    }

    .stat-card h3 {
        font-size: 1.5rem;
    }

    .stat-card p {
        font-size: 12px;
    }

    .sidebar li {
        min-width: 100px;
        font-size: 12px;
    }

    .sidebar li i {
        font-size: 14px;
    }

    .page-header {
        text-align: center;
    }

    .page-header h2 {
        font-size: 1.3rem;
    }

    .data-table {
        font-size: 11px;
    }

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

/* 快速分发页面样式 */
.quick-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    position: relative;
    padding: 30px;
    border-radius: 20px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
}

.stat-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.gradient-blue {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.gradient-green {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e6cf 100%);
}

.gradient-purple {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.gradient-orange {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.gradient-red {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
}

.gradient-teal {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.stat-content {
    position: relative;
    z-index: 2;
    color: white;
}

.stat-number {
    font-size: 48px;
    font-weight: 800;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.stat-label {
    font-size: 16px;
    font-weight: 500;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-icon {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 40px;
    opacity: 0.3;
    z-index: 1;
}

/* 快速分发区域 */
.quick-distribute-section {
    background: white;
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

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

.section-header h2 {
    font-size: 28px;
    color: #2c3e50;
    margin-bottom: 10px;
}

.section-header h2 i {
    color: #667eea;
    margin-right: 10px;
}

.section-header p {
    color: #7f8c8d;
    font-size: 16px;
}

.distribute-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
}

.codes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.code-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px solid #dee2e6;
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.code-card:hover {
    transform: translateY(-5px);
    border-color: #667eea;
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.3);
}

.code-card.copying {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.code-value {
    font-size: 24px;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    margin-bottom: 10px;
    color: #2c3e50;
}

.code-card.copying .code-value {
    color: white;
}

.code-status {
    font-size: 12px;
    color: #28a745;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.code-card.copying .code-status {
    color: rgba(255,255,255,0.9);
}

/* 最近活动 */
.recent-activity {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.recent-activity h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 20px;
}

.recent-activity h3 i {
    color: #667eea;
    margin-right: 10px;
}

.activity-list {
    max-height: 300px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #f1f3f4;
    transition: background 0.2s ease;
}

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

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

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin-right: 15px;
    font-size: 16px;
}

.activity-content {
    flex: 1;
}

.activity-title {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 5px;
}

.activity-time {
    font-size: 12px;
    color: #7f8c8d;
}

/* 分页信息样式 */
.pagination-info {
    text-align: center;
    margin-bottom: 10px;
    color: #666;
    font-size: 14px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 6px;
}

/* 设备数量显示优化 */
.devices-pagination .pagination-info {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    font-weight: 500;
}

/* 网站管理页面样式 */
.website-editor {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.editor-tabs {
    display: flex;
    border-bottom: 2px solid #f1f3f4;
    margin-bottom: 30px;
}

.tab-btn {
    background: none;
    border: none;
    padding: 15px 25px;
    font-size: 16px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-btn:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.tab-content {
    display: none;
}

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

.tab-content .form-group {
    margin-bottom: 25px;
}

.tab-content label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.tab-content input,
.tab-content textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.tab-content input:focus,
.tab-content textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.tab-content textarea {
    resize: vertical;
    min-height: 80px;
}

/* 图片管理样式 */
.images-manager h3 {
    margin-bottom: 10px;
    color: #333;
}

.help-text {
    color: #666;
    font-size: 14px;
    margin-bottom: 20px;
}

.upload-area {
    margin-bottom: 30px;
    padding: 20px;
    border: 2px dashed #ddd;
    border-radius: 10px;
    text-align: center;
    background: #f9f9f9;
}

.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.image-item {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    background: white;
}

.image-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.image-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
}

.image-actions button {
    background: rgba(0,0,0,0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 12px;
}

.image-actions button:hover {
    background: rgba(0,0,0,0.9);
}

.image-info {
    padding: 10px;
    font-size: 12px;
    color: #666;
}

.tab-content small.help-text {
    display: block;
    margin-top: 5px;
    color: #888;
    font-size: 12px;
}
