/* ============================================================
   Design System — 蓝白专业风格（本地化资源）
   ============================================================ */

:root {
    /* Backgrounds */
    --bg-app:      #f0f4fa;
    --bg-sidebar:  #ffffff;
    --bg-card:     #ffffff;
    --bg-card-alt: #f6f8fc;
    --bg-hover:    #eef2fa;

    /* Borders */
    --border-color:  #dde4f0;
    --border-subtle: #eaeef6;
    --border-hover:  #4f8ef7;
    --border-active: #2563eb;

    /* Text */
    --text-primary:   #1a2340;
    --text-secondary: #3a4a6b;
    --text-muted:     #7a8baa;
    --text-dim:       #b5bece;

    /* Brand / Primary — Blue */
    --primary:         #2563eb;
    --primary-light:   #4f8ef7;
    --primary-lighter: #93c5fd;
    --primary-hover:   #1d4ed8;
    --primary-glow:    rgba(37, 99, 235, 0.18);
    --primary-subtle:  rgba(37, 99, 235, 0.07);

    /* Accent */
    --accent:        #6366f1;
    --accent-subtle: rgba(99, 102, 241, 0.08);

    /* Secondary — Cyan/Teal */
    --secondary:        #0ea5e9;
    --secondary-hover:  #0284c7;
    --secondary-subtle: rgba(14, 165, 233, 0.08);

    /* Success */
    --success:        #10b981;
    --success-subtle: rgba(16, 185, 129, 0.1);

    /* Danger */
    --danger:        #ef4444;
    --danger-hover:  #dc2626;
    --danger-subtle: rgba(239, 68, 68, 0.08);

    /* Shadows */
    --shadow-xs: 0 1px 3px rgba(30,60,120,0.07);
    --shadow-sm: 0 2px 8px rgba(30,60,120,0.08);
    --shadow-md: 0 4px 18px rgba(30,60,120,0.10);
    --shadow-lg: 0 10px 36px rgba(30,60,120,0.13);
    --shadow-glow: 0 0 0 3px rgba(37, 99, 235, 0.15);

    /* Radius */
    --radius-sm:   6px;
    --radius-md:   10px;
    --radius-lg:   14px;
    --radius-xl:   20px;
    --radius-full: 9999px;

    /* Font */
    --font:      'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Sidebar width */
    --sidebar-w: 368px;

    /* Transitions */
    --ease:        cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ============================================================
   Base
   ============================================================ */
html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--primary-lighter); }

/* ============================================================
   App Layout
   ============================================================ */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 20;
    box-shadow: 2px 0 16px rgba(30,60,120,0.07);
}

/* ── Brand ── */
.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 22px 22px 18px;
    border-bottom: 1px solid var(--border-subtle);
    background: linear-gradient(135deg, #f0f6ff 0%, #ffffff 100%);
}

.brand-icon-wrap {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.28);
    flex-shrink: 0;
}

.brand-icon {
    color: #ffffff !important;
    background: none !important;
    -webkit-background-clip: unset !important;
    -webkit-text-fill-color: #ffffff !important;
    background-clip: unset !important;
}

.brand-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand h2 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.2px;
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 11.5px;
    color: var(--primary);
    font-weight: 600;
    letter-spacing: 0.2px;
}

/* ── Sidebar body ── */
.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 18px 0;
}

/* ── Section titles ── */
.sidebar-section {
    margin-bottom: 20px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.step-badge {
    width: 22px;
    height: 22px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}

.section-title h3 {
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

/* ── File Upload Box ── */
.file-upload-box {
    background: var(--bg-card-alt);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 22px 18px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s var(--ease);
}

.file-upload-box:hover {
    border-color: var(--primary-light);
    background: #eef4ff;
    box-shadow: var(--shadow-sm);
}

.file-upload-box.dragover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.06);
    box-shadow: var(--shadow-glow);
    transform: scale(1.01);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.upload-placeholder i {
    font-size: 30px;
    color: var(--border-color);
    transition: all 0.25s var(--ease-spring);
}

.file-upload-box:hover .upload-placeholder i {
    color: var(--primary);
    transform: translateY(-3px);
}

.upload-placeholder p {
    font-size: 13px;
    color: var(--text-muted);
}

/* ── File info ── */
.file-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.file-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-all;
}

.file-details {
    font-size: 11.5px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ── Image Upload Cards ── */
.image-upload-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    overflow: hidden;
    transition: all 0.25s var(--ease);
    box-shadow: var(--shadow-xs);
}

.image-upload-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.image-upload-card.loaded {
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 0 3px rgba(16,185,129,0.08), var(--shadow-xs);
}

.image-upload-card.placed {
    border-color: rgba(37, 99, 235, 0.45);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1), var(--shadow-xs);
}

/* ── Card header ── */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: linear-gradient(90deg, #f6f8fc 0%, #ffffff 100%);
    border-bottom: 1px solid var(--border-subtle);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ── Status Badges ── */
.status-badge {
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    transition: all 0.25s var(--ease);
}

.status-badge.inactive {
    background: var(--bg-app);
    color: var(--text-dim);
    border: 1px solid var(--border-subtle);
}

.status-badge.ready {
    background: var(--success-subtle);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.status-badge.placed {
    background: var(--primary-subtle);
    color: var(--primary);
    border: 1px solid rgba(37, 99, 235, 0.25);
    animation: pulse-blue 2.5s ease-in-out infinite;
}

@keyframes pulse-blue {
    0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.2); }
    50%       { box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08); }
}

/* ── Card Body ── */
.card-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 76px;
}

.card-body img {
    max-width: 100%;
    max-height: 110px;
    border-radius: var(--radius-md);
    object-fit: contain;
    box-shadow: var(--shadow-sm);
    transition: transform 0.25s var(--ease);
}

.card-body img:hover {
    transform: scale(1.03);
}

/* ── Upload Button ── */
.upload-btn {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px dashed var(--border-color);
    border-radius: var(--radius-md);
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s var(--ease);
    background: var(--bg-app);
}

.upload-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-subtle);
}

/* ── Card Actions ── */
.card-actions {
    padding: 10px 14px;
    background: #fafbfe;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

/* ── Sidebar Footer ── */
.sidebar-footer {
    padding: 16px 18px 20px;
    border-top: 1px solid var(--border-color);
    background: linear-gradient(180deg, #ffffff 0%, #f5f8ff 100%);
    display: flex;
    flex-direction: column;
    gap: 11px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    font-family: var(--font);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    padding: 11px 22px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.2s var(--ease);
    letter-spacing: 0.1px;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(37, 99, 235, 0.42);
    filter: brightness(1.06);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: var(--border-color);
    color: var(--text-dim);
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    background: var(--primary-subtle);
    color: var(--primary);
    border: 1px solid rgba(37, 99, 235, 0.22);
}

.btn-secondary:hover {
    background: rgba(37, 99, 235, 0.12);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.btn-block {
    width: 100%;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 12px;
    cursor: pointer;
    transition: color 0.2s;
    padding: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-text:hover {
    color: var(--danger);
}

#btn-remove-pdf {
    margin-top: 8px;
}

/* ── Export Progress ── */
.export-progress-container {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.progress-bar {
    background: var(--border-subtle);
    border-radius: var(--radius-full);
    height: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    background-size: 200% 100%;
    border-radius: var(--radius-full);
    transition: width 0.35s var(--ease);
    animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
    0%   { background-position: 0% 0%; }
    100% { background-position: 200% 0%; }
}

.progress-text {
    font-size: 11.5px;
    color: var(--text-muted);
    text-align: center;
}

/* ── Developer Credit ── */
.developer-credit {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 0.3px;
}

.developer-credit .dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--primary-lighter);
}

/* ============================================================
   Editor Workspace
   ============================================================ */
.editor-workspace {
    flex: 1;
    overflow-y: auto;
    position: relative;
    padding: 36px 32px;
    display: flex;
    justify-content: center;
    align-items: flex-start;

    /* Subtle dot grid */
    background-color: var(--bg-app);
    background-image: radial-gradient(circle, rgba(37,99,235,0.1) 1px, transparent 1px);
    background-size: 28px 28px;
}

/* ── Empty State ── */
.empty-state {
    align-self: center;
    max-width: 480px;
    width: 100%;
    text-align: center;
}

.empty-state-content {
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 48px 36px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.empty-state-content::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
}

.icon-glow {
    font-size: 58px;
    color: var(--primary);
    margin-bottom: 20px;
    filter: drop-shadow(0 6px 18px rgba(37, 99, 235, 0.25));
    animation: float-icon 4s ease-in-out infinite;
    display: inline-block;
    /* Override gradient text — use solid blue for light theme */
    background: none;
    -webkit-text-fill-color: var(--primary);
    -webkit-background-clip: unset;
    background-clip: unset;
}

@keyframes float-icon {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-8px); }
}

.empty-state h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.empty-state p {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.75;
}

/* ── Workflow Steps ── */
.workflow-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 24px;
    text-align: left;
}

.workflow-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    background: var(--primary-subtle);
    border: 1px solid rgba(37, 99, 235, 0.1);
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--text-secondary);
    transition: background 0.2s;
}

.workflow-step:hover {
    background: rgba(37, 99, 235, 0.1);
}

.workflow-step-num {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: white;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(37,99,235,0.22);
}

/* ============================================================
   PDF Viewer
   ============================================================ */
.pdf-viewer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 36px;
    max-width: 100%;
    width: 100%;
    padding-bottom: 40px;
}

/* ── PDF Page Container ── */
.pdf-page-container {
    position: relative;
    background: #ffffff;
    border-radius: 5px;
    box-shadow:
        0 0 0 1px rgba(37, 99, 235, 0.08),
        var(--shadow-lg);
    overflow: visible;
    transition: box-shadow 0.25s var(--ease);
}

.pdf-page-container:hover {
    box-shadow:
        0 0 0 2px rgba(37, 99, 235, 0.15),
        0 16px 48px rgba(30, 60, 120, 0.18);
}

.pdf-page-container canvas {
    display: block;
    max-width: 100%;
    height: auto !important;
    border-radius: 4px;
}

/* ── Image Draggable Overlay ── */
.image-overlay {
    position: absolute;
    border: 2px dashed rgba(37, 99, 235, 0.65);
    cursor: move;
    user-select: none;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.14);
    background: rgba(37, 99, 235, 0.04);
    border-radius: 2px;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.image-overlay:hover,
.image-overlay.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12), 0 6px 24px rgba(37, 99, 235, 0.2);
    background: rgba(37, 99, 235, 0.06);
}

.image-overlay img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    display: block;
    pointer-events: none;
}

/* ── Overlay Label ── */
.overlay-label {
    position: absolute;
    top: -25px;
    left: -2px;
    background: var(--primary);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 4px 4px 0 0;
    pointer-events: none;
    white-space: nowrap;
    letter-spacing: 0.4px;
    box-shadow: 0 -2px 6px rgba(37, 99, 235, 0.2);
}

.image-overlay:hover .overlay-label,
.image-overlay.active .overlay-label {
    background: var(--primary-hover);
}

/* ── Overlay Delete Button ── */
.overlay-delete-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 22px;
    height: 22px;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35);
    border: 1.5px solid white;
    transition: transform 0.2s var(--ease-spring), background-color 0.2s;
    z-index: 5;
}

.overlay-delete-btn:hover {
    background: var(--danger-hover);
    transform: scale(1.2);
}

/* ── Overlay Resize Handle ── */
.overlay-resize-handle {
    position: absolute;
    bottom: -7px;
    right: -7px;
    width: 15px;
    height: 15px;
    background: white;
    border: 2.5px solid var(--primary);
    border-radius: 50%;
    cursor: se-resize;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
    z-index: 5;
    transition: transform 0.2s var(--ease-spring), border-color 0.2s;
}

.overlay-resize-handle:hover {
    transform: scale(1.3);
    border-color: var(--primary-hover);
}

/* ── Page Indicator ── */
.page-indicator {
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(6px);
    color: var(--text-muted);
    padding: 4px 14px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 500;
    border: 1px solid var(--border-color);
    pointer-events: none;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

/* ── Page Selector ── */
.page-select-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: var(--text-muted);
}

.page-select {
    background: var(--primary-subtle);
    border: 1px solid rgba(37, 99, 235, 0.2);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 11.5px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.page-select:hover,
.page-select:focus {
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.page-select option {
    background: white;
    color: var(--text-primary);
}
