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

body {
    font-family: 'Arial', sans-serif;
    background: #0a0a0a;
    color: #e0e0e0;
    min-height: 100vh;
}

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

/* 头部样式 */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 2px solid #ff6b00;
    margin-bottom: 30px;
}

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

.logo h1 {
    color: #ff6b00;
    font-size: 2em;
}

.logo-img {
    width: 60px;
    height: 60px;
    background: linear-gradient(45deg, #ff6b00, #ff8c00);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 24px;
    color: #000;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.auth-buttons {
    display: flex;
    gap: 10px;
}

.btn-auth {
    padding: 10px 25px;
    background: linear-gradient(45deg, #ff6b00, #ff8c00);
    color: #000;
    border: none;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-auth:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 107, 0, 0.4);
}

.btn-register {
    background: linear-gradient(45deg, #444, #666);
    color: #fff;
}

.btn-register:hover {
    background: linear-gradient(45deg, #555, #777);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid #ff6b00;
    background: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.user-details h3 {
    color: #ff6b00;
    margin-bottom: 5px;
}

.logout-btn {
    background: linear-gradient(45deg, #dc3545, #c82333);
    color: white;
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.logout-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(220, 53, 69, 0.4);
}

/* 主内容区 */
.content {
    background: rgba(30, 30, 30, 0.9);
    border-radius: 10px;
    padding: 30px;
    border: 1px solid #444;
    margin-bottom: 30px;
}

.content h2 {
    color: #ff8c00;
    margin-bottom: 30px;
    text-align: center;
    font-size: 28px;
    border-bottom: 2px solid rgba(255, 107, 0, 0.3);
    padding-bottom: 15px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.content h2 i {
    margin-right: 10px;
    font-size: 28px;
}

/* 服务器控制区域 */
.server-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding: 15px;
    background: rgba(40, 40, 40, 0.8);
    border-radius: 8px;
    border: 1px solid #444;
}

.btn-refresh {
    padding: 10px 25px;
    background: linear-gradient(45deg, #ff6b00, #ff8c00);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-refresh:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 107, 0, 0.4);
    background: linear-gradient(45deg, #ff8c00, #ffa500);
}

.btn-refresh:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.server-stats {
    color: #aaa;
    font-size: 14px;
}

.server-stats span {
    color: #fff;
    font-weight: bold;
}

/* 服务器列表 */
.server-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 20px;
}

.loading-servers, .error-loading, .no-servers {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    background: rgba(40, 40, 40, 0.8);
    border-radius: 8px;
    border: 1px solid #444;
}

.loading-servers i {
    margin-right: 10px;
    animation: spin 1s linear infinite;
}

.error-loading {
    color: #dc3545;
}

.error-loading i {
    font-size: 48px;
    margin-bottom: 15px;
    color: #dc3545;
}

.btn-retry {
    margin-top: 15px;
    padding: 10px 20px;
    background: linear-gradient(45deg, #dc3545, #c82333);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

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

/* 服务器卡片 */
.server-card {
    background: rgba(40, 40, 40, 0.8);
    padding: 25px;
    border-radius: 10px;
    border: 1px solid #444;
    transition: all 0.3s;
}

.server-card:hover {
    border-color: #ff6b00;
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(255, 107, 0, 0.1);
}

.server-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #444;
}

.server-name {
    color: #ff8c00;
    font-size: 18px;
    font-weight: bold;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 10px;
}

.server-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    flex-shrink: 0;
}

.status-online {
    background: rgba(40, 167, 69, 0.2);
    color: #28a745;
    border: 1px solid #28a745;
}

.status-offline {
    background: rgba(220, 53, 69, 0.2);
    color: #dc3545;
    border: 1px solid #dc3545;
}

.server-info {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.info-item {
    text-align: center;
    padding: 12px;
    background: rgba(50, 50, 50, 0.6);
    border-radius: 6px;
    border: 1px solid #333;
}

.info-label {
    font-size: 12px;
    color: #888;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.info-value {
    font-size: 16px;
    color: #fff;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ping-low { color: #28a745 !important; }
.ping-medium { color: #ffc107 !important; }
.ping-high { color: #dc3545 !important; }

.server-players {
    margin: 15px 0;
    padding-top: 15px;
    border-top: 1px solid #444;
}

.players-count {
    color: #ff6b00;
    font-weight: bold;
    font-size: 16px;
    display: block;
    margin-bottom: 10px;
}

.players-progress {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #20c997);
    border-radius: 3px;
    transition: width 0.3s;
}

/* 服务器操作按钮 */
.server-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.server-actions button {
    padding: 12px;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.join-btn {
    flex: 2;
    min-width: 140px;
    background: linear-gradient(45deg, #ff6b00, #ff8c00);
    color: #000;
}

.join-btn:hover {
    background: linear-gradient(45deg, #ff8c00, #ffa500);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 107, 0, 0.4);
}

.join-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.detail-btn {
    flex: 1;
    min-width: 100px;
    background: linear-gradient(45deg, #17a2b8, #138496);
    color: white;
}

.detail-btn:hover {
    background: linear-gradient(45deg, #138496, #117a8b);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(23, 162, 184, 0.4);
}

/* === 页脚 === */
footer {
    margin-top: 50px;
    text-align: center;
    padding: 20px;
    border-top: 1px solid #444;
    color: #888;
    font-size: 14px;
}

footer a {
    color: #ff8c00;
    text-decoration: none;
    margin: 0 10px;
}

footer a:hover {
    text-decoration: underline;
}

/* 模态框样式 */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-container {
    background: rgba(30, 30, 30, 0.95);
    border-radius: 10px;
    border: 2px solid #ff6b00;
    width: 100%;
    max-width: 500px;
    animation: modalFadeIn 0.3s;
}

.server-detail-modal {
    max-width: 700px;
    max-height: 800px; /* 固定高度，确保窗口大小不变 */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #444;
    flex-shrink: 0; /* 防止头部被压缩 */
}

.modal-header h3 {
    color: #ff8c00;
    font-size: 20px;
    margin: 0;
}

.close-modal {
    color: #ff8c00;
    font-size: 24px;
    cursor: pointer;
    background: none;
    border: none;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close-modal:hover {
    background: rgba(255, 107, 0, 0.1);
}

.modal-body {
    padding: 20px;
    overflow: hidden; /* 隐藏溢出内容 */
}

.server-detail-modal .modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 20px;
}

/* 服务器详情样式 */
.server-detail-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.server-detail-header {
    margin-bottom: 20px;
    flex-shrink: 0; /* 防止头部被压缩 */
}

.server-detail-status {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.status-badge, .ping-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
}

.ping-badge {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #444;
}

.server-detail-header h4 {
    color: #ff8c00;
    font-size: 18px;
    margin: 0;
}

.detail-tabs {
    display: flex;
    border-bottom: 1px solid #444;
    margin-bottom: 20px;
    flex-shrink: 0; /* 防止标签被压缩 */
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    border-bottom: 2px solid transparent;
    transition: all 0.3s;
}

.tab-btn:hover {
    color: #ff8c00;
}

.tab-btn.active {
    color: #ff8c00;
    border-bottom: 2px solid #ff8c00;
}

.detail-tab-content {
    flex: 1;
    overflow: hidden;
    min-height: 300px; /* 确保有最小高度 */
    display: flex;
    flex-direction: column;
}

.tab-pane {
    display: none;
    flex: 1;
    overflow: hidden;
    height: 100%;
}

.tab-pane.active {
    display: flex;
    flex-direction: column;
}

#tab-basic {
    overflow: auto; /* 基本信息也允许滚动 */
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.detail-item {
    padding: 15px;
    background: rgba(50, 50, 50, 0.6);
    border-radius: 8px;
    border: 1px solid #333;
}

.detail-item label {
    display: block;
    color: #888;
    font-size: 12px;
    margin-bottom: 5px;
}

.detail-item label i {
    width: 16px;
    margin-right: 8px;
}

.detail-item span {
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    display: block;
}

/* 玩家列表标签页 */
.players-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.players-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 服务器参数标签页 */
.rules-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.rules-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.server-detail-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #444;
    flex-shrink: 0; /* 防止按钮被压缩 */
}

.btn-join, .btn-copy {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-join {
    background: linear-gradient(45deg, #ff6b00, #ff8c00);
    color: #000;
}

.btn-join:hover {
    background: linear-gradient(45deg, #ff8c00, #ffa500);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 107, 0, 0.4);
}

.btn-copy {
    background: linear-gradient(45deg, #6c757d, #495057);
    color: white;
}

.btn-copy:hover {
    background: linear-gradient(45deg, #5a6268, #3d4348);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(108, 117, 125, 0.4);
}

/* 登录注册表单 */
.auth-form-modal .form-group {
    margin-bottom: 15px;
}

.auth-form-modal label {
    display: block;
    margin-bottom: 5px;
    color: #ff8c00;
    font-size: 14px;
    font-weight: bold;
}

.auth-form-modal label i {
    width: 20px;
    margin-right: 8px;
}

.auth-form-modal input {
    width: 100%;
    padding: 10px 15px;
    background: rgba(40, 40, 40, 0.8);
    border: 1px solid #444;
    border-radius: 5px;
    color: #fff;
    font-size: 14px;
}

.auth-form-modal input:focus {
    outline: none;
    border-color: #ff6b00;
}

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

.auth-footer-modal {
    text-align: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #444;
    color: #888;
    font-size: 14px;
}

.auth-footer-modal a {
    color: #ff6b00;
    text-decoration: none;
    font-weight: bold;
}

.auth-footer-modal a:hover {
    text-decoration: underline;
}

.register-note-modal {
    background: rgba(255, 107, 0, 0.1);
    padding: 15px;
    border-radius: 5px;
    border-left: 4px solid #ff6b00;
    margin-bottom: 20px;
}

.register-note-modal h4 {
    color: #ff8c00;
    margin: 0 0 10px 0;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.register-note-modal p {
    color: #ddd;
    font-size: 12px;
    margin: 5px 0;
    line-height: 1.4;
}

/* 玩家和规则表格样式 */
.players-table, .rules-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(40, 40, 40, 0.8);
    table-layout: fixed;
}

.players-table th,
.players-table td,
.rules-table th,
.rules-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #444;
    word-break: break-word;
}

.players-table th,
.rules-table th {
    background: rgba(255, 107, 0, 0.2);
    color: #ff8c00;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 1px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.players-table tr:hover,
.rules-table tr:hover {
    background: rgba(255, 107, 0, 0.1);
}

.players-table .bot-row {
    color: #888;
    font-style: italic;
}

.players-table .bot-row:hover {
    background: rgba(136, 136, 136, 0.1);
}

/* 加载和错误状态 */
.players-loading,
.rules-loading {
    text-align: center;
    padding: 40px;
    color: #ff8c00;
}

.players-error,
.rules-error {
    text-align: center;
    padding: 30px;
    color: #dc3545;
}

.players-error i,
.rules-error i {
    font-size: 48px;
    margin-bottom: 15px;
}

/* 服务器详情中的域名样式 */
.detail-item label i.fa-globe {
    color: #17a2b8;
}

/* 表格容器样式，添加滚动条 */
.table-container {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #444;
    border-radius: 8px;
    background: rgba(30, 30, 30, 0.8);
    margin-top: 15px;
    max-height: 500px; /* 确保滚动条出现 */
}

/* 自定义滚动条样式 */
.table-container::-webkit-scrollbar {
    width: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: rgba(40, 40, 40, 0.8);
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #ff6b00;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #ff8c00;
}

/* 规则摘要栏 */
.rules-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: rgba(40, 40, 40, 0.8);
    border-radius: 6px;
    border: 1px solid #444;
    flex-shrink: 0; /* 防止被压缩 */
}

.rules-summary span {
    color: #ff8c00;
    font-weight: bold;
    font-size: 14px;
}

.btn-collapse {
    padding: 6px 12px;
    background: rgba(255, 107, 0, 0.2);
    color: #ff8c00;
    border: 1px solid #ff6b00;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s;
}

.btn-collapse:hover {
    background: rgba(255, 107, 0, 0.3);
    transform: translateY(-1px);
}

/* 恢复规则字体颜色为白色 */
.rules-table td {
    color: #fff; /* 规则值恢复为白色 */
}

.rules-table td:first-child {
    color: #ff8c00; /* 规则名称保持橙色 */
    font-weight: bold;
}

/* 规则值的样式调整 */
.rule-value {
    max-height: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    transition: max-height 0.3s ease;
}

.rule-row:not(.collapsed) .rule-value {
    max-height: none;
    -webkit-line-clamp: unset;
}

/* 调整规则表格中的按钮 */
.toggle-btn {
    background: rgba(255, 107, 0, 0.1);
    border: 1px solid rgba(255, 107, 0, 0.3);
    color: #ff6b00;
    padding: 2px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    margin-left: 10px;
    vertical-align: middle;
}

.toggle-btn:hover {
    background: rgba(255, 107, 0, 0.2);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
    
    .server-list {
        grid-template-columns: 1fr;
    }
    
    .server-info {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .server-controls {
        flex-direction: column;
        gap: 15px;
    }
    
    .server-stats {
        text-align: center;
    }
    
    .server-detail-modal {
        max-width: 95%;
        max-height: 90vh; /* 移动端使用视口高度 */
    }
    
    .table-container {
        max-height: 350px; /* 移动端也适当增加 */
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .server-actions {
        flex-direction: column;
    }
    
    .server-detail-actions {
        flex-direction: column;
    }
    
    .players-table,
    .rules-table {
        display: block;
        overflow-x: auto;
    }
    
    .players-table th,
    .players-table td,
    .rules-table th,
    .rules-table td {
        padding: 8px 10px;
        font-size: 12px;
    }
    
    .rules-summary {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .btn-collapse {
        align-self: flex-end;
    }
}

@media (max-width: 480px) {
    .server-info {
        grid-template-columns: 1fr;
    }
    
    .server-name {
        font-size: 16px;
    }
    
    .logo h1 {
        font-size: 1.5em;
    }
    
    .content {
        padding: 20px;
    }
    
    .server-card {
        padding: 20px;
    }
    
    .modal-container {
        max-width: 95%;
        margin: 10px;
    }
}