/* ============================================
   图片转PDF工具 - 样式表
   系统字体栈 · 深色/浅色主题 · 响应式
   ============================================ */

/* --- CSS Variables (Light Theme) --- */
:root {
    --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;

    --bg-body: #f2f5f9;
    --bg-body-texture: radial-gradient(ellipse at 20% 0%, rgba(74,144,217,0.06) 0%, transparent 60%),
                       radial-gradient(ellipse at 80% 100%, rgba(74,144,217,0.04) 0%, transparent 50%);
    --bg-card: #ffffff;
    --bg-card-alt: #f7f9fc;
    --bg-input: #f0f4f8;

    --text-primary: #1a2332;
    --text-secondary: #5a6a7e;
    --text-muted: #8e9bae;

    --accent: #4A90D9;
    --accent-hover: #3a7bc8;
    --accent-light: rgba(74, 144, 217, 0.08);
    --accent-glow: rgba(74, 144, 217, 0.22);
    --accent-gradient: linear-gradient(135deg, #4A90D9 0%, #6BB0F0 100%);

    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --border-dashed: #b8c5d3;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.06), 0 2px 6px rgba(0,0,0,0.03);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
    --shadow-accent: 0 4px 16px rgba(74, 144, 217, 0.25);

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --danger: #e74c3c;
    --danger-hover: #c0392b;
    --success: #27ae60;

    --toast-bg: #1a2332;
    --toast-text: #ffffff;

    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Dark Theme --- */
[data-theme="dark"] {
    --bg-body: #0d1520;
    --bg-body-texture: radial-gradient(ellipse at 20% 0%, rgba(91,159,230,0.07) 0%, transparent 60%),
                       radial-gradient(ellipse at 80% 100%, rgba(91,159,230,0.04) 0%, transparent 50%);
    --bg-card: #162032;
    --bg-card-alt: #1a2736;
    --bg-input: #1a2736;

    --text-primary: #e8edf3;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent: #5b9fe6;
    --accent-hover: #74b0ed;
    --accent-light: rgba(91, 159, 230, 0.1);
    --accent-glow: rgba(91, 159, 230, 0.18);
    --accent-gradient: linear-gradient(135deg, #5b9fe6 0%, #7ec4ff 100%);

    --border: #243044;
    --border-hover: #33475e;
    --border-dashed: #33475e;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.25);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.4);
    --shadow-accent: 0 4px 16px rgba(91, 159, 230, 0.15);

    --toast-bg: #e8edf3;
    --toast-text: #1a2332;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-body);
    background-image: var(--bg-body-texture);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    transition: background var(--transition-slow), color var(--transition);
    animation: fadeInPage 0.5s ease-out;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background: var(--accent);
    color: #fff;
}

@keyframes fadeInPage {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- CDN Error Overlay --- */
.cdn-error {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: var(--bg-body);
    background-image: var(--bg-body-texture);
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.cdn-error.show {
    display: flex;
}

.cdn-error-inner {
    text-align: center;
    max-width: 400px;
    animation: fadeUp 0.5s ease-out;
}

.cdn-error-icon {
    color: var(--danger);
    margin-bottom: 1.25rem;
    display: flex;
    justify-content: center;
}

.cdn-error-inner h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.cdn-error-inner p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 1.5rem;
}

.cdn-error-inner button {
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.7rem 2rem;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-accent);
}

.cdn-error-inner button:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
}

/* --- Container --- */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
}

/* --- Theme Toggle --- */
.theme-toggle {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 1000;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--bg-card);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: all var(--transition);
    overflow: hidden;
}

.theme-toggle:hover {
    border-color: var(--accent);
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-icon {
    font-size: 1.15rem;
    position: absolute;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] .light-icon,
:root .light-icon {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

[data-theme="light"] .dark-icon,
:root .dark-icon {
    opacity: 0;
    transform: scale(0.5) rotate(90deg);
}

[data-theme="dark"] .light-icon {
    opacity: 0;
    transform: scale(0.5) rotate(-90deg);
}

[data-theme="dark"] .dark-icon {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* --- Header --- */
.header {
    text-align: center;
    margin-bottom: 2.5rem;
    animation: slideDown 0.5s ease-out 0.08s both;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-14px); }
    to { opacity: 1; transform: translateY(0); }
}

.header-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    color: #fff;
    margin-bottom: 1.1rem;
    box-shadow: var(--shadow-accent);
    animation: floatBadge 3.5s ease-in-out infinite;
    position: relative;
}

.header-logo::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: calc(var(--radius-md) + 3px);
    background: var(--accent-gradient);
    opacity: 0.15;
    z-index: -1;
    filter: blur(8px);
}

@keyframes floatBadge {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.header-title {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.35rem;
    line-height: 1.2;
}

.header-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.01em;
}

/* --- Main Content Layout --- */
.main-content {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 1.5rem;
    align-items: start;
    animation: fadeUp 0.5s ease-out 0.15s both;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Upload Zone --- */
.upload-zone {
    border: 2px dashed var(--border-dashed);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    padding: 2.5rem 2rem;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.upload-zone::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent-light);
    opacity: 0;
    transition: opacity var(--transition);
    pointer-events: none;
}

.upload-zone::after {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: calc(var(--radius-lg) - 4px);
    border: 2px solid transparent;
    transition: border-color var(--transition);
    pointer-events: none;
}

.upload-zone:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.upload-zone:hover::before {
    opacity: 1;
}

.upload-zone.drag-over {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow), var(--shadow-lg);
    transform: scale(1.01);
}

.upload-zone.drag-over::before {
    opacity: 1;
}

.upload-zone.drag-over::after {
    border-color: var(--accent-glow);
    animation: pulseBorder 1.2s ease-in-out infinite;
}

@keyframes pulseBorder {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.upload-zone-inner {
    text-align: center;
    position: relative;
    z-index: 1;
}

.upload-icon {
    color: var(--accent);
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    animation: pulseIcon 2.5s ease-in-out infinite;
}

@keyframes pulseIcon {
    0%, 100% { transform: translateY(0); opacity: 0.85; }
    50% { transform: translateY(-4px); opacity: 1; }
}

.upload-icon svg {
    transition: transform var(--transition);
}

.upload-zone:hover .upload-icon {
    animation: none;
}

.upload-zone:hover .upload-icon svg {
    transform: scale(1.1);
}

.upload-text {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 0.4rem;
}

.upload-browse {
    color: var(--accent);
    cursor: pointer;
    font-weight: 600;
    position: relative;
}

.upload-browse::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 100%;
    height: 1.5px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform var(--transition);
}

.upload-browse:hover::after {
    transform: scaleX(1);
    transform-origin: left;
}

.upload-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* --- Preview Area --- */
.preview-area {
    margin-top: 1.5rem;
    animation: fadeUp 0.35s ease-out;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.preview-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.image-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 24px;
    height: 24px;
    border-radius: 12px;
    padding: 0 7px;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-clear-all {
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--danger);
    background: transparent;
    border: 1.5px solid var(--danger);
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.8rem;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-clear-all:hover {
    background: var(--danger);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(231, 76, 60, 0.25);
}

/* --- Preview Grid --- */
.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.85rem;
}

.preview-item {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border);
    overflow: hidden;
    cursor: grab;
    transition: all var(--transition);
    animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
    box-shadow: var(--shadow-sm);
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1); }
}

.preview-item:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}

.preview-item:hover .preview-thumb {
    filter: brightness(1.05) saturate(1.05);
}

.preview-item.dragging {
    opacity: 0.35;
    transform: scale(0.92);
    border-color: var(--accent);
}

.preview-item.drag-target {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Image sequence badge */
.preview-item::before {
    content: attr(data-seq);
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 2;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity var(--transition);
}

.preview-item:hover::before {
    opacity: 1;
}

.preview-thumb {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    background: var(--bg-card-alt);
    transition: filter var(--transition);
}

.preview-name {
    padding: 0.4rem 0.5rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    border-top: 1px solid var(--border);
    background: var(--bg-card-alt);
}

.preview-delete {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all var(--transition);
    line-height: 1;
    backdrop-filter: blur(4px);
    z-index: 3;
}

.preview-item:hover .preview-delete {
    opacity: 1;
}

.preview-delete:hover {
    background: var(--danger);
    transform: scale(1.2) rotate(8deg);
}

/* --- Settings Section --- */
.settings-section {
    position: sticky;
    top: 1.5rem;
}

.settings-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 1.4rem;
    box-shadow: var(--shadow-md);
    transition: all var(--transition);
}

.settings-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--border);
}

.settings-title svg {
    color: var(--accent);
    flex-shrink: 0;
}

.setting-group {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.setting-group:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.setting-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.select-wrapper {
    position: relative;
}

.setting-select {
    width: 100%;
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.55rem 2.2rem 0.55rem 0.75rem;
    cursor: pointer;
    appearance: none;
    transition: all var(--transition);
}

.setting-select:hover {
    border-color: var(--border-hover);
}

.setting-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.select-arrow {
    position: absolute;
    right: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.setting-input {
    width: 100%;
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.75rem;
    transition: all var(--transition);
}

.setting-input:hover {
    border-color: var(--border-hover);
}

.setting-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* --- Generate Button --- */
.btn-generate {
    width: 100%;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.4rem;
    transition: all var(--transition);
    box-shadow: var(--shadow-accent);
    position: relative;
    overflow: hidden;
}

.btn-generate::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
    opacity: 0;
    transition: opacity var(--transition);
}

.btn-generate:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(74, 144, 217, 0.35);
}

.btn-generate:hover:not(:disabled)::before {
    opacity: 1;
}

.btn-generate:active:not(:disabled) {
    transform: translateY(0);
}

.btn-generate:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
    filter: grayscale(0.3);
}

/* --- Settings Tip --- */
.settings-tip {
    margin-top: 0.85rem;
    background: var(--accent-light);
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--accent-glow);
}

.settings-tip p {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--toast-bg);
    color: var(--toast-text);
    padding: 0.7rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 320px;
    backdrop-filter: blur(8px);
}

.toast.toast-out {
    animation: toastOut 0.3s ease-in forwards;
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-info { border-left: 4px solid var(--accent); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(10px) scale(0.95); }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- Responsive --- */
@media (max-width: 800px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .settings-section {
        position: static;
    }

    .container {
        padding: 1.5rem 1rem 3rem;
    }

    .header-title {
        font-size: 1.6rem;
    }

    .upload-zone {
        padding: 2rem 1.25rem;
    }

    .preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 1rem 0.75rem 2.5rem;
    }

    .header-title {
        font-size: 1.35rem;
    }

    .header-logo {
        width: 48px;
        height: 48px;
    }

    .header-logo svg {
        width: 26px;
        height: 26px;
    }

    .header-subtitle {
        font-size: 0.85rem;
    }

    .upload-zone {
        padding: 1.5rem 1rem;
        border-radius: var(--radius-md);
    }

    .upload-icon svg {
        width: 36px;
        height: 36px;
    }

    .preview-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }

    .settings-card {
        padding: 1.1rem;
    }

    .toast-container {
        left: 1rem;
        right: 1rem;
        transform: none;
    }

    .toast {
        max-width: 100%;
    }

    .theme-toggle {
        top: 0.75rem;
        right: 0.75rem;
        width: 42px;
        height: 42px;
    }
}
