/**
 * Minecraft Server Status - 前端样式
 */

.mcss-widget,
.mcss-display {
    max-width: 100%;
    margin: 0;
    padding: 0;
}

.mcss-server-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden; /* 确保图表与内容被卡片圆角裁切在内部 */
    position: relative;
    animation: mcss-card-fade-in 360ms ease-out both; /* 进入动画 */
    transition: transform 160ms ease, box-shadow 160ms ease; /* 悬停动效 */
}

/* 紧凑样式：默认对列表更友好，尽量压缩高度 */
.mcss-widget .mcss-server-card,
.mcss-display .mcss-server-card {
    padding: 12px;
    margin-bottom: 14px;
}

.mcss-server-image {
    text-align: center;
    margin-bottom: 8px;
}

.mcss-server-image img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    max-height: 200px;
    object-fit: cover;
    display: block;
    margin: 0 auto;
}

/* Minecraft服务器favicon通常是64x64像素 */
.mcss-server-image img[src^="data:image"] {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.mcss-server-info {
    text-align: center;
}

.mcss-server-name {
    font-size: 24px;
    font-weight: bold;
    margin: 0 0 10px 0;
    color: #333;
}

.mcss-widget .mcss-server-name,
.mcss-display .mcss-server-name {
    font-size: 18px;
    margin-bottom: 6px;
}

.mcss-server-slogan {
    font-size: 14px;
    color: #666;
    font-style: italic;
    margin: 0 0 10px 0;
}

/* 标语单行省略，节省空间 */
.mcss-widget .mcss-server-slogan,
.mcss-display .mcss-server-slogan {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}

.mcss-server-status {
    margin-top: 15px;
}

.mcss-widget .mcss-server-status,
.mcss-display .mcss-server-status {
    margin-top: 8px;
}

.mcss-status-online,
.mcss-status-offline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 500;
    margin-bottom: 15px;
}

.mcss-status-online {
    background-color: #e8f5e9;
    color: #2e7d32;
}

.mcss-status-offline {
    background-color: #ffebee;
    color: #c62828;
}

.mcss-status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.mcss-status-indicator.online {
    background-color: #4caf50;
    box-shadow: 0 0 4px rgba(76, 175, 80, 0.6);
}

.mcss-status-indicator.offline {
    background-color: #f44336;
    box-shadow: 0 0 4px rgba(244, 67, 54, 0.6);
}

.mcss-server-details {
    text-align: left;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

/* 居中显示版本与人数 */
.mcss-server-details.centered {
    text-align: center;
}

.mcss-server-details.centered .mcss-detail-item {
    display: inline-block;
    border-bottom: none;
    padding: 0 14px;
}

.mcss-server-details.centered .mcss-detail-label,
.mcss-server-details.centered .mcss-detail-value {
    text-align: center;
    flex: initial;
}

.mcss-server-details.centered .mcss-detail-value strong {
    font-size: 20px;
}

.mcss-detail-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f5f5f5;
}

.mcss-detail-item:last-child {
    border-bottom: none;
}

.mcss-detail-label {
    font-weight: 500;
    color: #666;
    flex: 0 0 40%;
}

.mcss-detail-value {
    color: #333;
    text-align: right;
    flex: 1;
}

.mcss-detail-value strong {
    color: #2196f3;
    font-size: 18px;
}

/* 历史图表样式 */
.mcss-history-chart {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 当图表包含在卡片内时，去掉二次边框与阴影，让其与卡片风格一致 */
.mcss-server-card .mcss-history-chart {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    margin-top: 15px;
}

/* 区间滑块（双滑块） */
.mcss-range {
    margin-top: 8px;
}
.mcss-range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #666;
    margin-bottom: 6px;
}
.mcss-range-sep { opacity: 0.6; padding: 0 6px; }
.mcss-range-inputs {
    position: relative;
    height: 22px;
}
.mcss-range-inputs input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    position: absolute;
    left: 0; right: 0;
    width: 100%;
    height: 4px;
    margin: 9px 0;
    background: transparent;
    pointer-events: none; /* 叠加两条，仅thumb可交互 */
}
.mcss-range-inputs input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    pointer-events: auto;
    width: 14px; height: 14px; border-radius: 50%;
    background: #2196f3; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2);
}
.mcss-range-inputs input[type="range"]::-moz-range-thumb {
    pointer-events: auto;
    width: 14px; height: 14px; border-radius: 50%;
    background: #2196f3; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2);
}
.mcss-range-inputs input[type="range"]::-webkit-slider-runnable-track {
    height: 4px; background: linear-gradient(90deg,#e0e0e0,#e0e0e0);
    border-radius: 2px;
}
.mcss-range-inputs input[type="range"]::-moz-range-track {
    height: 4px; background: #e0e0e0; border-radius: 2px;
}

/* 卡片悬停轻微浮起 */
.mcss-server-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

/* 入场动画 */
@keyframes mcss-card-fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mcss-chart-title { display: none; }


/* 让卡片随图表自适应高度：用CSS变量统一图表高度 */
.mcss-chart-container {
    position: relative;
    width: 100%;
    height: var(--mcss-chart-height, 300px);
    min-height: var(--mcss-chart-height, 300px);
    overflow: hidden; /* 强制裁切图表绘制区域，避免溢出卡片 */
    box-sizing: border-box;
}

.mcss-chart-canvas {
    display: block;
    max-width: 100%;
    width: 100% !important;
    height: var(--mcss-chart-height, 300px) !important;
    min-height: var(--mcss-chart-height, 300px);
}

.mcss-widget .mcss-history-chart {
    margin-top: 15px;
}

.mcss-widget .mcss-chart-container {
    --mcss-chart-height: 160px;
}

.mcss-display .mcss-chart-container {
    --mcss-chart-height: 220px;
}

.mcss-refresh-time {
    text-align: center;
    margin-top: 6px;
    color: #999;
    font-size: 11px;
}

/* 并排布局：服务器卡片 + 图表 */
.mcss-pair {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 992px) {
    .mcss-pair {
        grid-template-columns: 1fr 1.2fr;
        align-items: start;
    }
    .mcss-pair .mcss-server-card { margin-bottom: 0; }
}

/* 弹窗样式 */
.mcss-history-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
}

.mcss-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
}

.mcss-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(90vw, 900px);
    max-height: 90vh;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.mcss-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    font-weight: 600;
}

.mcss-modal-close {
    border: none;
    background: transparent;
    font-size: 22px;
    cursor: pointer;
}

.mcss-modal-body {
    padding: 12px 16px 16px 16px;
}

.mcss-card-clickable {
    cursor: pointer;
}

/* 打开弹窗时禁止页面滚动 */
body.mcss-modal-open {
    overflow: hidden;
}

/* 多服务器下的两列自适应：让每个服务器单元并排 */
.mcss-display.mcss-pair,
.mcss-widget.mcss-pair {
    box-sizing: border-box;
    width: 100%;
    display: grid; /* 内部已为grid，两列布局 */
    margin-bottom: 20px;
}

/* 父容器未知时，使用inline布局在大屏自动并排两列 */
@media (min-width: 992px) {
    .mcss-display.mcss-pair,
    .mcss-widget.mcss-pair {
        display: inline-grid; /* 使多个元素在一行显示并可换行 */
        vertical-align: top;
        width: calc(50% - 12px);
        margin-right: 16px;
    }
    /* 每行最后一个去掉右间距（简单处理：当父级换行时不精确，能满足常见布局） */
    .mcss-display.mcss-pair:nth-child(2n),
    .mcss-widget.mcss-pair:nth-child(2n) {
        margin-right: 0;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .mcss-server-card {
        padding: 15px;
    }
    
    .mcss-server-name {
        font-size: 20px;
    }
    
    .mcss-detail-item {
        flex-direction: column;
        gap: 5px;
    }
    
    .mcss-detail-label {
        flex: 1;
    }
    
    .mcss-detail-value {
        text-align: left;
    }
    
    .mcss-chart-container {
        --mcss-chart-height: 200px;
    }
}

