/* ============================================
   Litematic Viewer — 赛博朋克暗色主题样式
   ============================================ */

/* 4.1 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 10px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #050810, #0a1128);
    color: #e2e8f0;
    min-height: 100vh;
    overflow-x: hidden;
}

::selection {
    color: #fff;
    background-color: #a855f7;
}

a {
    text-decoration: none;
    color: inherit;
}

/* 4.2 导航栏 */
.header {
    background: rgba(8, 12, 21, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(168, 85, 247, 0.1);
}

.nav {
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 120rem;
    margin: 0 auto;
    padding: 1.5rem 3rem;
}

.logo {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(90deg, #a855f7, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: -0.02em;
}

/* 4.3 英雄区 */
.main {
    max-width: 120rem;
    margin: 0 auto;
    padding: 0 2rem;
}

.banner {
    text-align: center;
    padding: 4rem 0 2rem;
}

.banner h1 {
    font-size: 3.5rem;
    font-weight: 800;
    background: linear-gradient(90deg, #a855f7, #ec4899, #f97316);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    line-height: 1.2;
    margin-bottom: 1rem;
}

.banner-subtitle {
    font-size: 1.6rem;
    color: #94a3b8;
    font-weight: 400;
}

/* 4.4 上传区域 */
.upload-section {
    padding: 1rem 0 3rem;
}

.upload-zone {
    max-width: 60rem;
    margin: 0 auto;
    min-height: 25rem;
    border: 2px dashed rgba(168, 85, 247, 0.4);
    border-radius: 1.5rem;
    background: rgba(168, 85, 247, 0.03);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-zone:hover,
.upload-zone.dragover {
    border: 2px solid rgba(168, 85, 247, 0.8);
    background: rgba(168, 85, 247, 0.08);
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.2);
}

.upload-icon {
    color: #a855f7;
    opacity: 0.7;
    transition: all 0.3s ease;
}

.upload-zone:hover .upload-icon {
    opacity: 1;
    transform: translateY(-4px);
}

.upload-text {
    font-size: 1.6rem;
    color: #e2e8f0;
    font-weight: 600;
}

.upload-hint {
    font-size: 1.3rem;
    color: #64748b;
}

/* 4.5 预览区域 */
.preview-section {
    padding: 0 0 2rem;
}

.preview-container {
    display: flex;
    gap: 2rem;
    align-items: stretch;
}

.canvas-wrapper {
    flex: 1;
    min-width: 0;
}

.canvas-container {
    position: relative;
    width: 100%;
    height: 65rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(168, 85, 247, 0.15);
    border-radius: 1.5rem;
    overflow: hidden;
}

#three-canvas {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 1.5rem;
}

/* 4.6 信息面板 */
.info-panel {
    width: 30rem;
    flex-shrink: 0;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.06), rgba(236, 72, 153, 0.04));
    border: 1px solid rgba(168, 85, 247, 0.15);
    border-radius: 1.5rem;
    padding: 2rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    overflow-y: auto;
    max-height: 65rem;
}

.info-title {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(90deg, #a855f7, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 0.8rem;
}

.info-divider,
.stats-divider {
    height: 1px;
    background: linear-gradient(90deg, rgba(168, 85, 247, 0.3), transparent);
    margin-bottom: 1.5rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-size: 1.3rem;
    color: #94a3b8;
}

.info-value {
    font-size: 1.3rem;
    color: #e2e8f0;
    font-weight: 600;
    text-align: right;
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 方块统计 */
.block-stats {
    margin-top: 2rem;
}

.stats-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #e2e8f0;
    margin-bottom: 0.8rem;
}

.stats-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-name {
    font-size: 1.2rem;
    color: #94a3b8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 18rem;
}

.stat-count {
    font-size: 1.1rem;
    color: #64748b;
    flex-shrink: 0;
}

/* 4.12 方块统计进度条 */
.block-stat-bar {
    height: 0.6rem;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 0.3rem;
    overflow: hidden;
}

.block-stat-fill {
    height: 100%;
    background: linear-gradient(90deg, #a855f7, #ec4899);
    border-radius: 0.3rem;
    transition: width 0.5s ease;
}

.stats-toggle-btn {
    display: none;
    width: 100%;
    margin-top: 1rem;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.6rem;
    color: #a78bfa;
    font-size: 1.3rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
}

.stats-toggle-btn:hover {
    background: rgba(168, 85, 247, 0.1);
    border-color: rgba(168, 85, 247, 0.3);
    color: #c084fc;
}

/* 4.7 控制面板 */
.controls-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 1.2rem 2rem;
    margin: 1rem 0 3rem;
    background: rgba(8, 12, 21, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 1rem;
    border: 1px solid rgba(168, 85, 247, 0.1);
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.control-label {
    font-size: 1.2rem;
    color: #94a3b8;
    white-space: nowrap;
}

.layer-slider-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.layer-value {
    font-size: 1.2rem;
    color: #a855f7;
    font-weight: 600;
    min-width: 2.5rem;
    text-align: center;
}

/* Range input 自定义 */
.range-input {
    -webkit-appearance: none;
    appearance: none;
    width: 12rem;
    height: 0.4rem;
    background: rgba(168, 85, 247, 0.2);
    border-radius: 0.2rem;
    outline: none;
    cursor: pointer;
}

.range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 1.4rem;
    height: 1.4rem;
    background: linear-gradient(135deg, #a855f7, #ec4899);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.5);
    transition: transform 0.2s ease;
}

.range-input::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.range-input::-moz-range-thumb {
    width: 1.4rem;
    height: 1.4rem;
    background: linear-gradient(135deg, #a855f7, #ec4899);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.5);
}

/* 4.8 控制按钮 */
.control-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.5rem;
    background: rgba(168, 85, 247, 0.08);
    border: 1px solid rgba(168, 85, 247, 0.2);
    border-radius: 0.8rem;
    color: #94a3b8;
    font-size: 1.3rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
}

.control-btn:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3);
    color: #e2e8f0;
    border-color: rgba(168, 85, 247, 0.5);
    background: rgba(168, 85, 247, 0.15);
}

.control-btn.active {
    background: linear-gradient(135deg, #a855f7, #ec4899);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3);
}

.control-btn.active:hover {
    filter: brightness(1.1);
}

.control-btn.btn-danger:hover {
    border-color: rgba(239, 68, 68, 0.6);
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.2);
}

.control-btn svg {
    flex-shrink: 0;
}

/* 4.10 加载遮罩 */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(5, 8, 16, 0.9), rgba(10, 17, 40, 0.9));
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1.5rem;
    z-index: 10;
    border-radius: 1.5rem;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 4rem;
    height: 4rem;
    border: 3px solid rgba(168, 85, 247, 0.2);
    border-top-color: #a855f7;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1.6rem;
    color: #a855f7;
    font-weight: 600;
}

/* 4.11 空状态 */
.empty-state {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
    color: #64748b;
    pointer-events: none;
}

.empty-state svg {
    opacity: 0.3;
}

.empty-state p {
    font-size: 1.4rem;
}

.empty-state.hidden {
    display: none;
}

/* 4.9 Toast 提示 */
.toast {
    position: fixed;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 1.2rem 2.4rem;
    border-radius: 0.8rem;
    color: #fff;
    font-size: 1.4rem;
    font-weight: 500;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1000;
    animation: toastIn 0.3s ease;
    white-space: nowrap;
}

.toast.success {
    background: linear-gradient(135deg, #10b981, #059669);
}

.toast.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.toast.info {
    background: linear-gradient(135deg, #a855f7, #ec4899);
}

.toast.fade-out {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-1rem); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(-50%) translateY(0); }
    to { opacity: 0; transform: translateX(-50%) translateY(-1rem); }
}

/* 错误弹窗（需手动关闭） */
.error-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.2s ease;
}

.error-modal {
    background: rgba(15, 20, 35, 0.98);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 1.2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 30px rgba(239, 68, 68, 0.1);
    max-width: 42rem;
    width: 90%;
    overflow: hidden;
}

.error-modal-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid rgba(239, 68, 68, 0.15);
    font-size: 1.6rem;
    font-weight: 700;
    color: #ef4444;
}

.error-modal-body {
    padding: 2rem;
}

.error-modal-body p {
    font-size: 1.4rem;
    color: #e2e8f0;
    line-height: 1.6;
    word-break: break-all;
}

.error-modal-footer {
    padding: 1rem 2rem 1.5rem;
    display: flex;
    justify-content: flex-end;
}

.error-modal-btn {
    padding: 0.8rem 2rem;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    border: none;
    border-radius: 0.6rem;
    font-size: 1.4rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.error-modal-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
    filter: brightness(1.1);
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Footer */
.footer {
    text-align: center;
    padding: 3rem 2rem;
    border-top: 1px solid rgba(168, 85, 247, 0.1);
}

.footer p {
    font-size: 1.2rem;
    color: #64748b;
}

/* 隐藏预览区域的初始状态 */
#preview-section {
    display: none;
}

#controls-bar {
    display: none;
}

/* ============================================
   响应式设计
   ============================================ */
@media (max-width: 768px) {
    .nav {
        padding: 1.2rem 1.5rem;
    }

    .logo {
        font-size: 1.6rem;
    }

    .banner h1 {
        font-size: 2.4rem;
    }

    .banner-subtitle {
        font-size: 1.4rem;
    }

    .upload-zone {
        min-height: 18rem;
        padding: 2rem;
    }

    .upload-icon svg {
        width: 48px;
        height: 48px;
    }

    .upload-text {
        font-size: 1.4rem;
    }

    .preview-container {
        flex-direction: column;
    }

    .info-panel {
        width: 100%;
        max-height: none;
    }

    .canvas-container {
        height: 40rem;
    }

    .controls-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem 1.5rem;
    }

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

    .range-input {
        width: 8rem;
    }

    .control-btn {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .banner h1 {
        font-size: 2rem;
    }

    .canvas-container {
        height: 30rem;
    }

    .layer-slider-group {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* 贴图设置模态框 */
.texture-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.texture-modal-overlay.active {
    display: flex;
}

.texture-modal {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 1px solid rgba(168, 85, 247, 0.2);
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.texture-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid rgba(168, 85, 247, 0.1);
}

.texture-modal-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(90deg, #a855f7, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin: 0;
}

.texture-modal-close {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #ef4444;
    transition: all 0.3s ease;
}

.texture-modal-close:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: rotate(90deg);
}

.texture-modal-body {
    padding: 2rem;
}

.texture-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.texture-label {
    font-size: 1.4rem;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
}

.texture-select {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(168, 85, 247, 0.2);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    font-size: 1.4rem;
    color: #e2e8f0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.texture-select:hover,
.texture-select:focus {
    border-color: rgba(168, 85, 247, 0.5);
    background: rgba(255, 255, 255, 0.08);
}

.texture-select option {
    background: #1a1a2e;
    color: #e2e8f0;
    padding: 0.5rem;
}

.texture-config {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.config-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: #a855f7;
    margin-bottom: 1rem;
}

.face-config-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.face-config-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.face-config-item .face-label {
    font-size: 1.2rem;
    font-weight: 500;
    color: #94a3b8;
}

.texture-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(168, 85, 247, 0.2);
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    font-size: 1.2rem;
    color: #e2e8f0;
    font-family: 'Inter', monospace;
    transition: all 0.3s ease;
}

.texture-input:hover,
.texture-input:focus {
    border-color: rgba(168, 85, 247, 0.5);
    background: rgba(255, 255, 255, 0.08);
    outline: none;
}

.texture-input::placeholder {
    color: #64748b;
}

.quick-settings {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.8rem;
}

.quick-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.quick-btn:hover {
    background: rgba(168, 85, 247, 0.2);
    border-color: rgba(168, 85, 247, 0.5);
    transform: translateY(-2px);
}

.quick-btn svg {
    width: 24px;
    height: 24px;
}

.texture-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.8rem;
}

.texture-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0.8rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(168, 85, 247, 0.2);
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.texture-action-btn:hover {
    background: rgba(168, 85, 247, 0.15);
    border-color: rgba(168, 85, 247, 0.4);
    transform: translateY(-2px);
}

.texture-action-btn.btnSave {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
    color: #22c55e;
}

.texture-action-btn.btnSave:hover {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.5);
}

.texture-action-btn.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.texture-action-btn.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
}

.texture-action-btn svg {
    width: 20px;
    height: 20px;
}

/* 按钮主要样式 */
.btn-primary {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.2), rgba(236, 72, 153, 0.2));
    border-color: rgba(168, 85, 247, 0.4);
}

.btn-primary:hover {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.3), rgba(236, 72, 153, 0.3));
    border-color: rgba(168, 85, 247, 0.6);
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}

/* 响应式调整 */
@media (max-width: 768px) {
    .face-config-row {
        grid-template-columns: 1fr;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }

    .texture-actions {
        grid-template-columns: repeat(2, 1fr);
    }
}
