/* 护眼搭档管理后台样式 */

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-color: #f1f5f9;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --sidebar-width: 250px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* 激活码显示样式 - 使用等宽字体避免字符混淆 */
.activation-code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 1px;
    background: #f1f5f9;
    padding: 6px 12px;
    border-radius: 6px;
    display: inline-block;
    color: #1e293b;
    border: 1px solid #e2e8f0;
}

/* 激活码复制按钮 */
.copy-code-btn {
    margin-left: 8px;
    padding: 4px 8px;
    font-size: 12px;
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.copy-code-btn:hover {
    background: #4338ca;
}

.copy-code-btn:active {
    transform: scale(0.95);
}

/* 布局 */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header .logo {
    font-size: 28px;
}

.sidebar-nav {
    padding: 16px 0;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
    gap: 12px;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-item.active {
    background: var(--primary-color);
    color: white;
}

.nav-item .icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    margin-top: auto;
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.3);
    text-align: center;
}

.admin-info {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.admin-username {
    color: rgba(255,255,255,0.9);
    font-size: 14px;
    font-weight: 500;
}

.settings-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.3) 0%, rgba(118, 75, 162, 0.3) 100%);
    color: #fff;
    border: 1px solid rgba(102, 126, 234, 0.4);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 10px;
}

.settings-btn:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.5) 0%, rgba(118, 75, 162, 0.5) 100%);
    border-color: rgba(102, 126, 234, 0.6);
    transform: translateY(-1px);
}

.settings-btn .icon {
    font-size: 18px;
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.3) 0%, rgba(220, 38, 38, 0.3) 100%);
    color: #fff;
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.5) 0%, rgba(220, 38, 38, 0.5) 100%);
    border-color: rgba(239, 68, 68, 0.6);
    transform: translateY(-1px);
}

.logout-btn .icon {
    font-size: 18px;
}

/* 主内容区 */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px;
}

/* 顶部栏 */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-title {
    font-size: 24px;
    font-weight: 600;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* 卡片 */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 24px;
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
}

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon.users { background: #dbeafe; color: #2563eb; }
.stat-icon.vip { background: #fef3c7; color: #d97706; }
.stat-icon.records { background: #dcfce7; color: #16a34a; }
.stat-icon.orders { background: #f3e8ff; color: #9333ea; }

.stat-info h3 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-info p {
    color: var(--text-light);
    font-size: 14px;
}

/* 表格 */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-light);
}

tr:hover {
    background: #f8fafc;
}

/* 徽章 */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
}

.badge-primary { background: #dbeafe; color: #2563eb; }
.badge-success { background: #dcfce7; color: #16a34a; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-info { background: #dbeafe; color: #2563eb; }

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: #e2e8f0;
    color: var(--text-color);
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* 表单 */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* 页面容器 */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-light);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
}

/* 搜索表单 */
.search-form {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.search-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.search-row:last-child {
    margin-bottom: 0;
}

.search-input,
.search-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    color: var(--text-color);
    flex: 1;
    min-width: 150px;
}

.search-input:focus,
.search-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-button,
.reset-button {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.search-button {
    background: var(--primary-color);
    color: white;
}

.search-button:hover {
    background: var(--primary-hover);
}

.reset-button {
    background: var(--secondary-color);
    color: white;
}

.reset-button:hover {
    background: #475569;
}

/* 加载状态 */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.pagination button {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 6px;
    cursor: pointer;
}

.pagination button:hover {
    background: #f8fafc;
}

.pagination button.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* 刷新按钮 */
.refresh-btn {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.refresh-btn:hover {
    background: #f1f5f9;
    color: var(--text-color);
}

/* 配置表格 */
.config-table td:first-child {
    font-weight: 500;
    width: 200px;
}

.config-table td:last-child {
    width: 120px;
}

/* 响应式 */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1000;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* 广告管理样式 */
.upload-form {
    padding: 0;
}

.ad-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 0;
}

.ad-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    background: white;
}

.ad-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.ad-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: #f8fafc;
}

.ad-info {
    padding: 16px;
}

.ad-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
}

.ad-status.active {
    background: #dcfce7;
    color: #16a34a;
}

.ad-status.inactive {
    background: #fee2e2;
    color: #dc2626;
}

.ad-meta {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 12px;
    line-height: 1.6;
}

.ad-meta div {
    margin-bottom: 4px;
}

.ad-actions {
    display: flex;
    gap: 8px;
}

.ad-actions button {
    flex: 1;
    padding: 8px;
    font-size: 13px;
}

.btn-toggle {
    background: #2196F3;
    color: white;
}

.btn-toggle:hover {
    background: #0b7dda;
}

.btn-delete {
    background: #ef4444;
    color: white;
}

.btn-delete:hover {
    background: #dc2626;
}

.ad-grid .empty-state {
    grid-column: 1 / -1;
}

.ad-grid .loading {
    grid-column: 1 / -1;
}

/* WebSocket连接状态 */
.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: white;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    animation: pulse 2s ease-in-out infinite;
}

.status-dot.disconnected {
    background: #ef4444;
    animation: none;
}

.status-text {
    font-weight: 500;
    color: var(--text-color);
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* 刷新按钮增强 */
.refresh-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.refresh-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
}

.refresh-btn:active {
    transform: translateY(0);
}


/* 标签页样式 */
.tabs {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 8px;
}

.tab-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.tab-btn:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.tab-btn.active {
    background: #4f46e5;
    color: white;
}

.tab-btn .badge {
    font-size: 11px;
    padding: 2px 6px;
}

/* 删除按钮样式 */
.btn-delete {
    background: #ef4444;
    color: white;
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

/* 恢复按钮样式 */
.btn-restore {
    background: #22c55e;
    color: white;
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-restore:hover {
    background: #16a34a;
    transform: translateY(-1px);
}

/* 永久删除按钮样式 */
.btn-permanent-delete {
    background: #991b1b;
    color: white;
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-permanent-delete:hover {
    background: #7f1d1d;
    transform: translateY(-1px);
}

/* 分页样式 */
.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pagination .btn {
    min-width: 36px;
    justify-content: center;
}

.pagination .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 复选框样式 */
.user-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

#select-all-users {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* 开关样式 */
.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: rgba(255,255,255,0.3);
    transition: .3s;
    border-radius: 26px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: rgba(255,255,255,0.9);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

input:checked + .slider:after {
    content: "✓";
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: #22c55e;
    font-size: 12px;
    font-weight: bold;
}
