/* 自定义工具类 - 纯 CSS，不依赖 @apply */
.queue-transition {
    transition: all 0.5s ease;
}

.pulse-animation {
    animation: pulse 2s infinite;
}

.queue-element {
    background-color: #4cc9f0;
    border: 2px solid #4361ee;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.queue-empty {
    background-color: #f3f4f6;
    border: 2px solid #d1d5db;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-weight: 700;
}

.queue-cell-occupied {
    background-color: #4361ee;
    border: 2px solid #4361ee;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.queue-cell-empty {
    background-color: #f9fafb;
    border: 2px solid #d1d5db;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-weight: 700;
}

.tail-placeholder {
    border-style: dashed;
    background-image: repeating-linear-gradient(
        45deg,
        #f9fafb,
        #f9fafb 8px,
        #f3f4f6 8px,
        #f3f4f6 16px
    );
}

.button-primary {
    background-color: #4361ee;
    color: white;
    font-weight: 700;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.3s;
    outline: none;
}

.button-primary:hover {
    background-color: rgba(67, 97, 238, 0.9);
}

.button-primary:focus {
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.5);
}

.button-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.button-secondary {
    background-color: #e5e7eb;
    color: #1f2937;
    font-weight: 700;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.3s;
    outline: none;
}

.button-secondary:hover {
    background-color: #d1d5db;
}

.button-secondary:focus {
    box-shadow: 0 0 0 3px rgba(156, 163, 175, 0.5);
}

.button-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.button-danger {
    background-color: #ef4444;
    color: white;
    font-weight: 700;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.3s;
    outline: none;
}

.button-danger:hover {
    background-color: #dc2626;
}

.button-danger:focus {
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.5);
}

.button-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tab-active {
    background-color: #4361ee;
    color: white;
}

.tab-inactive {
    background-color: #e5e7eb;
    color: #374151;
}

.tab-inactive:hover {
    background-color: #d1d5db;
}

@keyframes slideInRight {
    from { transform: translateX(80px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutLeft {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(-80px); opacity: 0; }
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(58, 134, 255, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(58, 134, 255, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(58, 134, 255, 0); }
}

@keyframes popIn {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.slide-in {
    animation: slideInRight 0.5s ease forwards;
}

.slide-out {
    animation: slideOutLeft 0.5s ease forwards;
}

.pop-in {
    animation: popIn 0.3s ease forwards;
}

.pointer-indicator {
    transition: all 0.4s ease;
}

/* 代码面板样式 */
.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; }

/* 普通队列布局 */
.queue-track {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 120px;
    padding: 20px;
    position: relative;
    overflow-x: auto;
}

.queue-item-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    min-width: 64px;
}

.queue-pointer-label {
    height: 20px;
    font-size: 11px;
    font-weight: bold;
    color: #4361ee;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.queue-pointer-label.tail {
    color: #f72585;
}

.queue-pointer-label.head-tail {
    color: #7c3aed;
}

.queue-pointer-label.empty {
    visibility: hidden;
}

.queue-item {
    width: 64px;
    height: 64px;
    font-size: 18px;
    flex-shrink: 0;
}

.queue-flow-arrow {
    color: #9ca3af;
    font-size: 14px;
    flex-shrink: 0;
}

/* 知识点总结卡片 */
.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;
}

/* 循环队列环形视觉 */
.circular-visual {
    position: relative;
    width: 380px;
    height: 380px;
    margin: 0 auto;
}

.ring-track {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    border: 3px dashed #d1d5db;
    border-radius: 50%;
    pointer-events: none;
}

.ring-cell {
    position: absolute;
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    transition: all 0.5s ease;
    transform-origin: center center;
}

.ring-cell .cell-idx {
    position: absolute;
    bottom: -18px;
    font-size: 11px;
    color: #888;
}

.ring-pointer {
    position: absolute;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.4s ease;
    z-index: 20;
    white-space: nowrap;
    transform: translate(-50%, -50%);
}

.badge-head { background: #3a86ff; color: white; }
.badge-tail { background: #f72585; color: white; }

/* 循环队列线性数组视图 */
.linear-array-view {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.linear-cell-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.linear-cell {
    width: 48px;
    height: 48px;
    font-size: 14px;
    flex-shrink: 0;
}

.linear-cell-index {
    font-size: 10px;
    color: #888;
    margin-top: 2px;
}

/* 统计面板 */
.stat-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 14px;
    text-align: center;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #4361ee;
}

.stat-label {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
}

/* 错误提示 */
.input-error {
    color: #dc2626;
    font-size: 12px;
    margin-top: 4px;
}

/* 说明文字 */
.help-text {
    background: #eff6ff;
    border-left: 4px solid #4361ee;
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    font-size: 14px;
    color: #1e40af;
    margin-bottom: 16px;
}

/* 页脚 */
.page-footer {
    text-align: center;
    padding: 20px;
    color: #7f8c8d;
    border-top: 1px solid #e1e4e8;
    font-size: 14px;
    background: #f9fafb;
}

.page-footer a {
    color: #4361ee;
    text-decoration: none;
}

.page-footer a:hover {
    text-decoration: underline;
}

/* 响应式 */
@media (max-width: 640px) {
    /* 普通队列：缩小单元格并减少内边距，避免在 360px 左右视口下溢出 */
    .queue-track {
        min-height: 100px;
        padding: 12px;
    }
    .queue-item-wrapper {
        min-width: 48px;
    }
    .queue-item {
        width: 48px;
        height: 48px;
        font-size: 14px;
    }
    .queue-pointer-label {
        font-size: 10px;
    }
    .queue-flow-arrow {
        font-size: 12px;
    }

    /* 循环队列：针对 360–390px 视口进一步缩小环形图 */
    .circular-visual {
        width: 280px;
        height: 280px;
    }
    .ring-track {
        width: 220px;
        height: 220px;
    }
    .ring-cell {
        width: 40px;
        height: 40px;
        font-size: 12px;
    }
    .ring-cell .cell-idx {
        bottom: -14px;
        font-size: 9px;
    }
    .ring-pointer {
        font-size: 9px;
        padding: 1px 4px;
    }

    /* 循环队列线性数组视图：同步缩小单元格 */
    .linear-cell {
        width: 40px;
        height: 40px;
        font-size: 13px;
    }

    /* 代码面板：避免小屏下字体/内边距过大导致横向溢出 */
    .code-panel {
        font-size: 12px;
        padding: 12px;
    }
    .code-line {
        padding-left: 8px;
    }

    /* 知识点公式：强制长公式换行 */
    .knowledge-formula {
        word-break: break-all;
    }
}
