/* ============================================
   座位牌批量生成器 - 样式表
   ============================================ */

/* ---------- 基础重置 ---------- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --sidebar-width: 340px;
    --color-primary: #4f46e5;
    --color-primary-light: #6366f1;
    --color-primary-dark: #4338ca;
    --color-primary-bg: #eef2ff;
    --color-text: #1f2937;
    --color-text-secondary: #6b7280;
    --color-text-tertiary: #9ca3af;
    --color-border: #e5e7eb;
    --color-border-strong: #d1d5db;
    --color-bg: #f9fafb;
    --color-surface: #ffffff;
    --color-danger: #ef4444;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px 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);
    --transition: 0.2s ease;
}

html, body {
    height: 100%;
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--color-text);
    background: var(--color-bg);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---------- 主布局 ---------- */
.app {
    display: flex;
    height: 100vh;
}

/* ============================================
   侧边栏
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid var(--color-border);
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
    color: #fff;
}

.sidebar-header h1 {
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    font-size: 22px;
}

.sidebar-header .subtitle {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 4px;
    font-weight: 400;
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-body::-webkit-scrollbar {
    width: 6px;
}
.sidebar-body::-webkit-scrollbar-thumb {
    background: var(--color-border-strong);
    border-radius: 3px;
}
.sidebar-body::-webkit-scrollbar-track {
    background: transparent;
}

/* ---------- Tab 导航 ---------- */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
    position: sticky;
    top: 0;
    z-index: 10;
}

.tab {
    flex: 1;
    padding: 12px 4px;
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    border-bottom: 2px solid transparent;
    font-family: inherit;
}

.tab:hover {
    color: var(--color-primary);
    background: var(--color-primary-bg);
}

.tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    font-weight: 600;
}

/* ---------- Tab 面板 ---------- */
.tab-panel {
    display: none;
    padding: 20px;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- 面板分区 ---------- */
.panel-section {
    margin-bottom: 20px;
}

.field-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.field-label .hint {
    font-size: 11px;
    font-weight: 400;
    color: var(--color-text-tertiary);
}

.value-display {
    font-size: 12px;
    color: var(--color-primary);
    font-weight: 600;
    background: var(--color-primary-bg);
    padding: 1px 8px;
    border-radius: 10px;
}

/* ---------- 文本输入 ---------- */
.name-textarea {
    width: 100%;
    min-height: 160px;
    padding: 12px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color var(--transition), box-shadow var(--transition);
    line-height: 1.6;
}

.name-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.text-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.text-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.select-field {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--color-surface);
    cursor: pointer;
    transition: border-color var(--transition);
}

.select-field:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

/* ---------- 统计信息 ---------- */
.name-stats {
    margin-top: 8px;
    font-size: 12px;
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.name-stats .separator {
    color: var(--color-border-strong);
}

/* ---------- 按钮 ---------- */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border-strong);
}

.btn-secondary:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
}

.btn-ghost:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.btn-block {
    width: 100%;
}

.import-buttons {
    display: flex;
    gap: 8px;
}

.import-buttons .btn {
    flex: 1;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.action-buttons .btn {
    flex: 1;
}

/* ---------- 模板选择网格 ---------- */
.template-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.template-card {
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 8px;
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
    background: var(--color-surface);
}

.template-card:hover {
    border-color: var(--color-primary-light);
}

.template-card.active {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.template-preview {
    height: 70px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
    overflow: hidden;
}

.template-name {
    font-size: 12px;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.template-card.active .template-name {
    color: var(--color-primary);
    font-weight: 600;
}

/* 模板预览样式 */
.tp-classic {
    background: #fff;
    border: 2px solid #333;
    color: #333;
    font-family: 'Noto Serif SC', serif;
}
.tp-modern {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
}
.tp-business {
    background: #fff;
    border-top: 6px solid #1a365d;
    color: #1a365d;
    font-weight: 700;
}
.tp-festive {
    background: #C41E3A;
    color: #FFD700;
    border: 2px solid #FFD700;
    font-family: 'Noto Serif SC', serif;
}
.tp-minimal {
    background: #fff;
    color: #333;
    border-bottom: 2px solid #333;
}
.tp-gradient {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: #fff;
}

/* ---------- 单选卡片 ---------- */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-card {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.radio-card:hover {
    border-color: var(--color-primary-light);
}

.radio-card input:checked + .radio-label {
    color: var(--color-primary);
    font-weight: 600;
}

.radio-card:has(input:checked) {
    border-color: var(--color-primary);
    background: var(--color-primary-bg);
}

.radio-label {
    font-size: 14px;
    margin-left: 8px;
}

/* ---------- 滑块 ---------- */
.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--color-border);
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition);
}

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

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: var(--shadow-sm);
}

.slider-group {
    margin-top: 10px;
}

.slider-group label {
    font-size: 12px;
    color: var(--color-text-secondary);
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

/* ---------- 复选框行 ---------- */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    cursor: pointer;
    user-select: none;
}

.checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.checkbox-label {
    font-size: 13px;
    color: var(--color-text-secondary);
}

/* ---------- 颜色选择器 ---------- */
.color-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-picker {
    width: 40px;
    height: 36px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
    padding: 2px;
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}
.color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.color-value {
    font-size: 13px;
    color: var(--color-text-secondary);
    font-family: 'SF Mono', 'Consolas', monospace;
}

/* ---------- 渐变预设 ---------- */
.gradient-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.gradient-preset {
    width: 100%;
    height: 36px;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.gradient-preset:hover {
    transform: scale(1.1);
}

.gradient-preset.selected {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--color-primary);
}

/* ---------- Logo 上传 ---------- */
.logo-upload {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.logo-preview {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

/* ---------- 自定义尺寸输入 ---------- */
.custom-size-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.custom-size-field {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
}

.custom-size-label {
    font-size: 13px;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.custom-size-x {
    font-size: 16px;
    color: var(--color-text-tertiary);
}

.number-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: 'SF Mono', 'Consolas', monospace;
    text-align: center;
    transition: border-color var(--transition), box-shadow var(--transition);
    -moz-appearance: textfield;
}

.number-input::-webkit-outer-spin-button,
.number-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.number-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.custom-presets {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.preset-btn {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    font-size: 11px;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.preset-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-bg);
}

/* ---------- 导出卡片 ---------- */
.export-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
}

.export-icon {
    font-size: 32px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
}

.export-icon svg {
    display: block;
}

.export-info h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.export-info p {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-bottom: 12px;
}

/* ---------- 信息框 ---------- */
.info-box {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius-md);
    padding: 14px;
}

.info-box h4 {
    font-size: 13px;
    color: #92400e;
    margin-bottom: 8px;
}

.info-box ul {
    list-style: none;
    padding: 0;
}

.info-box li {
    font-size: 12px;
    color: #78350f;
    padding: 3px 0;
    padding-left: 16px;
    position: relative;
}

.info-box li::before {
    content: "•";
    position: absolute;
    left: 4px;
    color: #f59e0b;
}

/* ============================================
   主预览区
   ============================================ */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    overflow: hidden;
}

.preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.preview-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

.preview-info {
    font-size: 13px;
    color: var(--color-text-secondary);
    background: var(--color-bg);
    padding: 3px 10px;
    border-radius: 12px;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.icon-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-bg);
}

.zoom-value {
    font-size: 13px;
    color: var(--color-text-secondary);
    min-width: 50px;
    text-align: center;
}

/* ---------- 预览滚动区 ---------- */
.preview-scroll {
    flex: 1;
    overflow: auto;
    padding: 24px;
    display: flex;
    justify-content: center;
}

.preview-scroll::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.preview-scroll::-webkit-scrollbar-thumb {
    background: var(--color-border-strong);
    border-radius: 4px;
}

.preview-container {
    transform-origin: top center;
    transition: transform 0.15s ease;
}

/* ---------- 空状态 ---------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 40px;
    text-align: center;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h2 {
    font-size: 20px;
    color: var(--color-text);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin-bottom: 20px;
}

/* ============================================
   卡片预览样式
   ============================================ */

/* 打印页面容器 */
.print-page {
    background: #fff;
    box-shadow: var(--shadow-lg);
    margin: 0 auto 20px;
    display: flex;
    flex-wrap: wrap;
    position: relative;
    overflow: hidden;
}

/* 单个卡片 */
.seat-card {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    break-inside: avoid;
}

/* 桌牌模式：上下对折 */
.tent-card {
    flex-direction: column;
    position: relative;
    break-inside: avoid;
    align-items: stretch;
    justify-content: flex-start;
}

.tent-half {
    flex: 1 1 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.tent-half.tent-top {
    transform: rotate(180deg);
}

.tent-fold-line {
    position: absolute;
    left: 5%;
    right: 5%;
    top: 50%;
    height: 0;
    border-top: 1px dashed #cbd5e1;
    z-index: 2;
    pointer-events: none;
}

@media print {
    .tent-fold-line {
        border-top: 1pt dashed #999;
    }
}

/* 卡片内容 */
.card-content {
    text-align: center;
    padding: 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 100%;
}

.card-logo {
    max-width: 60px;
    max-height: 40px;
    object-fit: contain;
    margin-bottom: 4px;
}

.card-name {
    line-height: 1.2;
    white-space: nowrap;
    text-align: center;
}

.card-subtitle {
    font-size: 18px;
    color: inherit;
    opacity: 0.7;
    font-weight: 400;
    line-height: 1.3;
}

.card-company {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 11px;
    opacity: 0.5;
    font-weight: 400;
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--color-text);
    color: #fff;
    padding: 10px 24px;
    border-radius: 24px;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 9999;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--color-success);
}

.toast.error {
    background: var(--color-danger);
}

/* ============================================
   打印样式
   ============================================ */
@media print {
    @page {
        margin: 0;
    }

    body {
        background: #fff;
        overflow: visible;
    }

    .app {
        display: block;
        height: auto;
    }

    .sidebar {
        display: none;
    }

    .main-area {
        display: block;
    }

    .preview-toolbar {
        display: none;
    }

    .preview-scroll {
        overflow: visible;
        padding: 0;
        display: block;
    }

    .preview-container {
        transform: none !important;
    }

    .empty-state {
        display: none;
    }

    .print-page {
        box-shadow: none;
        margin: 0;
        page-break-after: always;
        break-after: page;
    }

    .print-page:last-child {
        page-break-after: auto;
        break-after: auto;
    }
}
