/* ============================================
   XMAS PHOTO PRINTER - Pixel Tech Style
   ============================================ */

/* CSS Variables - 颜色主题 */
:root {
    /* 背景色 - 更柔和的深色 */
    --bg-primary: #0f1419;
    --bg-secondary: #15202b;
    --bg-card: #1c2732;
    --bg-hover: #253341;
    
    /* 主色调 - 柔和的青蓝 */
    --accent-primary: #5bcefa;
    --accent-secondary: #48a9c7;
    --accent-glow: rgba(91, 206, 250, 0.25);
    
    /* 强调色 - 温暖的玫瑰红 */
    --accent-red: #f5a9b8;
    --accent-red-glow: rgba(245, 169, 184, 0.25);
    
    /* 文字色 - 更柔和的对比度 */
    --text-primary: #f0f4f8;
    --text-secondary: #a8b9c9;
    --text-muted: #6b7d8f;
    
    /* 纸张色 */
    --paper-bg: #faf8f5;
    --paper-border: #e0dbd4;
    --paper-text: #2d3436;
    
    /* 字体 */
    --font-pixel: 'VT323', monospace;
    --font-mono: 'Space Mono', monospace;
    
    /* 尺寸 */
    --card-width: 340px;
    --card-photo-height: 340px;
    --border-radius: 4px;
    
    /* 动画 */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-mono);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* 背景渐变 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 15% 15%, rgba(91, 206, 250, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 85% 85%, rgba(245, 169, 184, 0.03) 0%, transparent 50%),
        linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    pointer-events: none;
    z-index: -1;
}

/* 扫描线效果 */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    );
    pointer-events: none;
    z-index: 9999;
}

/* ============================================
   顶部导航栏
   ============================================ */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 28px;
    background: rgba(15, 20, 25, 0.95);
    border-bottom: 1px solid rgba(91, 206, 250, 0.15);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    color: var(--accent-primary);
    font-size: 1.2rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.logo-text {
    font-family: var(--font-pixel);
    font-size: 1.5rem;
    letter-spacing: 2px;
    color: var(--text-primary);
}

.version {
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 2px 6px;
    border: 1px solid var(--text-muted);
    border-radius: var(--border-radius);
}

.status-display {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid rgba(91, 206, 250, 0.2);
    border-radius: var(--border-radius);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-primary);
    animation: blink 1.5s infinite;
}

.status-dot.active {
    background: #00ff88;
    box-shadow: 0 0 8px #00ff88;
}

.status-dot.processing {
    background: #ffaa00;
    box-shadow: 0 0 8px #ffaa00;
    animation: blink 0.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.status-text {
    font-family: var(--font-pixel);
    font-size: 1rem;
    letter-spacing: 1px;
    color: var(--accent-primary);
}

/* ============================================
   主内容区
   ============================================ */
.main-container {
    display: flex;
    gap: 32px;
    padding: 32px;
    max-width: 720px;
    margin: 0 auto;
    min-height: calc(100vh - 140px);
}

/* 左侧预览区 */
.preview-section {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* 打印卡片 */
.print-card {
    position: relative;
    filter: drop-shadow(0 16px 48px rgba(0, 0, 0, 0.4));
}

.paper {
    width: var(--card-width);
    background: var(--paper-bg);
    padding: 16px;
    position: relative;
}

/* 纸张纹理 */
.paper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%' height='100%' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
}

.paper-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.header-line {
    flex: 1;
    height: 1px;
    background: var(--paper-border);
}

.header-label {
    font-family: var(--font-pixel);
    font-size: 0.8rem;
    color: #9ca3af;
    letter-spacing: 2px;
}

/* 照片框 */
.photo-frame {
    width: 100%;
    height: var(--card-photo-height);
    background: #1a1a1a;
    position: relative;
    overflow: hidden;
    border-radius: 2px;
}

#photoCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* 上传提示 */
.upload-prompt {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
    background: rgba(15, 20, 25, 0.95);
    border: 2px dashed rgba(91, 206, 250, 0.25);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.upload-prompt:hover {
    border-color: var(--accent-primary);
    background: rgba(91, 206, 250, 0.05);
}

.upload-prompt.drag-over {
    border-color: var(--accent-primary);
    background: rgba(91, 206, 250, 0.08);
}

.upload-prompt.hidden {
    display: none;
}

.prompt-icon {
    font-size: 2rem;
    color: var(--accent-primary);
    animation: float 2s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.prompt-text {
    font-family: var(--font-pixel);
    font-size: 1.2rem;
    color: var(--accent-primary);
    letter-spacing: 2px;
}

.prompt-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* 贴纸容器 */
.stickers-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.sticker {
    position: absolute;
    cursor: move;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    transition: filter 0.1s;
}

.sticker:hover {
    filter: brightness(1.1);
}

.sticker.selected {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.sticker.selected::before,
.sticker.selected::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    background: var(--accent-primary);
}

.sticker.selected::before {
    top: -4px;
    left: -4px;
}

.sticker.selected::after {
    bottom: -4px;
    right: -4px;
}

/* 印章叠加层 */
.stamp-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.stamp-image {
    position: absolute;
    opacity: 0.7;
    mix-blend-mode: multiply;
}

/* 信息区 */
.info-section {
    margin-top: 16px;
    font-family: var(--font-pixel);
    color: var(--paper-text);
}

.msg-line {
    font-size: 1.1rem;
    margin-bottom: 8px;
    line-height: 1.4;
    min-height: 2.8em;
    word-break: break-all;
}

.msg-line .label {
    color: #7a8892;
}

.msg-line .value {
    color: var(--paper-text);
}

.meta-row {
    display: flex;
    gap: 16px;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.meta-item .label {
    color: #7a8892;
}

.meta-item .value {
    color: #4a5568;
    letter-spacing: 1px;
}

.barcode {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    letter-spacing: -2px;
    color: #4a5568;
    margin-top: 12px;
    text-align: center;
    opacity: 0.5;
}

/* 撕纸锯齿边 */
.paper-tear {
    position: absolute;
    bottom: -8px;
    left: 0;
    right: 0;
    height: 8px;
    background: var(--paper-bg);
    mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 10' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0,0 L5,10 L10,0 L15,10 L20,0 L25,10 L30,0 L35,10 L40,0 L45,10 L50,0 L55,10 L60,0 L65,10 L70,0 L75,10 L80,0 L85,10 L90,0 L95,10 L100,0 L100,10 L0,10 Z' fill='white'/%3E%3C/svg%3E");
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 10' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0,0 L5,10 L10,0 L15,10 L20,0 L25,10 L30,0 L35,10 L40,0 L45,10 L50,0 L55,10 L60,0 L65,10 L70,0 L75,10 L80,0 L85,10 L90,0 L95,10 L100,0 L100,10 L0,10 Z' fill='white'/%3E%3C/svg%3E");
    mask-size: 20px 8px;
    -webkit-mask-size: 20px 8px;
}

/* ============================================
   右侧工具面板
   ============================================ */
.tools-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 360px;
}

.panel-section {
    background: var(--bg-card);
    border: 1px solid rgba(91, 206, 250, 0.12);
    border-radius: var(--border-radius);
    padding: 16px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.section-icon {
    color: var(--accent-primary);
    font-size: 0.8rem;
}

.section-title {
    font-family: var(--font-pixel);
    font-size: 0.9rem;
    letter-spacing: 2px;
    color: var(--text-secondary);
}

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    font-family: var(--font-pixel);
    font-size: 0.95rem;
    letter-spacing: 1px;
    border: 1px solid;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-fast);
    background: transparent;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-glow);
    box-shadow: 0 0 16px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-secondary {
    color: var(--text-secondary);
    border-color: var(--text-muted);
}

.btn-secondary:hover:not(:disabled) {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.btn-accent {
    color: var(--accent-red);
    border-color: var(--accent-red);
}

.btn-accent:hover:not(:disabled) {
    background: var(--accent-red-glow);
    box-shadow: 0 0 16px var(--accent-red-glow);
    transform: translateY(-1px);
}

.btn-danger {
    color: #ff4444;
    border-color: #ff4444;
}

.btn-danger:hover:not(:disabled) {
    background: rgba(255, 68, 68, 0.2);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-full {
    width: 100%;
    margin-bottom: 8px;
}

.btn-icon {
    font-size: 1rem;
}

.input-buttons,
.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.history-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-buttons .undo-redo-row {
    display: flex;
    gap: 8px;
}

.history-buttons .undo-redo-row .btn {
    flex: 1;
}

.history-buttons .btn-danger {
    width: 100%;
    margin-top: 4px;
    border-style: dashed;
    opacity: 0.8;
}

.history-buttons .btn-danger:hover {
    opacity: 1;
}

.control-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* 贴纸网格 */
.sticker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.sticker-item {
    aspect-ratio: 1;
    background: var(--bg-hover);
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    transition: all var(--transition-fast);
}

.sticker-item:hover {
    border-color: var(--accent-primary);
    background: rgba(91, 206, 250, 0.1);
    transform: scale(1.05);
}

.sticker-item svg {
    width: 100%;
    height: 100%;
}

/* 消息输入 */
.message-input-wrap {
    position: relative;
}

.message-input {
    width: 100%;
    padding: 12px 50px 12px 14px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    background: var(--bg-primary);
    border: 1px solid rgba(91, 206, 250, 0.15);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition-fast);
}

.message-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(91, 206, 250, 0.1);
}

.message-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.message-input::placeholder {
    color: var(--text-muted);
}

.char-count {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-pixel);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================
   底部栏
   ============================================ */
.bottom-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 28px;
    background: rgba(15, 20, 25, 0.95);
    border-top: 1px solid rgba(91, 206, 250, 0.1);
}

.shortcuts {
    display: flex;
    gap: 20px;
}

.shortcut {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.shortcut kbd {
    display: inline-block;
    padding: 3px 8px;
    font-family: var(--font-pixel);
    font-size: 0.7rem;
    background: var(--bg-hover);
    border: 1px solid rgba(91, 206, 250, 0.2);
    border-radius: var(--border-radius);
    margin-right: 4px;
    color: var(--text-secondary);
}

.credits {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.credits .author {
    color: var(--text-secondary);
    font-style: italic;
}

.credits .divider {
    color: var(--accent-red);
    font-size: 0.6rem;
}

.credits .year {
    font-family: var(--font-pixel);
    color: var(--text-muted);
    letter-spacing: 2px;
}

/* ============================================
   摄像头模态框
   ============================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--accent-primary);
    border-radius: var(--border-radius);
    padding: 20px;
    max-width: 500px;
    width: 90%;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-title {
    font-family: var(--font-pixel);
    font-size: 1.1rem;
    color: var(--accent-primary);
    letter-spacing: 1px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
}

.modal-close:hover {
    color: var(--accent-red);
}

.camera-preview {
    background: #000;
    border-radius: var(--border-radius);
    overflow: hidden;
    margin-bottom: 16px;
}

.camera-preview video {
    width: 100%;
    display: block;
}

.modal-actions {
    display: flex;
    justify-content: center;
}

/* ============================================
   Toast 提示
   ============================================ */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-card);
    border: 1px solid var(--accent-primary);
    padding: 14px 28px;
    font-family: var(--font-pixel);
    font-size: 1rem;
    color: var(--accent-primary);
    letter-spacing: 1px;
    border-radius: var(--border-radius);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    z-index: 2000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ============================================
   移动端抽屉
   ============================================ */
.mobile-drawer {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid rgba(91, 206, 250, 0.15);
    z-index: 200;
}

.drawer-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.drawer-tab {
    flex: 1;
    padding: 12px 8px;
    font-family: var(--font-pixel);
    font-size: 0.75rem;
    letter-spacing: 1px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.drawer-tab.active {
    color: var(--accent-primary);
    background: rgba(91, 206, 250, 0.1);
}

.drawer-content {
    padding: 16px;
    max-height: 200px;
    overflow-y: auto;
}

.drawer-panel {
    display: none;
}

.drawer-panel.active {
    display: block;
}

.mobile-sticker-grid {
    grid-template-columns: repeat(6, 1fr);
}

/* ============================================
   响应式设计
   ============================================ */
@media (max-width: 900px) {
    .main-container {
        flex-direction: column;
        align-items: center;
        padding: 16px;
        padding-bottom: 280px;
    }

    .tools-panel {
        display: none;
    }

    .mobile-drawer {
        display: block;
    }

    .bottom-bar {
        display: none;
    }

    .top-bar {
        padding: 8px 16px;
    }

    .logo-text {
        font-size: 1rem;
    }

    .version {
        display: none;
    }
}

@media (max-width: 400px) {
    :root {
        --card-width: 300px;
        --card-photo-height: 300px;
    }

    .paper {
        padding: 12px;
    }

    .mobile-sticker-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ============================================
   动画效果
   ============================================ */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes stampBounce {
    0% { transform: scale(0) rotate(-15deg); }
    60% { transform: scale(1.2) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.stamp-image.animate {
    animation: stampBounce 0.4s ease-out;
}

/* 打印动画 */
@keyframes printingPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.photo-frame.printing {
    animation: printingPulse 0.5s ease-in-out infinite;
}

/* 选中状态闪烁 */
@keyframes selectPulse {
    0%, 100% { 
        outline-color: var(--accent-primary);
        outline-offset: 2px;
    }
    50% { 
        outline-color: transparent;
        outline-offset: 4px;
    }
}

/* 打印显影扫描线 */
.photo-frame.printing::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(
        to bottom,
        transparent,
        rgba(0, 217, 255, 0.5),
        transparent
    );
    animation: scanDown 0.8s linear infinite;
}

@keyframes scanDown {
    0% { top: 0; }
    100% { top: 100%; }
}

/* ============================================
   打印动画状态
   ============================================ */
.status-text.printing {
    animation: blink 0.3s infinite;
}

.status-text.stamped {
    color: var(--accent-red) !important;
}

