/* 
 * 风扇的部屋 - Global Styles
 * Pure CSS, no framework dependencies
 */

/* CSS Variables - Use system fonts for China compatibility (Google Fonts blocked) */
:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --bg-card: rgba(26, 26, 26, 0.8);
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --border-subtle: rgba(255, 255, 255, 0.1);
    --glow-white: rgba(255, 255, 255, 0.1);
    --purple: rgba(147, 112, 219, 1);
    --purple-glow: rgba(147, 112, 219, 0.3);
    --cyan: rgba(100, 200, 255, 1);
    --cyan-glow: rgba(100, 200, 255, 0.3);
    --pink: rgba(255, 153, 153, 1);
    --pink-glow: rgba(255, 153, 153, 0.3);
    --font-main: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--text-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s;
}

a:hover {
    color: var(--text-secondary);
}

/* Container */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 2rem;
}

.main-title {
    font-size: 2.5rem;
    font-weight: 300;
    letter-spacing: 0.5rem;
    text-shadow: 0 0 20px var(--glow-white);
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 0.95rem;
    font-weight: 300;
    color: var(--text-muted);
    letter-spacing: 0.2rem;
}

/* Avatar */
.avatar-container {
    display: flex;
    justify-content: center;
    margin: 2rem 0;
}

.avatar-img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 2px solid var(--border-subtle);
    box-shadow: 0 0 30px var(--glow-white);
    object-fit: cover;
}

/* Glass Card */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    padding: 1.5rem 2rem;
    margin: 1rem 0;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.03);
}

.glass-card h3 {
    font-weight: 400;
    margin-bottom: 0.8rem;
    font-size: 1.1rem;
}

.glass-card p {
    font-weight: 300;
    color: var(--text-secondary);
    line-height: 1.8;
    font-size: 0.9rem;
}

/* Rooms Grid */
.rooms-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin: 2rem 0;
}

.room-card {
    background: rgba(20, 20, 20, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.room-card h4 {
    font-weight: 400;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.room-card p {
    font-weight: 300;
    color: var(--text-muted);
    font-size: 0.85rem;
    flex-grow: 1;
}

.room-btn {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    margin-top: 1rem;
    font-family: var(--font-main);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.room-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Room Card Variants */
.room-card-purple {
    border: 1px solid rgba(147, 112, 219, 0.4);
    box-shadow: 0 0 15px var(--purple-glow);
}

.room-card-purple:hover {
    border-color: rgba(147, 112, 219, 0.7);
    box-shadow: 0 0 25px rgba(147, 112, 219, 0.5);
}

.room-card-cyan {
    border: 1px solid rgba(100, 200, 255, 0.4);
    box-shadow: 0 0 15px var(--cyan-glow);
}

.room-card-cyan:hover {
    border-color: rgba(100, 200, 255, 0.7);
    box-shadow: 0 0 25px rgba(100, 200, 255, 0.5);
}

.room-card-pink {
    border: 1px solid rgba(255, 153, 153, 0.4);
    box-shadow: 0 0 15px var(--pink-glow);
}

.room-card-pink:hover {
    border-color: rgba(255, 153, 153, 0.7);
    box-shadow: 0 0 25px rgba(255, 153, 153, 0.5);
}

/* Third card spans full width on grid */
.rooms-grid .room-card:nth-child(3) {
    grid-column: 1;
}

/* Divider */
.divider {
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-subtle), transparent);
    margin: 3rem auto;
    width: 80%;
}

/* Social Section */
.social-section {
    text-align: center;
    margin: 2rem 0;
}

.social-title {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.qr-grid {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.qr-item {
    text-align: center;
    padding: 0.3rem;
}

.qr-img {
    width: 70px;
    height: 70px;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
}

.qr-label {
    color: var(--text-secondary);
    font-size: 0.65rem;
    margin-top: 0.4rem;
    margin-bottom: 0;
}

.qr-sublabel {
    color: var(--text-muted);
    font-size: 0.55rem;
    margin-top: 2px;
}

/* Footer */
.footer {
    text-align: center;
    color: #444444;
    font-size: 0.75rem;
    margin-top: 3rem;
    font-weight: 300;
}

/* ============ Room Page Styles ============ */

.room-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.back-btn {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-main);
    transition: all 0.2s;
}

.back-btn:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.room-title {
    font-size: 1.5rem;
    font-weight: 400;
}

/* Key Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
}

.modal-content h2 {
    margin-bottom: 1rem;
    font-weight: 400;
}

.modal-input {
    width: 100%;
    padding: 0.8rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 1rem;
    margin-bottom: 1rem;
}

.modal-input:focus {
    outline: none;
    border-color: var(--text-secondary);
}

.modal-btn {
    width: 100%;
    padding: 0.8rem;
    background: var(--text-primary);
    color: var(--bg-primary);
    border: none;
    border-radius: 8px;
    font-family: var(--font-main);
    font-size: 1rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.modal-btn:hover {
    opacity: 0.9;
}

.modal-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.modal-error {
    color: #ff6b6b;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* Chat Container */
.chat-container {
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: calc(100vh - 120px);
    padding-bottom: 100px;
    /* Space for fixed input area */
}

.messages-area {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    min-height: 300px;
    padding: 1rem 0 200px 0;
    /* Extra bottom padding for input bar */
    -webkit-overflow-scrolling: touch;
}

.message {
    padding: 1.2rem 1.5rem;
    border-radius: 12px;
    line-height: 1.8;
}

.message-user {
    background: rgba(100, 200, 255, 0.15);
    border: 1px solid rgba(100, 200, 255, 0.3);
    max-width: 80%;
    align-self: flex-end;
    white-space: pre-wrap;
}

/* Improved Assistant Message Bubble */
.message-assistant {
    background: linear-gradient(180deg, rgba(30, 40, 50, 0.95) 0%, rgba(20, 20, 20, 0.95) 100%);
    border: 1px solid rgba(100, 200, 255, 0.15);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2), inset 0 0 20px rgba(100, 200, 255, 0.02);
    width: 100%;
    padding: 20px;
    /* Increased padding */
}

/* === Chat Content Typography === */
.message-assistant h2 {
    color: #ffd700 !important;
    font-size: 1.4rem;
    font-weight: 500;
    margin: 2.5rem 0 1.5rem 0;
    /* More spacing */
    padding: 0.8rem 1.2rem;
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.08) 0%, transparent 100%);
    border-left: 4px solid #ffd700;
    border-radius: 4px;
    /* Slightly softer */
    letter-spacing: 0.05em;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
}

.message-assistant h2:first-child {
    margin-top: 0.5rem;
}

.message-assistant h3 {
    color: #64c8ff !important;
    font-size: 1.2rem;
    font-weight: 500;
    margin: 2rem 0 1rem 0;
    padding: 0.5rem 1rem;
    background: linear-gradient(90deg, rgba(100, 200, 255, 0.08) 0%, transparent 100%);
    border-left: 3px solid #64c8ff;
    border-radius: 4px;
}

.message-assistant h4 {
    color: #00d4aa !important;
    /* Cyan-Green for H4 */
    font-size: 1.1rem;
    margin: 1.5rem 0 0.8rem 0;
}

.message-assistant strong,
.message-assistant b {
    color: #92d9e6 !important;
    /* Light Cyan for bold text to differentiate from body */
    font-weight: 700;
    text-shadow: 0 0 5px rgba(100, 200, 255, 0.15);
    padding: 0 2px;
}

.message-assistant p {
    margin: 1.0rem 0;
    /* More spacing between paragraphs */
    line-height: 1.9;
    /* More breathable line height */
    text-indent: 0;
    color: #e0e0e0;
    /* Slightly brighter text */
    font-size: 1.05rem;
    /* Larger font size */
}

/* Custom List Item Markers */
.message-assistant ul,
.message-assistant ol {
    margin: 1.2rem 0;
    padding-left: 1.5rem;
}

.message-assistant li {
    margin: 1rem 0;
    /* Significant spacing between list items */
    line-height: 1.8;
    color: #d0d0d0;
    padding-left: 0.5rem;
    position: relative;
}

/* Bullet points color */
.message-assistant ul li::marker {
    color: #64c8ff;
    /* Cyan bullets */
    font-size: 1.2em;
}

.message-assistant ol li::marker {
    color: #ffd700;
    /* Gold numbers */
    font-weight: 600;
    font-style: italic;
}

.message-assistant blockquote {
    border-left: 3px solid #64c8ff;
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    background: rgba(100, 200, 255, 0.05);
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: #a0c0d0;
    box-shadow: inset 10px 0 20px -10px rgba(100, 200, 255, 0.1);
}

/* Speaker name styling */
/* Speaker name styling - only for the first paragraph */
.message-assistant p:first-of-type>strong:first-child {
    display: inline-block;
    color: #ff9966;
    background: rgba(255, 153, 102, 0.12);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    margin-right: 0.3rem;
}

/* Homework section styling for Daliuren course */
.homework-section {
    border-left: 4px solid #00d4aa;
    background: rgba(0, 212, 170, 0.06);
    padding: 20px;
    border-radius: 0 12px 12px 0;
    margin: 25px 0;
}

.homework-section h3 {
    color: #00d4aa !important;
    border-left-color: #00d4aa !important;
    background: rgba(0, 212, 170, 0.1) !important;
}

.homework-section strong {
    color: #00d4aa;
}

/* Content highlighting for Daliuren course (replaces broken markdown bold) */
.highlight-bracket {
    color: #ffd700;
    font-weight: 600;
}

.highlight-quote {
    color: #00d4ff;
    font-weight: 500;
}

.highlight-book {
    color: #c792ea;
    font-style: italic;
}

/* Input Area */
.input-area {
    display: flex;
    gap: 0.5rem;
    padding: 20px;
    border-top: 1px solid var(--border-subtle);

    /* Fixed Positioning */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;

    /* Layout */
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    /* Center it */
    background: #121212;
    /* Dark background to cover scrolling text */
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

.chat-input {
    flex: 1;
    padding: 0.8rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 1rem;
    resize: none;
}

.chat-input:focus {
    outline: none;
    border-color: var(--text-secondary);
}

.send-btn {
    padding: 0.8rem 1.5rem;
    background: var(--text-primary);
    color: var(--bg-primary);
    border: none;
    border-radius: 8px;
    font-family: var(--font-main);
    cursor: pointer;
    transition: opacity 0.2s;
}

.send-btn:hover {
    opacity: 0.9;
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* User Data Form */
.user-data-form {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.user-data-form h3 {
    margin-bottom: 1rem;
    font-weight: 400;
}

.user-data-form textarea {
    width: 100%;
    min-height: 150px;
    padding: 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.95rem;
    line-height: 1.6;
    resize: vertical;
    margin-bottom: 1rem;
}

.user-data-form textarea:focus {
    outline: none;
    border-color: var(--text-secondary);
}

.submit-data-btn {
    width: 100%;
    padding: 0.8rem;
    background: var(--text-primary);
    color: var(--bg-primary);
    border: none;
    border-radius: 8px;
    font-family: var(--font-main);
    font-size: 1rem;
    cursor: pointer;
    margin-top: 1rem;
}

.submit-data-btn:hover {
    opacity: 0.9;
}

/* Form Grid Styles */
.form-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-field.full-width {
    grid-column: 1 / -1;
}

.form-field label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.form-field select,
.form-field input,
.form-field textarea {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.95rem;
}

.form-field select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

/* Style dropdown options to be visible on all systems */
.form-field select option,
select option {
    background: #1a1a1a !important;
    background-color: #1a1a1a !important;
    color: #ffffff !important;
    padding: 8px;
}

/* Ensure select element itself has dark background when open */
.form-field select,
select {
    background-color: #0a0a0a !important;
    color: #ffffff !important;
}

.form-field select:focus,
.form-field input:focus,
.form-field textarea:focus {
    outline: none;
    border-color: var(--pink);
}

.form-field textarea {
    min-height: 80px;
    resize: vertical;
}

.relationship-field {
    margin-bottom: 1rem;
}

@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr 1fr;
    }

    .form-grid .form-field:first-child {
        grid-column: 1 / -1;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-subtle);
    border-radius: 50%;
    border-top-color: var(--text-primary);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .main-title {
        font-size: 1.8rem;
        letter-spacing: 0.3rem;
    }

    .rooms-grid {
        grid-template-columns: 1fr;
    }

    .rooms-grid .room-card:nth-child(3) {
        grid-column: 1;
    }

    .room-card {
        padding: 1rem;
    }

    .room-card h4 {
        font-size: 1rem;
    }

    .qr-grid {
        gap: 0.5rem;
    }

    .qr-img {
        width: 60px;
        height: 60px;
    }

    .message {
        max-width: 95%;
    }

    .messages-area {
        padding-bottom: 180px;
        /* Increased safe margin for mobile */
    }

    .input-area {
        padding: 12px 15px;
        gap: 8px;
    }

    .send-btn {
        padding: 0.8rem 1.2rem;
    }
}

/* Hide scrollbar but allow scrolling */
.messages-area::-webkit-scrollbar {
    width: 6px;
}

.messages-area::-webkit-scrollbar-track {
    background: transparent;
}

.messages-area::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 3px;
}

.messages-area::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Annual Report Topic Buttons */
.topic-btn {
    width: 100%;
    padding: 16px 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    font-size: 15px;
    text-align: left;
    background: rgba(255, 255, 255, 0.03);
    color: #ccc;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.topic-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
    transform: translateX(5px);
}

.topic-btn.completed {
    background: rgba(76, 175, 80, 0.1);
    border-color: rgba(76, 175, 80, 0.3);
    color: #4caf50;
}

.topic-btn.completed:hover {
    background: rgba(76, 175, 80, 0.2);
    border-color: #4caf50;
}

.topic-btn.current {
    background: linear-gradient(135deg, rgba(255, 99, 71, 0.1), rgba(255, 165, 0, 0.1));
    border-color: rgba(255, 99, 71, 0.3);
    color: #fff;
    box-shadow: 0 0 15px rgba(255, 99, 71, 0.05);
}

.topic-btn.current:hover {
    background: linear-gradient(135deg, rgba(255, 99, 71, 0.2), rgba(255, 165, 0, 0.2));
    border-color: #ff6347;
}

.topic-btn.locked {
    background: rgba(100, 100, 100, 0.1);
    border-color: rgba(150, 150, 150, 0.2);
    color: #888;
}

.topic-btn.locked:hover {
    background: rgba(255, 215, 0, 0.1);
    border-color: rgba(255, 215, 0, 0.3);
    color: #ffd700;
}

.topic-btn.free {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.08), rgba(139, 195, 74, 0.08));
    border-color: rgba(76, 175, 80, 0.3);
    color: #8bc34a;
}

.topic-btn.free:hover {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.15), rgba(139, 195, 74, 0.15));
    border-color: #8bc34a;
    color: #aed581;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 99, 71, 0.1);
    border-top: 3px solid #ff6347;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}