/* style.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    background: #eef2f5;
}

body {
    font-family: system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
}

.chat-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 800px;
    height: 100%;
    max-height: 100vh;
    background: white;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    border-radius: 0;
    margin: 0 auto;
}

.header {
    background: #2c3e50;
    color: white;
    padding: 16px 24px;
    font-size: 1.4rem;
    font-weight: bold;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}

#flash-container {
    flex-shrink: 0;
    min-height: 0;
}
#flash-container:empty {
    display: none;
}

.flash {
    padding: 10px 20px;
    margin: 8px 20px;
    background: #d4edda;
    color: #155724;
    border-radius: 30px;
    font-size: 0.85rem;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.03);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.messages-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px 18px;
    background: #f9fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.loading-placeholder {
    text-align: center;
    padding: 40px 20px;
    color: #7f8c8d;
    font-size: 0.95rem;
}

.message {
    background: white;
    border-radius: 18px;
    padding: 14px 18px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
    border-left: 4px solid #3498db;
    transition: box-shadow 0.15s;
    word-break: break-word;
}
.message:hover {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.nickname {
    font-weight: 700;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 4px;
}

.time {
    color: #7f8c8d;
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0.2px;
}

.content {
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
    color: #1e293b;
}

.input-area {
    padding: 18px 20px 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.form-group {
    margin-bottom: 14px;
}

.form-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.nickname-group {
    flex: 1;
}

.checkbox-group {
    flex-shrink: 0;
}

label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 5px;
    color: #334155;
    font-weight: 500;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 28px;
    font-weight: 400;
    cursor: pointer;
    white-space: nowrap;
    color: #2c3e50;
}

.checkbox-label input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: #3498db;
    cursor: pointer;
}

input, textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid #d1d9e6;
    border-radius: 18px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fafbfc;
    transition: border 0.2s, background 0.2s;
}
input:focus, textarea:focus {
    outline: none;
    border-color: #3498db;
    background: white;
    box-shadow: 0 0 0 3px rgba(52,152,219,0.1);
}

textarea {
    resize: vertical;
    min-height: 90px;
    line-height: 1.5;
}

.send-button {
    background: #3498db;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 40px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: background 0.2s, transform 0.1s;
    box-shadow: 0 4px 8px rgba(52,152,219,0.2);
    letter-spacing: 0.3px;
}
.send-button:hover {
    background: #2980b9;
}
.send-button:active {
    transform: scale(0.98);
}
.send-button:disabled {
    background: #a0c4e2;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.7;
}

.pagination {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.pagination:empty {
    display: none;
}

.page-btn {
    background: #edf2f7;
    color: #1e293b;
    padding: 8px 16px;
    border-radius: 30px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    min-width: 44px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.page-btn:hover {
    background: #d0dfeb;
}
.page-btn.active {
    background: #3498db;
    color: white;
    box-shadow: 0 4px 8px rgba(52,152,219,0.2);
    pointer-events: none;
}

/* ---------- 移动端紧凑优化 ---------- */
@media (max-width: 600px) {
    .header {
        padding: 12px 18px;
        font-size: 1.25rem;
    }

    .messages-area {
        padding: 14px 12px;
    }

    /* 输入区整体压缩 */
    .input-area {
        padding: 12px 14px 14px;
    }

    .form-group {
        margin-bottom: 10px;
    }

    .form-row {
        gap: 10px;
        align-items: flex-end;       /* 底部对齐更紧凑 */
    }

    .nickname-group {
        flex: 1 1 140px;
    }

    .checkbox-group {
        margin-bottom: 2px;
    }

    label {
        font-size: 0.8rem;
        margin-bottom: 4px;
    }

    .checkbox-label {
        margin-top: 0;
        gap: 6px;
        padding-bottom: 6px;
        white-space: nowrap;
    }

    .checkbox-label input {
        width: 18px;
        height: 18px;
    }

    /* 输入框减小内边距 */
    input, textarea {
        padding: 10px 12px;
        font-size: 0.9rem;
        border-radius: 14px;
    }

    /* 文本域最小高度降低 */
    textarea {
        min-height: 70px;
    }

    .send-button {
        padding: 12px 18px;
        font-size: 0.95rem;
    }

    .pagination {
        padding: 10px 12px;
    }

    .page-btn {
        padding: 6px 12px;
        min-width: 40px;
    }

    .flash {
        padding: 8px 16px;
        margin: 6px 16px;
        font-size: 0.8rem;
    }
}

/* 极窄屏进一步微调 */
@media (max-width: 380px) {
    .input-area {
        padding: 10px 12px 12px;
    }

    textarea {
        min-height: 60px;
    }

    .checkbox-label {
        font-size: 0.8rem;
    }
}