/* Global styles and resets */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

body {
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

/* Header section */
.header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.logo {
    height: 60px;
    width: auto;
    object-fit: contain;
}

.main-title {
    color: #2c3e50;
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 2px;
    margin: 0;
    text-align: center;
}

/* Main container layout */
.container {
    display: flex;
    min-height: calc(100vh - 120px);
    padding: 20px;
    gap: 30px;
}

/* Editor and Preview panels */
.editor-panel, .preview-panel {
    flex: 1;
    padding: 25px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    min-width: 300px;
}

.editor-panel {
    max-width: 500px;
    align-self: flex-start;
}

.preview-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Editor panel heading */
.editor-panel h2 {
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 24px;
    text-align: center;
}

/* Form group styling */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #34495e;
}

/* Input fields and textarea */
input[type="text"], textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s;
}

input[type="text"]:focus, textarea:focus {
    border-color: #3498db;
    outline: none;
}

textarea {
    resize: vertical;
    min-height: 150px;
    overflow-y: hidden;
}

/* Checkbox and Radio button styling */
.checkbox-label, .radio-label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    margin-right: 15px;
    margin-bottom: 5px;
}

.checkbox-label input, .radio-label input {
    margin-right: 8px;
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #3498db;
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
}

/* File input and remove button area */
.upload-area {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}
input[type="file"] {
    flex-grow: 1;
    padding: 10px 0;
    color: #555;
    font-size: 14px;
}
.remove-btn {
    background-color: #e74c3c !important;
    padding: 6px 12px !important;
    font-size: 14px !important;
    width: auto !important;
    margin-top: 0 !important;
    flex-shrink: 0;
}
.remove-btn:hover {
    background-color: #c0392b !important;
}

/* General button styling */
button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: background-color 0.3s;
    width: 100%;
    margin-top: 10px;
}
button:hover {
    background-color: #2980b9;
}
#preview-btn {
    margin-top: 20px;
}

/* Save button styling */
#save-btn {
    background-color: #2ecc71;
    margin-top: 20px;
    max-width: 200px;
}
#save-btn:hover {
    background-color: #27ae60;
}

/* --- Poster Styling --- */
.poster {
    width: 100%;
    max-width: 800px;
    background-color: #0a192f;
    color: #e6f1ff;
    padding: 40px;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Poster background effects */
.poster::before, .poster::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 0;
    pointer-events: none;
}
.poster::before {
    background:
        linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, transparent 50%),
        linear-gradient(45deg, rgba(99, 102, 241, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 20% 30%, rgba(59, 130, 246, 0.1) 0%, transparent 30%),
        radial-gradient(circle at 80% 70%, rgba(139, 92, 246, 0.1) 0%, transparent 30%);
}
.poster::after {
    background-image:
        linear-gradient(to right, rgba(10, 25, 47, 0.9) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(10, 25, 47, 0.9) 1px, transparent 1px);
    background-size: 30px 30px;
    opacity: 0.3;
}

/* Ensure direct children of poster are above the background effects */
.poster > * {
    position: relative;
    z-index: 1;
}

/* --- Poster Header Area --- */
.poster-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
    width: 100%;
}

.title-author-group {
    flex-grow: 1;
    text-align: center;
    min-width: 0;
}

#poster-title {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 5px;
    color: #64ffda;
    text-shadow: 0 0 10px rgba(100, 255, 218, 0.3);
}

.author {
    display: block;
    font-size: 14px;
    color: #8892b0;
    margin-top: 5px;
    min-height: 18px;
}

/* --- Text Date Line --- */
.text-date-line {
    display: none;
    justify-content: space-between;
    align-items: center;
    margin: 0 0 8px 0; /* 进一步减小与标题的间距 */
    min-height: 18px;
    width: 100%;
    font-size: 14px;
    color: #8892b0;
}

.date-text {
    display: inline-block;
    text-align: right;
}

/* --- Calendar Date Container --- */
#poster-date-container {
    display: none;
    flex-shrink: 0;
    margin-left: 20px;
}

/* --- Style Variations Based on Selected Date Style --- */
.poster.date-style-text .poster-header {
    flex-direction: column;
    align-items: center;
}

.poster.date-style-text .title-author-group {
    text-align: center;
    width: 100%;
    margin-bottom: 0; /* 减小标题下方间距 */
}

.poster.date-style-text .author {
    display: none;
}

.poster.date-style-text .text-date-line {
    display: flex;
}

.poster.date-style-text #poster-date-container {
    display: none;
}

.poster.date-style-calendar .poster-header {
    justify-content: space-between;
}

.poster.date-style-calendar .title-author-group {
    text-align: center;
    margin: 0 auto;
    width: 100%;
    padding-right: 100px; /* 向左移动标题，大约一个字的长度 */
}

.poster.date-style-calendar .author-container {
    display: none; /* 日历样式下不显示作者组件 */
}

.poster.date-style-calendar .text-date-line {
    display: none;
}

.poster.date-style-calendar #poster-date-container {
    display: flex;
}

/* Calendar Icon Styles */
.calendar-date {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgba(100, 255, 218, 0.1);
    border: 1px solid rgba(100, 255, 218, 0.3);
    border-radius: 8px;
    width: 85px;
    height: 75px;
    padding: 5px;
    color: #e6f1ff;
    font-family: 'Segoe UI', sans-serif;
}
.calendar-weekday {
    font-size: 12px;
    font-weight: 600;
    color: #8892b0;
    line-height: 1.2;
    margin-bottom: 2px;
}
.calendar-day {
    font-size: 28px;
    font-weight: 700;
    color: #64ffda;
    line-height: 1;
}
.calendar-month-year {
    font-size: 11px;
    color: #a8b2d1;
    line-height: 1.2;
    margin-top: 2px;
}

/* --- Divider and Content Area --- */
.divider {
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(100, 255, 218, 0.3), transparent);
    margin: 20px 0;
}

.poster-content {
    min-height: 200px;
    padding: 10px 0;
    line-height: 1.8;
    color: #ccd6f6;
    font-size: 16px;
    display: block !important;
}

/* --- Markdown content styling --- */
/* Titles */
.poster-content h1 {
    font-size: 26px;
    color: #64ffda;
    margin: 25px 0 15px;
}
.poster-content h2 {
    font-size: 22px;
    color: #64ffda;
    margin: 20px 0 12px;
    border-bottom: 1px solid rgba(100, 255, 218, 0.2);
    padding-bottom: 5px;
}
.poster-content h3 {
    font-size: 18px;
    color: #64ffda;
    margin: 18px 0 10px;
}
.poster-content h4,
.poster-content h5,
.poster-content h6 {
    color: #64ffda;
    margin: 15px 0 8px;
}

/* Paragraphs */
.poster-content p {
    margin-bottom: 15px;
    color: #ccd6f6;
}

/* Lists */
.poster-content ul,
.poster-content ol {
    margin-left: 25px;
    margin-bottom: 15px;
    padding-left: 5px;
    color: #ccd6f6;
}
.poster-content li {
    margin-bottom: 8px;
    color: #ccd6f6;
}

/* Links */
.poster-content a {
    color: #64ffda;
    text-decoration: none;
    border-bottom: 1px dotted #64ffda;
    transition: color 0.3s, border-color 0.3s;
}
.poster-content a:hover {
    color: #e6f1ff;
    border-bottom-color: #e6f1ff;
}

/* Inline Code */
.poster-content code:not(pre code) {
    background-color: rgba(100, 255, 218, 0.1);
    color: #64ffda;
    padding: 3px 6px;
    border-radius: 4px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
    font-size: 0.9em;
}

/* Code Blocks */
.poster-content pre {
    background-color: rgba(10, 25, 47, 0.8);
    border: 1px solid rgba(100, 255, 218, 0.2);
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 20px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
.poster-content pre code {
    background-color: transparent;
    padding: 0;
    font-size: 0.85em;
    line-height: 1.5;
    color: #ccd6f6;
}

/* Blockquotes */
.poster-content blockquote {
    border-left: 3px solid #64ffda;
    padding-left: 15px;
    margin: 20px 0;
    color: #a8b2d1;
    font-style: italic;
}
.poster-content blockquote p {
    margin-bottom: 0;
    color: #a8b2d1;
}

/* Images */
.poster-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 10px 0;
    display: block;
}

/* --- Poster Footer --- */
.poster-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(100, 255, 218, 0.1);
    font-size: 14px;
    color: #8892b0;
    min-height: 80px;
    flex-wrap: wrap;
    gap: 15px;
}

.footer-text {
    flex-grow: 1;
    min-width: 150px;
}

.qr-code {
    width: 80px;
    height: 80px;
    opacity: 0.8;
    filter: brightness(0.9);
    transition: opacity 0.3s, filter 0.3s;
    border-radius: 4px;
    flex-shrink: 0;
    object-fit: contain;
}
.qr-code:hover {
    opacity: 1;
    filter: brightness(1);
}

/* --- Responsive Design --- */
@media (max-width: 1000px) {
    .container {
        flex-direction: column;
    }
    .editor-panel {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .header { gap: 10px; }
    .logo { height: 50px; }
    .main-title { font-size: 28px; }
    .container { padding: 15px; gap: 20px; }
    .editor-panel, .preview-panel { padding: 20px; }
    .poster { padding: 30px; }
    #poster-title { font-size: 28px; }

    .poster-header {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .title-author-group {
        order: 1;
        width: 100%;
        text-align: center;
    }

    #poster-author {
        text-align: center;
    }

    #poster-date-container {
        order: 2;
        margin-left: 0;
        margin-top: 10px;
    }

    .text-date-line {
        text-align: center;
        order: 2;
        margin: 10px 0;
        flex-direction: column;
    }

    .calendar-date { width: 70px; height: 70px; }
    .calendar-day { font-size: 24px; }

    .poster-footer {
        flex-direction: column;
        text-align: center;
        min-height: auto;
    }
    .footer-text { margin-bottom: 15px; }
}

@media (max-width: 480px) {
    .main-title { font-size: 24px; }
    .poster { padding: 20px; }
    #poster-title { font-size: 24px; }
    .calendar-date { width: 65px; height: 65px; }
    .calendar-day { font-size: 22px; }
    button { font-size: 15px; padding: 10px 15px; }
    input[type="text"], textarea { font-size: 15px; padding: 10px 12px; }
    .poster-content { font-size: 15px; }
    .qr-code { width: 70px; height: 70px; }
}

.author-container {
    margin-top: 10px;
}

.author-box {
    display: inline-flex;
    align-items: center;
    padding: 4px 0; /* 移除左右内边距 */
    background: transparent; /* 移除背景色 */
    border-radius: 0;
}

.author {
    color: #94A3B8;
    font-size: 0.9em;
}

/* 日历样式下的作者名称布局 */
.date-style-calendar .author-container {
    margin-top: 5px;
    display: none; /* 确保日历样式下不显示作者容器 */
}

.date-style-calendar .title-author-group {
    display: block; /* 改为块级显示，确保标题居中 */
    text-align: center;
}

.date-style-calendar .author-box {
    margin-top: 0;
}