/* ============= 基础样式 ============= */
:root {
    --primary-color: #007AFF;
    --secondary-color: #00C7BE;
    --success-color: #34C759;
    --warning-color: #FF9500;
    --danger-color: #FF3B30;
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f7;
    --bg-tertiary: #e8e8ed;
    --border-color: #d2d2d7;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

.background-decoration {
    position: fixed;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(0, 199, 190, 0.1) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

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

/* ============= 头部导航 ============= */
.header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: all 0.3s ease;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-sm);
}

.logo h1 {
    font-size: 24px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-status {
    display: flex;
    align-items: center;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-dot.error {
    background: var(--danger-color);
}

.status-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ============= 主内容区 ============= */
.main {
    padding: 32px 0;
    position: relative;
    z-index: 1;
}

/* ============= 卡片样式 ============= */
.card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

/* ============= 概览卡片 ============= */
.overview-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.overview-card {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.card-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.card-content {
    flex: 1;
}

.card-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 500;
}

.card-value {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ============= 功能区网格 ============= */
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 24px;
}

/* 2x2 网格布局 */
.content-grid-2x2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.section-card {
    padding: 24px;
}

.section-card .list-container {
    max-height: 400px;
}

.full-width {
    grid-column: 1 / -1;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--bg-tertiary);
}

.section-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

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

.update-time {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ============= 按钮样式 ============= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
}

/* ============= 列表容器 ============= */
.list-container {
    max-height: 500px;
    overflow-y: auto;
    padding: 4px;
}

.list-container::-webkit-scrollbar {
    width: 6px;
}

.list-container::-webkit-scrollbar-track {
    background: transparent;
}

.list-container::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.list-container::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

/* ============= 加载状态 ============= */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ============= 订阅项 ============= */
.subscription-item {
    padding: 16px;
    margin-bottom: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    transition: all 0.2s ease;
}

.subscription-item:hover {
    background: var(--bg-tertiary);
}

.subscription-info {
    flex: 1;
}

.subscription-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.subscription-info h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* ============= 订阅徽章容器 ============= */
.subscription-badges {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============= 节点数量徽章 ============= */
.node-count-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: rgba(0, 122, 255, 0.08);
    color: var(--primary-color);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid rgba(0, 122, 255, 0.15);
    transition: all 0.2s ease;
}

.node-count-badge:hover {
    background: rgba(0, 122, 255, 0.12);
    border-color: rgba(0, 122, 255, 0.25);
}

/* ============= 在线节点徽章 ============= */
.alive-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s ease;
}

/* 在线率高 (>=80%) - 绿色 */
.alive-badge.alive-good {
    background: rgba(52, 199, 89, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(52, 199, 89, 0.2);
}

.alive-badge.alive-good:hover {
    background: rgba(52, 199, 89, 0.15);
    border-color: rgba(52, 199, 89, 0.3);
}

/* 在线率中等 (50%-80%) - 橙色 */
.alive-badge.alive-warning {
    background: rgba(255, 149, 0, 0.1);
    color: var(--warning-color);
    border: 1px solid rgba(255, 149, 0, 0.2);
}

.alive-badge.alive-warning:hover {
    background: rgba(255, 149, 0, 0.15);
    border-color: rgba(255, 149, 0, 0.3);
}

/* 在线率低 (<50%) - 红色 */
.alive-badge.alive-danger {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger-color);
    border: 1px solid rgba(255, 59, 48, 0.2);
}

.alive-badge.alive-danger:hover {
    background: rgba(255, 59, 48, 0.15);
    border-color: rgba(255, 59, 48, 0.3);
}

.subscription-url {
    font-size: 13px;
    color: var(--text-secondary);
    word-break: break-all;
    margin-bottom: 8px;
}

.subscription-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.meta-item {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 8px;
    background: white;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.subscription-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: white;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.icon-btn:hover {
    background: var(--primary-color);
    color: white;
}

.icon-btn.delete-btn:hover {
    background: var(--danger-color);
    color: white;
}

/* ============= 代理过滤器 ============= */
.proxy-filter {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.search-input,
.filter-select {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    background: white;
    transition: all 0.2s ease;
    outline: none;
}

.search-input {
    flex: 1;
}

.search-input:focus,
.filter-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

/* ============= 代理列表 ============= */
.proxy-list {
    display: grid;
    gap: 12px;
}

.proxy-item {
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.proxy-item:hover {
    background: var(--bg-tertiary);
}

.proxy-item.offline {
    opacity: 0.6;
}

.proxy-info {
    flex: 1;
}

.proxy-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.proxy-details {
    font-size: 12px;
    color: var(--text-secondary);
}

.proxy-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-badge {
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
}

.status-badge.online {
    background: rgba(52, 199, 89, 0.1);
    color: var(--success-color);
}

.status-badge.offline {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger-color);
}

.delay-badge {
    padding: 4px 12px;
    background: rgba(0, 122, 255, 0.1);
    color: var(--primary-color);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
}

/* ============= 系统信息 ============= */
.system-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.info-item {
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.info-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.info-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ============= 模态框 ============= */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid var(--bg-tertiary);
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: all 0.2s ease;
    outline: none;
}

.form-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* ============= Toast 通知 ============= */
.toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    padding: 16px 20px;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: toastSlideIn 0.3s ease;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

.toast.warning {
    border-left: 4px solid var(--warning-color);
}

.toast-message {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
}

/* ============= 响应式设计 ============= */
@media (max-width: 1200px) {
    .content-grid-2x2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }

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

    .content-grid {
        grid-template-columns: 1fr;
    }

    .content-grid-2x2 {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .proxy-filter {
        flex-direction: column;
    }

    .modal-content {
        width: 95%;
    }
}

@media (max-width: 480px) {
    .overview-cards {
        grid-template-columns: 1fr;
    }
}

/* ============= 平滑滚动 ============= */
html {
    scroll-behavior: smooth;
}

/* ============= 地区分流样式 ============= */
.region-info-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.08) 0%, rgba(0, 199, 190, 0.08) 100%);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    border: 1px solid rgba(0, 122, 255, 0.15);
}

.region-info-item {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.region-list {
    display: grid;
    gap: 10px;
}

.region-item {
    padding: 14px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.region-item:hover {
    background: var(--bg-tertiary);
}

.region-item.has-port {
    border-color: rgba(0, 122, 255, 0.2);
    background: rgba(0, 122, 255, 0.03);
}

.region-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.region-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.region-flag {
    font-size: 20px;
    line-height: 1;
}

.region-details {
    font-size: 12px;
    color: var(--text-secondary);
    padding-left: 28px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.region-details .alive-badge {
    padding: 2px 8px;
    font-size: 11px;
}

.region-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.port-badge {
    padding: 6px 14px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 122, 255, 0.25);
}

.port-badge.inactive {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    box-shadow: none;
}

/* 小按钮样式 */
.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #e53935;
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.3);
}

.region-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ============= API 统计样式 ============= */
.stats-footer {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.stats-total {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    display: inline-block;
}
