/* ============================================
   小红书图片工具样式 - Xiaohongshu Image Tool Styles
   ============================================ */

:root {
    --primary: #2563eb;
    --bg-app: #f8fafc;
    --bg-panel: #ffffff;
    --border: #e2e8f0;
    --text-main: #1e293b;
    --text-sub: #64748b;
}

body {
    height: 100vh;
    display: flex;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
    background: var(--bg-app);
    color: var(--text-main);
    overflow: hidden;
    flex-direction: column;
    margin: 0;
    padding: 0;
}

/* 确保导航栏正常显示 */
.navbar {
    flex-shrink: 0;
    position: relative;
    z-index: 100;
    width: 100%;
}

.top-bar {
    flex-shrink: 0;
    width: 100%;
}

/* 确保导航容器正常显示 */
.nav-container {
    width: 100%;
    max-width: 100%;
}

/* 布局 */
aside {
    width: 40%;
    min-width: 450px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 20;
    box-shadow: 4px 0 24px rgba(0,0,0,0.03);
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f1f5f9;
    position: relative;
    overflow: hidden;
}

/* 组件样式 */
.header {
    height: 64px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(8px);
}

.logo {
    font-weight: 800;
    font-size: 18px;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0 24px;
    height: 40px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
}

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

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.scroll-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.section-header {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-sub);
    text-transform: uppercase;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 8px;
    margin-bottom: 12px;
}

/* 风格网格 */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.style-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    height: 72px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fff;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.style-card.active {
    border: 2px solid var(--primary);
    background: #eff6ff;
}

.style-preview {
    width: 100%;
    height: 100%;
    position: absolute;
    opacity: 0.5;
    z-index: 0;
}

.style-name {
    position: relative;
    z-index: 1;
    font-size: 12px;
    font-weight: 600;
    background: rgba(255,255,255,0.9);
    padding: 2px 6px;
    border-radius: 4px;
}

/* 控件 */
.row {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.row-label {
    font-size: 12px;
    color: var(--text-sub);
    width: 40px;
    flex-shrink: 0;
}

input[type=text], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    background: #f8fafc;
    color: var(--text-main);
    transition: 0.2s;
}

input[type=text]:focus, select:focus, textarea:focus {
    background: #fff;
    border-color: var(--primary);
}

input[type=range] {
    flex: 1;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    -webkit-appearance: none;
    cursor: pointer;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: white;
    border: 2px solid var(--primary);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.img-panel {
    background: #f1f5f9;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    gap: 8px;
}

.icon-btn {
    flex: 1;
    border: none;
    background: white;
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-main);
    font-weight: 500;
    transition: 0.2s;
}

.icon-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.icon-btn.danger {
    color: #ef4444;
}

.toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-main);
    user-select: none;
}

.toggle-track {
    width: 36px;
    height: 20px;
    background: #cbd5e1;
    border-radius: 99px;
    position: relative;
    transition: 0.3s;
}

.toggle-thumb {
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: 0.3s;
}

input[type="checkbox"] {
    display: none;
}

input[type="checkbox"]:checked + .toggle-track {
    background: var(--primary);
}

input[type="checkbox"]:checked + .toggle-track .toggle-thumb {
    transform: translateX(16px);
}

.editor-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 400px;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.editor-tools {
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#inpBody {
    flex: 1;
    padding: 16px;
    border: none;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    font-family: "Menlo", monospace;
}

.title-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    background: #fff;
    resize: none;
    font-family: inherit;
}

.title-input:focus {
    border-color: var(--primary);
    outline: none;
}

/* 预览 */
.toolbar {
    height: 56px;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

.ratio-btn {
    padding: 6px 16px;
    font-size: 12px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    color: var(--text-sub);
    font-weight: 500;
    transition: 0.2s;
}

.ratio-btn.active {
    background: #eff6ff;
    color: var(--primary);
    font-weight: 700;
    border-color: rgba(37, 99, 235, 0.2);
}

#previewArea {
    flex: 1;
    overflow-y: auto;
    padding: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}

/* 卡片核心 */
.card {
    background: white;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px -10px rgba(0,0,0,0.15);
    transition: all 0.3s;
    transform-origin: top center;
}

/* 纹理 */
.tex-paper {
    background-color: #fefce8;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.08'/%3E%3C/svg%3E");
}

.tex-grid {
    background-color: #ffffff;
    background-image: linear-gradient(#e2e8f0 1px, transparent 1px), linear-gradient(90deg, #e2e8f0 1px, transparent 1px);
    background-size: 20px 20px;
}

.tex-kraft {
    background-color: #d6cbb6;
    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='1.5' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.15'/%3E%3C/svg%3E");
}

.tex-dot {
    background-color: #fdf2f8;
    background-image: radial-gradient(#db2777 1.5px, transparent 1.5px);
    background-size: 15px 15px;
}

.bg-layer {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.mask-layer {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

.content-layer {
    position: relative;
    z-index: 10;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* MD 排版 */
.cover-h1 {
    font-weight: 900;
    line-height: 1.2;
    margin: 0 0 20px 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.md-h1 {
    font-weight: 900;
    line-height: 1.3;
    margin: 0.6em 0;
}

.md-h2 {
    font-weight: 700;
    font-size: 1.25em;
    margin: 0.8em 0 0.4em 0;
}

.md-p {
    margin-bottom: 0.8em;
    text-align: justify;
}

.md-li {
    margin-bottom: 0.5em;
    padding-left: 1.2em;
    position: relative;
}

.md-li::before {
    content: "•";
    position: absolute;
    left: 0.2em;
    font-weight: bold;
}

.md-quote {
    border-left: 3px solid currentColor;
    padding: 8px 16px;
    background: rgba(0,0,0,0.04);
    opacity: 0.9;
    font-style: italic;
    margin-bottom: 1em;
    border-radius: 0 6px 6px 0;
}

.md-img {
    width: 100%;
    border-radius: 6px;
    margin: 8px 0;
    display: block;
}

#statusBar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 8px;
    background: #ef4444;
    color: white;
    text-align: center;
    font-size: 12px;
    font-weight: bold;
    z-index: 9999;
    display: none;
}

.app-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0; /* 确保 flex 子元素可以正确收缩 */
}

/* 响应式 */
@media (max-width: 968px) {
    aside {
        width: 100%;
        min-width: 100%;
    }
    
    .app-wrapper {
        flex-direction: column;
    }
}
