/* 兑鸭惠家 · 后台管理系统样式 */
:root {
    --brand-blue: #00A0F0;
    --brand-blue-dark: #0088CC;
    --brand-yellow: #FFD300;
    --text-primary: #333333;
    --text-secondary: #666666;
    --bg-light: #f5f6f7;
    --bg-white: #FFFFFF;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg-light);
    color: var(--text-primary);
    min-height: 100vh;
}

/* Login */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-blue-dark));
}

.login-box {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 40px;
    width: 380px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.login-box h1 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.login-box .sub {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 28px;
}

.login-box .form-group {
    margin-bottom: 18px;
}

.login-box label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.login-box input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.login-box input:focus {
    outline: none;
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(0,160,240,0.1);
}

.login-box .btn {
    width: 100%;
    padding: 11px;
    background: var(--brand-blue);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.login-box .btn:hover { background: var(--brand-blue-dark); }

.login-box .error {
    color: #e74c3c;
    font-size: 0.85rem;
    text-align: center;
    margin-top: 12px;
}

/* Layout */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    background: #1a1a2e;
    color: #fff;
    padding: 0;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 { font-size: 1.1rem; }

.sidebar-header .company {
    font-size: 0.75rem;
    opacity: 0.5;
    margin-top: 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(0,160,240,0.15);
    color: #fff;
}

.sidebar-nav .icon { font-size: 1.1rem; }

.main-content {
    flex: 1;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--bg-white);
    padding: 16px 28px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar h3 { font-size: 1.1rem; }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.btn-logout {
    padding: 6px 14px;
    background: #e74c3c;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}

.content { padding: 24px; flex: 1; }

/* Stats Cards */
.stats-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-card .num {
    font-size: 2rem;
    font-weight: 700;
    color: var(--brand-blue);
}

.stat-card .label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.stat-card.warn .num { color: #f39c12; }
.stat-card.success .num { color: #27ae60; }
.stat-card.danger .num { color: #e74c3c; }

/* Filters */
.filters {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.filters select,
.filters input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
}

.filters input { width: 200px; }

.filters select:focus,
.filters input:focus {
    outline: none;
    border-color: var(--brand-blue);
}

.btn-primary {
    padding: 8px 18px;
    background: var(--brand-blue);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-primary:hover { background: var(--brand-blue-dark); }

.btn-export {
    padding: 8px 18px;
    background: var(--brand-yellow);
    color: var(--text-primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    margin-left: auto;
}

.btn-export:hover { background: #e6be00; }

/* Table */
.table-wrapper {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.9rem;
}

th {
    background: var(--bg-light);
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid #e8e8e8;
}

td {
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

tr:hover td { background: #fafbfc; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

.badge-new { background: #ffeaea; color: #e74c3c; }
.badge-contacted { background: #fff3e0; color: #f39c12; }
.badge-closed { background: #e8f5e9; color: #27ae60; }

.status-select {
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
}

.remark-input {
    width: 120px;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.8rem;
}

.btn-save {
    padding: 4px 10px;
    background: var(--brand-blue);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.message-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 20px;
}

.pagination button {
    min-width: 36px;
    height: 36px;
    border: 1px solid #ddd;
    background: var(--bg-white);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.pagination button:hover { border-color: var(--brand-blue); color: var(--brand-blue); }
.pagination button.active { background: var(--brand-blue); color: #fff; border-color: var(--brand-blue); }
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* Toast */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    padding: 12px 20px;
    border-radius: 8px;
    color: #fff;
    font-size: 0.9rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease;
}

.toast-success { background: #27ae60; }
.toast-error { background: #e74c3c; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Empty state */
.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty .icon { font-size: 3rem; margin-bottom: 12px; }

/* Panel Switching */
.panel-content { display: none; }
.panel-content.active { display: block; }

.loading-cell { text-align: center; padding: 40px !important; color: var(--text-secondary); }

/* Toolbar */
.toolbar { margin-bottom: 16px; }
.toolbar .btn-primary { padding: 10px 20px; }

/* Home button */
.btn-home {
    padding: 6px 12px;
    background: var(--bg-light);
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s;
}
.btn-home:hover { background: #e0e0e0; }

/* Small action buttons */
.btn-sm { padding: 5px 10px; border: none; border-radius: 4px; cursor: pointer; font-size: 0.8rem; margin: 0 2px; }
.btn-edit { background: var(--brand-blue); color: #fff; }
.btn-edit:hover { background: var(--brand-blue-dark); }
.btn-del { background: #e74c3c; color: #fff; }
.btn-del:hover { background: #c0392b; }
.btn-toggle-on { background: #27ae60; color: #fff; }
.btn-toggle-off { background: #f39c12; color: #fff; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 2000;
    align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }

.modal-box {
    background: var(--bg-white);
    border-radius: 12px;
    width: 90%; max-width: 640px; max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}
.modal-header {
    padding: 16px 20px; border-bottom: 1px solid #eee;
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h4 { font-size: 1.05rem; }
.modal-close {
    width: 32px; height: 32px; border: none; background: none;
    font-size: 1.2rem; cursor: pointer; color: var(--text-secondary);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg-light); }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid #eee; text-align: right; }
.modal-footer button { margin-left: 8px; }

/* Modal form */
.modal-body .form-group { margin-bottom: 14px; }
.modal-body .form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 5px; }
.modal-body .form-group input,
.modal-body .form-group select,
.modal-body .form-group textarea {
    width: 100%; padding: 9px 12px; border: 1px solid #ddd; border-radius: 6px;
    font-size: 0.9rem; font-family: inherit;
}
.modal-body .form-group textarea { min-height: 100px; resize: vertical; }
.modal-body .form-group input:focus,
.modal-body .form-group select:focus,
.modal-body .form-group textarea:focus { outline: none; border-color: var(--brand-blue); }

/* settings form */
#settingsForm .form-group { margin-bottom: 14px; display: flex; align-items: center; gap: 12px; }
#settingsForm .form-group label { width: 140px; flex-shrink: 0; font-weight: 600; font-size: 0.9rem; text-align: right; }
#settingsForm .form-group input,
#settingsForm .form-group textarea { flex: 1; padding: 9px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 0.9rem; font-family: inherit; }
#settingsForm .form-group textarea { min-height: 80px; resize: vertical; }
#settingsForm .form-group input:focus,
#settingsForm .form-group textarea:focus { outline: none; border-color: var(--brand-blue); }

/* Image preview in table */
.img-preview { width: 60px; height: 40px; object-fit: cover; border-radius: 4px; background: var(--bg-light); }

/* Switch toggle */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { display: none; }
.switch .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #ccc; border-radius: 24px; transition: 0.2s; }
.switch .slider:before { position: absolute; content: ''; height: 18px; width: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
.switch input:checked + .slider { background: var(--brand-blue); }
.switch input:checked + .slider:before { transform: translateX(20px); }

/* Upload Widget */
.upload-widget {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}
.upload-preview {
    width: 180px;
    height: 120px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-light);
}
.upload-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.upload-placeholder {
    color: #bbb;
    font-size: 0.85rem;
    text-align: center;
    padding: 10px;
}
.upload-progress {
    color: var(--brand-blue);
    font-size: 0.9rem;
}
.upload-actions {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.upload-btn {
    display: inline-block;
    padding: 9px 18px;
    background: var(--brand-blue);
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    text-align: center;
    transition: background 0.2s;
    width: fit-content;
}
.upload-btn:hover { background: var(--brand-blue-dark); }
.upload-btn input[type="file"] { display: none; }
.upload-or {
    color: #999;
    font-size: 0.8rem;
    text-align: center;
}
.upload-url {
    padding: 9px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.85rem;
    width: 100%;
}
.upload-url:focus {
    outline: none;
    border-color: var(--brand-blue);
}

/* Responsive */
@media (max-width: 768px) {
    .admin-layout { flex-direction: column; }
    .sidebar { width: 100%; }
    .sidebar-nav { display: flex; overflow-x: auto; }
    .sidebar-nav a { white-space: nowrap; flex-shrink: 0; }
    .stats-row { grid-template-columns: repeat(3, 1fr); }
    .filters { flex-direction: column; align-items: stretch; }
    .filters input { width: 100%; }
    th, td { padding: 8px 10px; font-size: 0.8rem; }
}

/* ===== 站点统计面板 ===== */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    margin-bottom: 0;
}
@media (max-width: 1100px) { .stats-overview { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px) { .stats-overview { grid-template-columns: repeat(2, 1fr); } }
