/* 基础样式设置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Arial, sans-serif;
}

body {
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    padding-bottom: 40px;
}

/* 头部样式 */
header {
    background-color: #2c3e50;
    color: white;
    text-align: center;
    padding: 2rem 1rem;
    margin-bottom: 2rem;
}

header h1 {
    margin-bottom: 0.5rem;
    font-size: 2.2rem;
}

header p {
    max-width: 800px;
    margin: 0 auto;
    font-size: 1.1rem;
    opacity: 0.9;
}

/* 主内容区样式 */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* 可视化容器样式 */
.visualization-container {
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 2rem;
    margin-bottom: 2rem;
    min-height: 300px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

#array-container {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    width: 100%;
    height: 250px;
    position: relative;
}

/* 数组元素（柱状图）样式 */
.array-bar {
    background-color: #3498db;
    border-radius: 4px 4px 0 0;
    transition: height 0.3s ease, background-color 0.3s ease;
    position: relative;
}

.array-bar::after {
    content: attr(data-value);
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.9rem;
    color: #555;
}

.array-bar.comparing {
    background-color: #e74c3c;
    scale: 1.05;
}

.array-bar.sorted {
    background-color: #2ecc71;
}

.array-bar.pivot {
    background-color: #f39c12;
}

/* 控制区域样式 */
.controls {
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
    background-color: #3498db;
    color: white;
}

button:hover:not(:disabled) {
    background-color: #2980b9;
    transform: translateY(-2px);
}

button:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

button:active:not(:disabled) {
    transform: translateY(0);
}

#start-btn { background-color: #2ecc71; }
#start-btn:hover:not(:disabled) { background-color: #27ae60; }

#pause-btn { background-color: #f39c12; }
#pause-btn:hover:not(:disabled) { background-color: #e67e22; }

#reset-btn { background-color: #e74c3c; }
#reset-btn:hover:not(:disabled) { background-color: #c0392b; }

/* 选项区域样式 */
.options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    align-items: center;
}

.array-input, .array-options, .animation-speed {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-weight: 500;
    color: #555;
}

input[type="text"], input[type="number"] {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

input[type="range"] {
    width: 100%;
}

/* 状态显示样式 */
.status-display {
    display: flex;
    justify-content: space-between;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
}

.status-display span {
    font-weight: bold;
    color: #2c3e50;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .status-display {
        flex-direction: column;
        gap: 10px;
    }

    .button-group {
        justify-content: center;
    }

    header h1 {
        font-size: 1.8rem;
    }
}

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

    .visualization-container {
        padding: 1rem;
    }

    .array-bar::after {
        font-size: 0.8rem;
        bottom: -20px;
    }
}

/* 算法分析区域样式 */
.algorithm-analysis {
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.algorithm-analysis h2 {
    color: #2c3e50;
    margin-bottom: 1rem;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
}

.analysis-metrics {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.metric {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    min-width: 150px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.metric p {
    font-size: 1.1rem;
    color: #333;
}

.metric span {
    font-weight: bold;
    color: #2980b9;
    font-size: 1.2rem;
}

.complexity-analysis h3 {
    color: #2c3e50;
    margin-bottom: 0.8rem;
    font-size: 1.3rem;
}

.complexity-analysis p {
    margin: 0.5rem 0;
    line-height: 1.6;
    color: #555;
}

.complexity-analysis strong {
    color: #e74c3c;
}