/* Barcode Pro - 样式文件 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 专业工具风格 - 蓝灰色系 */
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --sidebar-width: 320px;
    --sidebar-bg: #f8fafc;
}

html {
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    touch-action: manipulation;
}

input,
textarea,
select,
button {
    -webkit-tap-highlight-color: transparent;
}

.app-container {
    display: flex;
    height: 100vh;
    position: relative;
}

/* 侧边栏 - 使用 GPU 加速 */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
    transform: translateX(0);
    will-change: transform;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
    transform: translateX(-100%);
    margin-left: calc(-1 * var(--sidebar-width));
}

/* 侧边栏内容 */
.sidebar-header {
    padding: 20px;
    background: var(--card-bg);
    color: var(--text);
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--primary);
}

.sidebar-header p {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

.sidebar-content {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* 切换按钮 - 固定定位优化 */
.sidebar-toggle {
    position: fixed;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--card-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    z-index: 101;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: var(--shadow);
    transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1), all 0.2s;
    will-change: left;
}

.sidebar-toggle:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.sidebar:not(.collapsed) ~ .sidebar-toggle {
    left: calc(var(--sidebar-width) + 10px);
}

/* 悬停触发区域 */
.sidebar-trigger {
    position: fixed;
    left: 0;
    top: 0;
    width: 8px;
    height: 100vh;
    z-index: 99;
}

/* 主内容区 - GPU 加速 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.control-section {
    margin-bottom: 24px;
}

.control-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    resize: vertical;
    min-height: 120px;
    font-family: 'Monaco', 'Menlo', monospace;
    transition: all 0.2s;
    background: var(--card-bg);
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* 按钮样式 - 专业工具风 */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-1px);
}

.btn-success:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.btn-warning {
    background: var(--warning);
    color: #fff;
}

.btn-warning:hover {
    background: #d97706;
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-block {
    width: 100%;
}

/* 工具栏 */
.toolbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.toolbar-info {
    font-size: 14px;
    color: var(--text-secondary);
}

.toolbar-info strong {
    color: var(--primary);
    font-size: 18px;
    font-weight: 600;
}

.toolbar-actions {
    display: flex;
    gap: 8px;
}

.toolbar .btn {
    padding: 8px 16px;
    font-size: 13px;
}

/* 条形码展示区 */
.barcode-display {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg);
}

.barcode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.barcode-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 16px;
    box-shadow: var(--shadow);
    transition: all 0.15s ease;
    position: relative;
    border: 1px solid var(--border);
    cursor: pointer;
}

.barcode-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.barcode-card.selected {
    border-color: var(--primary);
    background: #eff6ff;
}

.barcode-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.barcode-index {
    background: var(--primary);
    color: #fff;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.barcode-actions {
    display: flex;
    gap: 4px;
}

.barcode-actions button {
    padding: 4px 8px;
    font-size: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: var(--bg);
    color: var(--text-secondary);
    transition: all 0.15s;
}

.barcode-actions button:hover {
    background: var(--primary);
    color: white;
}

.barcode-svg-container {
    background: #fafafa;
    border-radius: 6px;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    border: 1px solid var(--border);
}

.barcode-svg-container svg,
.barcode-svg-container canvas {
    max-width: 100%;
    height: auto;
}

.barcode-value {
    margin-top: 12px;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 13px;
    text-align: center;
    word-break: break-all;
    color: var(--text);
}

/* 空状态 */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    text-align: center;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h2 {
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--text);
}

.empty-state p {
    font-size: 14px;
    max-width: 400px;
    line-height: 1.6;
}

/* 快捷键提示 */
.shortcuts-hint {
    padding: 10px 24px;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.shortcut {
    display: flex;
    align-items: center;
    gap: 6px;
}

.shortcut kbd {
    background: var(--card-bg);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
    font-family: monospace;
    font-size: 10px;
}

/* Toast 提示 - 中间上方显示 */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 24px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideDown 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
    white-space: nowrap;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info { background: var(--primary); }

/* 错误提示 */
.error-message {
    color: var(--danger);
    text-align: center;
    padding: 20px;
}

.error-message .error-icon {
    font-size: 24px;
    margin-bottom: 8px;
}

.error-message .error-text {
    font-size: 12px;
}

/* 打印样式 */
@media print {
    @page {
        size: A4;
        margin: 10mm;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    html, body {
        margin: 0 !important;
        padding: 0 !important;
    }

    .sidebar, .sidebar-toggle, .sidebar-trigger, .toolbar, .shortcuts-hint, .toast-container {
        display: none !important;
    }

    .app-container {
        margin: 0 !important;
        padding: 0 !important;
    }

    .main-content {
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .barcode-display {
        overflow: visible !important;
        padding: 0 !important;
        height: auto !important;
        margin: 0 !important;
    }

    /* 打印布局 */
    .barcode-grid {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 4mm 3mm !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .barcode-card {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
        box-shadow: none !important;
        border: 1px solid #bbb !important;
        border-radius: 4px !important;
        padding: 6px !important;
        height: auto !important;
    }

    .barcode-card-header {
        display: flex !important;
        margin-bottom: 4px !important;
    }

    .barcode-index {
        background: #333 !important;
        color: white !important;
        width: 18px !important;
        height: 18px !important;
        font-size: 9px !important;
    }

    .barcode-actions {
        display: none !important;
    }

    .barcode-svg-container {
        min-height: 45px !important;
        padding: 4px !important;
    }

.barcode-value {
    font-size: 8px !important;
    padding: 2px 4px !important;
    margin-top: 4px !important;
}
}

/* 播放弹窗 */
.play-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.play-modal {
    background: var(--card-bg);
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.play-modal-header {
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.play-modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.play-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.play-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.play-modal-body {
    padding: 30px;
}

/* 播放显示区域 */
.play-display {
    background: var(--bg);
    border-radius: 12px;
    padding: 40px;
    margin-bottom: 24px;
    text-align: center;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.play-index {
    background: var(--primary);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.play-barcode-container {
    background: white;
    border-radius: 8px;
    padding: 30px;
    margin-bottom: 20px;
    border: 2px solid var(--border);
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.play-barcode-container svg,
.play-barcode-container canvas {
    max-width: 100%;
    height: auto;
}

.play-value {
    font-size: 24px;
    font-weight: 600;
    color: var(--text);
    font-family: 'Monaco', 'Menlo', monospace;
    word-break: break-all;
}

.play-count {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 12px;
}

/* 播放控制区 */
.play-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 24px;
}

.play-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.play-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.play-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.play-nav-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: white;
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.play-nav-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.play-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* 速度控制 */
.play-speed-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg);
    border-radius: 8px;
}

.play-speed-control label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.play-speed-control input[type="range"] {
    width: 200px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 3px;
    outline: none;
}

.play-speed-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

.play-speed-control input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

.play-speed-value {
    font-size: 14px;
    color: var(--primary);
    font-weight: 600;
    min-width: 60px;
    text-align: center;
}

/* 响应式 */
@media (max-width: 768px) {
    input,
    textarea,
    select {
        font-size: 16px !important;
    }

    button,
    .btn,
    .barcode-card,
    .sidebar-toggle {
        touch-action: manipulation;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 100;
    }
    
    .sidebar.collapsed {
        transform: translateX(-100%);
        margin-left: 0;
    }
    
    .sidebar-toggle {
        left: 10px !important;
        top: 10px;
        transform: none;
    }
    
    .sidebar:not(.collapsed) ~ .sidebar-toggle {
        left: calc(var(--sidebar-width) - 50px) !important;
        top: 10px;
    }
    
    .barcode-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .toolbar {
        flex-direction: column;
        gap: 10px;
        padding-top: 50px;
    }
    
    .toolbar-actions {
        width: 100%;
        justify-content: center;
    }
    
    .shortcuts-hint {
        display: none;
    }
}

@media (max-width: 480px) {
    .barcode-grid {
        grid-template-columns: 1fr;
    }
}

/* 留言弹窗样式 */
.message-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.message-modal {
    background: var(--card-bg);
    border-radius: 16px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

.message-modal-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.message-modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.message-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
    line-height: 1;
}

.message-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.message-modal-body {
    padding: 24px;
}

.message-form-group {
    margin-bottom: 20px;
}

.message-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 8px;
}

.message-form-group label .required {
    color: var(--danger);
}

.message-form-group label .optional {
    font-weight: normal;
    color: var(--text-secondary);
    font-size: 12px;
}

.message-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    resize: none;
    min-height: 100px;
    font-family: inherit;
    transition: border-color 0.2s;
    background: var(--card-bg);
}

.message-textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.message-char-count {
    text-align: right;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.contact-type-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.contact-type-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.contact-type-btn:hover {
    border-color: #667eea;
    background: #f5f5f5;
}

.contact-type-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.message-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
    background: var(--card-bg);
}

.message-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.message-input:disabled {
    background: var(--bg);
    cursor: not-allowed;
}

.captcha-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.captcha-input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.captcha-input:focus {
    outline: none;
    border-color: #667eea;
}

.captcha-image {
    cursor: pointer;
    border-radius: 6px;
    transition: transform 0.2s;
    border: 1px solid var(--border);
}

.captcha-image:hover {
    transform: scale(1.05);
}

.message-submit-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.message-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.message-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.message-result {
    padding: 12px;
    border-radius: 8px;
    margin-top: 16px;
    text-align: center;
    font-size: 14px;
    display: none;
}

.message-result.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.message-result.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}
