/* stats-dashboard.php 专用样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

.stat-card-advanced {
    background: white;
    border-radius: 20px;
    padding: 24px 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 4px solid #FFC107;
    border-right: 4px solid #FFC107;
}

.stat-card-advanced:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.02);
}

.stat-number-advanced {
    font-size: 34px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

.stat-label-advanced {
    font-size: 13px;
    color: #64748b;
    margin-top: 8px;
    font-weight: 500;
}

.distribution-section {
    background: white;
    border-radius: 24px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 15px;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-buttons {
    display: flex;
    gap: 8px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 40px;
}

.filter-btn {
    padding: 6px 16px;
    border: none;
    background: transparent;
    border-radius: 32px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: #64748b;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.filter-btn.active {
    background: #3b82f6;
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.filter-btn:hover:not(.active) {
    background: #e2e8f0;
}

.chart-legend-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
}

.chart-container {
    flex: 1.2;
    min-width: 260px;
    height: 260px;
}

.legend-stats {
    flex: 0.8;
    min-width: 180px;
}

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

.legend-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.item-name {
    font-size: 13px;
    color: #334155;
}

.item-count {
    font-weight: 600;
    color: #1e293b;
    font-size: 13px;
}

.item-percent {
    font-size: 11px;
    color: #94a3b8;
    margin-left: 6px;
}

.total-badge {
    margin-top: 12px;
    padding-top: 12px;
    text-align: center;
    border-top: 1px solid #e2e8f0;
    font-size: 12px;
    color: #64748b;
}

.total-badge strong {
    color: #3b82f6;
    font-size: 16px;
}

.back-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.25s;
    padding: 8px 16px;
    border-radius: 24px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px dashed #667eea;
}

.back-link:hover {
    background: #667eea;
    color: white;
    border-color: #fff;
}

@keyframes barSlide {
    from {
        width: 20%;
    }

    to {
        width: 100%;
    }
}

.back-link i {
    display: inline-flex;
    flex-direction: column;
    gap: 3px;
    width: 20px;
}

.back-link i b {
    display: block;
    height: 2px;
    border-radius: 2px;
    animation-name: barSlide;
    animation-timing-function: linear;
    animation-duration: 0.8s;
    animation-iteration-count: infinite;
    animation-direction: alternate;
}

.back-link i b:nth-child(1) {
    background: linear-gradient(90deg, #ef4444, #f87171);
    animation-delay: 0;
}

.back-link i b:nth-child(2) {
    background: linear-gradient(90deg, #10b981, #34d399);
    margin: 2px 0;
    animation-delay: 0.25s;
}

.back-link i b:nth-child(3) {
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    animation-delay: 0.5s;
}

.back-link:hover i b {
    animation-duration: 0.5s;
}

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

.container {
    max-width: 1400px;
    margin: 0 auto;
}

.header {
    background: white;
    border-radius: 24px;
    padding: 24px 32px;
    margin-bottom: 30px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.header-content h1 {
    margin: 0 0 8px 0;
    font-size: 1.9rem;
    color: #1e293b;
}

.header-content p {
    margin: 0;
    color: #64748b;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    font-size: 0.95rem;
}

footer {
    text-align: center;
    padding: 20px;
    color: #94a3b8;
    font-size: 0.8rem;
    margin-top: -10px;
}

.two-columns {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
    margin-bottom: 0px;
}

.bar-chart-wrapper {
    width: 100%;
    height: auto;
    min-height: 320px;
}

#osChart,
#browserChart,
#regionChart {
    width: 100%;
    height: 320px;
}

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

    #osChart,
    #browserChart,
    #regionChart {
        height: 300px;
    }
}

/* ========== crawler-logs.php 专用样式 ========== */
.crawler-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.crawler-stat-card {
    background: white;
    border-radius: 20px;
    padding: 24px 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 4px solid #FFC107;
    border-right: 4px solid #FFC107;
}

.crawler-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.02);
}

.crawler-stat-number {
    font-size: 34px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

.crawler-stat-label {
    font-size: 13px;
    color: #64748b;
    margin-top: 8px;
    font-weight: 500;
}

/* 爬虫类型分布区域 */
.type-distribution-section {
    background: white;
    border-radius: 24px;
    padding: 24px;
    margin-bottom: 30px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* 图表和标签双栏布局 */
.chart-legend-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    align-items: center;
}

.chart-container {
    flex: 1.2;
    min-width: 280px;
    height: 280px;
}

.legend-stats {
    flex: 0.8;
    min-width: 200px;
}

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

.type-legend-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.type-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.type-name {
    font-size: 14px;
    color: #334155;
}

.type-count {
    font-weight: 600;
    color: #1e293b;
}

.type-percent {
    font-size: 12px;
    color: #94a3b8;
    margin-left: 8px;
}

.total-badge {
    margin-top: 15px;
    padding-top: 15px;
    text-align: center;
    border-top: 1px solid #e2e8f0;
    font-size: 13px;
    color: #64748b;
}

.total-badge strong {
    color: #3b82f6;
    font-size: 18px;
}

.details-section {
    background: white;
    border-radius: 24px;
    padding: 24px;
    margin-bottom: 30px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

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

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

th,
td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    font-size: 0.85rem;
}

td {
    font-size: 0.85rem;
}

.ip-badge {
    font-family: monospace;
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
}

.crawler-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
}

.badge-search-engine {
    background: #fee2e2;
    color: #dc2626;
}

.badge-ai-bot {
    background: #e0e7ff;
    color: #4f46e5;
}

.badge-generic-crawler {
    background: #fef3c7;
    color: #d97706;
}

.badge-empty-ua {
    background: #f1f5f9;
    color: #475569;
}

.pagination-container {
    margin-top: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.pagination {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    background: #f1f5f9;
    color: #334155;
    border-radius: 10px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.page-btn:hover {
    background: #e2e8f0;
}

.page-btn.active {
    background: #3b82f6;
    color: white;
}

.page-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.pagination-info {
    color: #64748b;
    font-size: 0.8rem;
}

.empty-row {
    text-align: center;
    padding: 40px;
    color: #94a3b8;
}

/* ========== admin.php 管理员后台专用样式 ========== */
.admin-container {
    max-width: 1400px;
    margin: 0 auto;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-mini-card {
    background: white;
    border-radius: 20px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 4px solid #FFC107;
    border-right: 4px solid #FFC107;
}

.stat-mini-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.02);
}

.stat-mini-number {
    font-size: 34px;
    font-weight: 700;
    color: #1e293b;
}

.stat-mini-label {
    font-size: 13px;
    color: #64748b;
    margin-top: 5px;
}

.three-cols {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    margin-bottom: 30px;
}

.admin-card {
    background: white;
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    border: 2px dashed #673AB7;
}

.admin-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.card-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.form-group label {
    display: block;
    margin-bottom: 3px;
    font-weight: 500;
    color: #1e293b;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px dashed #667eea;
    border-radius: 12px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgb(59 246 234 / 20%);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.toggle-switch {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.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: #cbd5e1;
    transition: 0.3s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #3b82f6;
}

input:checked+.slider:before {
    transform: translateX(24px);
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #9C27B0;
    transform: translateY(-1px);

}

.btn-warning {
    background: #f59e0b;
    color: white;
}

.btn-warning:hover {
    background: #9C27B0;
    transform: translateY(-1px);
}

.btn-danger {
    background: #E91E63;
    color: white;
}

.btn-danger:hover {
    background: #9C27B0;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #2196F3;
    color: white;
}

.btn-secondary:hover {
    background: #475569;
    transform: translateY(-1px);
}

.btn-sm {
    color: #667eea;
    font-weight: 500;
    transition: all 0.25s;
    padding: 8px 25px;
    border-radius: 24px;
    background: #f8fafc;
    gap: 6px;
    border: 1px dashed #667eea;
}

.btn-block {
    width: 100%;
    margin-top: 10px;
}

.data-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.data-buttons .btn {
    justify-content: center;
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-range {
    background: #f8fafc;
    padding: 12px;
    border-radius: 16px;
    margin: 15px 0;
    border: 1px dashed #b91c1c;
}

.alert {
    padding: 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
}

.alert-danger {
    background: #fee2e2;
    color: #b91c1c;
    border: 2px dashed #b91c1c;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
}

.radio-group {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    margin-bottom: 8px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 12px;
    background: #e9efdf;
    transition: all 0.2s;
}

.radio-label:hover {
    background: #e2e8f0;
}

.radio-label input {
    margin: 0;
}

.engine-status {
    font-size: 14px;
    margin-top: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    background: #FFEB3B;
}

.engine-status .available {
    color: #10b981;
}

.engine-status .unavailable {
    color: #ef4444;
}

footer {
    text-align: center;
    padding: 20px;
    color: #94a3b8;
    font-size: 0.75rem;
    margin-top: 20px;
}

.stat-code-card {
    background: white;
    border-radius: 24px;
    padding: 24px;
    margin-top: 0;
    margin-bottom: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.stat-code-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.stat-code-header h4 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    background-clip: text;
}

.stat-code-badge {
    background: #10b981;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.stat-code-desc {
    color: #475569;
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.stat-code-desc code {
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #d946ef;
}

.stat-code-box {
    background: #e2f2ff;
    border-radius: 30px;
    padding: 2px 2px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    border: 1px dashed #3F51B5;
}

.stat-code-content {
    font-family: 'SF Mono', 'Fira Code', 'Monaco', 'Cascadia Code', monospace;
    padding: 10px;
}

.stat-code-copy {
    background: #3b82f6;
    border: none;
    color: white;
    padding: 8px 18px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.stat-code-copy:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

.stat-code-copy:active {
    transform: translateY(0);
}

.stat-code-note {
    color: #64748b;
    font-size: 0.8rem;
    margin: 0;
    padding-top: 8px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 操作日志弹窗样式 */
.logs-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.logs-modal.active {
    display: flex;
}

.logs-modal-content {
    background: white;
    border-radius: 24px;
    width: 90%;
    max-width: 1200px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

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

.logs-modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #1e293b;
}

.logs-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #94a3b8;
    transition: color 0.2s;
}

.logs-modal-close:hover {
    color: #ef4444;
}

.logs-table-container {
    overflow-x: auto;
    padding: 0 24px;
    flex: 1;
}

.logs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

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

.logs-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    position: sticky;
    top: 0;
}

.badge-action {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
}

.badge-SAVE_SETTINGS {
    background: #dbeafe;
    color: #1e40af;
}

.badge-CHANGE_PASSWORD {
    background: #fef3c7;
    color: #92400e;
}

.badge-DELETE_DATA {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-CLEAR_LOGS {
    background: #e0e7ff;
    color: #4338ca;
}

.badge-CLEAR_CRAWLER_LOGS {
    background: #fce7f3;
    color: #be185d;
}

.badge-LOGIN_SUCCESS {
    background: #d1fae5;
    color: #065f46;
}

.badge-LOGIN_FAILED {
    background: #fef3c7;
    color: #92400e;
}

.badge-default {
    background: #f1f5f9;
    color: #475569;
}

.logs-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 16px 24px;
    border-top: 1px solid #e2e8f0;
    background: white;
}

.logs-pagination button {
    padding: 8px 16px;
    background: #f1f5f9;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.logs-pagination button:hover:not(:disabled) {
    background: #3b82f6;
    color: white;
}

.logs-pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Toast 通知样式 */
.toast-message {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #1e293b;
    color: white;
    padding: 12px 24px;
    border-radius: 40px;
    font-size: 0.9rem;
    z-index: 1100;
    opacity: 0;
    transition: opacity 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast-message.show {
    opacity: 1;
}

.toast-message.error {
    background: #dc2626;
}

.toast-message.warning {
    background: #d97706;
}

/* 响应式调整 */
@media (max-width: 1000px) {
    .three-cols {
        grid-template-columns: 1fr;
        gap: 20px;
    }

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

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

    .form-row {
        grid-template-columns: 1fr;
    }

    .stat-code-box {
        flex-direction: column;
        align-items: stretch;
    }

    .stat-code-copy {
        text-align: center;
    }
}