/* 栈可视化工具样式 */

/* 全局样式 */
:root {
    --primary-color: #3498db;
    --primary-hover: #2980b9;
    --secondary-color: #2ecc71;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --gray-light: #ecf0f1;
    --gray-medium: #bdc3c7;
    --gray-dark: #7f8c8d;
    --white: #ffffff;
    --black: #333333;
    --border-radius: 8px;
    --box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: var(--black);
    background-color: #f8f9fa;
}

/* 头部样式 */
header {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--box-shadow);
}

header h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.header-contact {
    flex: 1;
    text-align: center;
    font-size: 1rem;
    font-weight: 500;
}

.back-button {
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--white);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color 0.3s ease;
    text-decoration: none;
}

.back-button:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* 主内容区域样式 */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* 栈容器样式 */
.stack-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .stack-container {
        grid-template-columns: 1fr;
    }
}

/* 栈可视化区域 */
.visualization-section {
    background-color: var(--white);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--box-shadow);
}

.visualization-section h2 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    text-align: center;
}

.stack-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 400px;
}

.stack-outline {
    position: relative;
    width: 100px;
    height: 350px;
    border: 2px solid var(--primary-color);
    border-radius: 4px;
    overflow: hidden;
}

#stackElements {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding: 2px;
}

/* 栈元素样式 */
.stack-element,
.stack-top,
.stack-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2px 0;
    border-radius: 4px;
    font-weight: 600;
    font-size: 1.1rem;
    transition: all 0.3s ease;
}

.stack-element {
    background-color: var(--gray-light);
    color: var(--black);
    border: 1px solid var(--gray-medium);
}

.stack-top {
    background-color: var(--primary-color);
    color: var(--white);
    border: 1px solid var(--primary-hover);
}

.stack-empty {
    background-color: #f0f0f0;
    color: var(--gray-dark);
    border: 1px dashed var(--gray-medium);
    font-style: italic;
}

/* 栈顶指示器 */
#topIndicator {
    position: absolute;
    left: 100%;
    margin-left: 10px;
    background-color: var(--warning-color);
    color: var(--white);
    padding: 0.3rem 0.6rem;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    transform: translateY(-50%);
}

#topIndicator::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 8px solid transparent;
    border-right-color: var(--warning-color);
}

/* 控制面板样式 */
.controls-section {
    background-color: var(--white);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--box-shadow);
}

.controls-section h2 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    text-align: center;
}

/* 操作按钮区域 */
.operation-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 576px) {
    .operation-buttons {
        grid-template-columns: 1fr;
    }
}

.operation-button {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 0.8rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.operation-button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.operation-button.secondary {
    background-color: var(--secondary-color);
}

.operation-button.secondary:hover {
    background-color: #27ae60;
}

.operation-button.danger {
    background-color: var(--danger-color);
}

.operation-button.danger:hover {
    background-color: #c0392b;
}

/* 输入框样式 */
.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--gray-dark);
}

.input-group input[type="number"] {
    width: 100%;
    padding: 0.7rem;
    border: 1px solid var(--gray-medium);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.input-group input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* 栈类型选择样式 */
.stack-type-selection {
    margin-bottom: 1.5rem;
}

.stack-type-selection h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--gray-dark);
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.radio-option input[type="radio"] {
    margin: 0;
}

.radio-option label {
    cursor: pointer;
    font-weight: normal;
}

/* 隐藏容器 */
.hidden {
    display: none;
}

/* 状态信息卡片 */
.status-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.status-card {
    background-color: var(--gray-light);
    padding: 1rem;
    border-radius: var(--border-radius);
    text-align: center;
}

.status-card h4 {
    font-size: 0.9rem;
    color: var(--gray-dark);
    margin-bottom: 0.5rem;
}

.status-card .value {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary-color);
}

/* 操作日志区域 */
.log-section {
    background-color: var(--white);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--box-shadow);
}

.log-section h2 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

#operationLog {
    height: 200px;
    overflow-y: auto;
    background-color: #f9f9f9;
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--gray-medium);
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
}

#operationLog p {
    margin-bottom: 0.3rem;
    word-break: break-all;
}

/* 容量限制到达样式 */
.border-limitReached {
    border-color: var(--danger-color) !important;
    animation: borderPulse 2s infinite;
}

/* 动画效果 */
@keyframes borderPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(231, 76, 60, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
    }
}

.pulse-animation {
    animation: pulse 0.6s ease-in-out;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* 栈元素过渡动画 */
.stack-transition {
    transition: all 0.3s ease;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-medium);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-dark);
}

/* 响应式调整 */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .header-contact {
        order: 3;
    }
    
    main {
        padding: 1rem;
    }
    
    .visualization-section,
    .controls-section,
    .log-section {
        padding: 1.5rem;
    }
    
    .stack-outline {
        width: 80px;
        height: 300px;
    }
    
    .stack-element,
    .stack-top,
    .stack-empty {
        height: 14px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .stack-outline {
        width: 70px;
        height: 250px;
    }
    
    .stack-element,
    .stack-top,
    .stack-empty {
        height: 12px;
        font-size: 0.8rem;
    }
    
    #topIndicator {
        font-size: 0.8rem;
        padding: 0.2rem 0.4rem;
    }
}

/* 代码面板样式（仿照队列可视化工具） */
.code-panel {
    background: #1e1e1e;
    color: #d4d4d4;
    border-radius: 12px;
    padding: 16px 20px;
    font-family: 'Consolas', 'Roboto Mono', monospace;
    font-size: 14px;
    overflow-x: auto;
    line-height: 1.6;
}

.code-line {
    padding: 2px 0;
    padding-left: 12px;
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.code-line.active {
    background: rgba(247, 37, 133, 0.2);
    border-left: 3px solid #f72585;
}

.code-keyword { color: #569cd6; }
.code-function { color: #dcdcaa; }
.code-string { color: #ce9178; }
.code-number { color: #b5cea8; }
.code-comment { color: #6a9955; }
.code-class { color: #4ec9b0; }
.code-self { color: #569cd6; }
.code-operator { color: #d4d4d4; }
.code-method { color: #dcdcaa; }
.code-variable { color: #9cdcfe; }

/* 知识点总结卡片 */
.knowledge-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 20px;
    height: fit-content;
}

.knowledge-title {
    font-size: 16px;
    font-weight: bold;
    color: #1e40af;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #dbeafe;
}

.knowledge-item {
    margin-bottom: 16px;
}

.knowledge-item:last-child {
    margin-bottom: 0;
}

.knowledge-label {
    font-size: 13px;
    font-weight: bold;
    color: #475569;
    margin-bottom: 4px;
}

.knowledge-formula {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 6px 10px;
    font-family: 'Consolas', 'Roboto Mono', monospace;
    font-size: 13px;
    color: #1e40af;
    margin-bottom: 6px;
}

.knowledge-formula code {
    font-family: inherit;
}

.knowledge-desc {
    font-size: 12px;
    color: #64748b;
    line-height: 1.5;
}
