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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #1f2937;
    background-color: #ffffff;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

button, input {
    font-family: inherit;
    font-size: 1rem;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
.site-header {
    background-color: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-inner {
    max-width: 800px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.site-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.01em;
}

.quiz-badge {
    background: #f3f4f6;
    color: #4b5563;
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 9999px;
    border: 1px solid #e5e7eb;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-pill {
    background-color: #f3f4f6;
    color: #111827;
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 9999px;
    border: 1px solid #e5e7eb;
}

.site-alert-bar {
    max-width: 800px;
    margin: 12px auto 0;
    padding: 10px 16px;
    background-color: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
}

/* ==========================================================================
   Main Wrapper & Content Views
   ========================================================================== */
.main-wrapper {
    min-height: calc(100vh - 61px);
    display: flex;
    flex-direction: column;
}

.content-view {
    width: 100%;
    flex: 1;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 16px 80px;
}

/* ==========================================================================
   Intro & Score Tracker
   ========================================================================== */
.intro-card {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 24px;
}

.intro-card h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: #111827;
}

.intro-card p {
    font-size: 0.9375rem;
    color: #4b5563;
    margin-bottom: 14px;
}

.quiz-tracker {
    display: flex;
    align-items: center;
    gap: 20px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
    font-size: 0.875rem;
}

.tracker-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tracker-label {
    color: #6b7280;
}

.tracker-val {
    font-weight: 700;
    color: #111827;
}

.btn-text {
    background: none;
    border: none;
    color: #2563eb;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    margin-left: auto;
    padding: 4px 8px;
}
.btn-text:hover {
    text-decoration: underline;
}

/* ==========================================================================
   MCQ Questions
   ========================================================================== */
.mcq-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.card {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 18px 20px;
}

.mcq-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
}

.mcq-num {
    font-weight: 700;
    color: #4b5563;
    font-size: 1rem;
    flex-shrink: 0;
}

.mcq-question {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
    line-height: 1.45;
}

.mcq-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.option-btn:hover:not(:disabled) {
    background-color: #f9fafb;
    border-color: #9ca3af;
}

.opt-prefix {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: #f3f4f6;
    border-radius: 4px;
    font-size: 0.8125rem;
    font-weight: 700;
    color: #374151;
    flex-shrink: 0;
}

.opt-text {
    font-size: 0.9375rem;
    color: #1f2937;
    line-height: 1.4;
}

.option-btn.opt-correct {
    background-color: #ecfdf5;
    border-color: #10b981;
}
.option-btn.opt-correct .opt-prefix {
    background-color: #10b981;
    color: #ffffff;
}
.option-btn.opt-correct .opt-text {
    color: #065f46;
    font-weight: 600;
}

.option-btn.opt-wrong {
    background-color: #fef2f2;
    border-color: #ef4444;
}
.option-btn.opt-wrong .opt-prefix {
    background-color: #ef4444;
    color: #ffffff;
}
.option-btn.opt-wrong .opt-text {
    color: #991b1b;
}

.mcq-result {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.875rem;
}

.mcq-result.correct {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.mcq-result.wrong {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.result-message {
    font-weight: 700;
    margin-bottom: 4px;
}

.result-explanation {
    color: #374151;
    font-size: 0.875rem;
    line-height: 1.4;
}

/* ==========================================================================
   Home Footer
   ========================================================================== */
.home-footer {
    margin-top: 40px;
    padding: 24px 20px;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    text-align: center;
}

.login-prompt p {
    font-size: 0.9375rem;
    color: #4b5563;
    margin-bottom: 16px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.btn-primary {
    background-color: #2563eb;
    color: #ffffff;
}
.btn-primary:hover {
    background-color: #1d4ed8;
}

.btn-large {
    padding: 12px 28px;
    font-size: 1rem;
}

.btn-outline {
    background-color: transparent;
    border-color: #d1d5db;
    color: #374151;
}
.btn-outline:hover {
    background-color: #f3f4f6;
}

.btn-danger {
    background-color: #dc2626;
    border-color: #b91c1c;
    color: #ffffff;
    font-weight: 500;
}
.btn-danger:hover {
    background-color: #b91c1c;
    border-color: #991b1b;
}

.btn-clear-logout {
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(220, 38, 38, 0.2);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8125rem;
}

.btn-block {
    width: 100%;
}

/* ==========================================================================
   Modal Overlay & Login Card
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(17, 24, 39, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}

.login-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 28px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.login-header {
    text-align: center;
    margin-bottom: 20px;
}

.sub-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #6b7280;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.login-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 6px;
}

.login-desc {
    font-size: 0.875rem;
    color: #6b7280;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background-color: #ffffff;
    color: #111827;
    outline: none;
    transition: border-color 0.15s ease;
}

.form-input:focus {
    border-color: #2563eb;
}

.alert {
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.alert-error {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

/* ==========================================================================
   Chat Room (In-page SPA View)
   ========================================================================== */
#view-chat {
    background-color: #f4f5f7;
    display: flex;
    flex-direction: column;
}

.chat-container {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 61px);
    background-color: #f4f5f7;
    border-left: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;
}

.chat-inner-header {
    background-color: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-back-btn {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #374151;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.chat-back-btn:hover {
    background-color: #fee2e2;
    border-color: #fecaca;
    color: #dc2626;
}

.chat-title {
    font-size: 1.0625rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.2;
}

.chat-status {
    font-size: 0.75rem;
    color: #10b981;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #10b981;
}

.chat-header-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ==========================================================================
   Pinned Message Bar (Shows at top, never hides)
   ========================================================================== */
.pinned-bar {
    background-color: #fffbeb;
    border-bottom: 1px solid #fef3c7;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
    z-index: 10;
}

.pinned-content {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.pinned-icon {
    font-size: 1.1rem;
    line-height: 1.2;
    flex-shrink: 0;
}

.pinned-body {
    flex: 1;
    min-width: 0;
}

.pinned-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #b45309;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}

.pinned-text {
    font-size: 0.875rem;
    color: #92400e;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
}

.btn-unpin {
    background: none;
    border: none;
    color: #b45309;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    flex-shrink: 0;
}
.btn-unpin:hover {
    background-color: #fef3c7;
    color: #78350f;
}

/* ==========================================================================
   Chat Messages Container
   ========================================================================== */
.chat-box {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 18px 16px;
    background-color: #f4f5f7;
    scroll-behavior: smooth;
}

.messages-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 100%;
    justify-content: flex-end;
}

/* Message Rows */
.msg-row {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    position: relative;
}

.msg-row.msg-me {
    align-self: flex-end;
    align-items: flex-end;
}

.msg-row.msg-other {
    align-self: flex-start;
    align-items: flex-start;
}

.msg-meta {
    font-size: 0.71875rem;
    color: #6b7280;
    margin-bottom: 3px;
    padding: 0 4px;
}

.msg-bubble-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.msg-row.msg-me .msg-bubble-wrap {
    flex-direction: row-reverse;
}

.msg-bubble {
    padding: 10px 14px;
    font-size: 0.9375rem;
    line-height: 1.45;
    word-break: break-word;
}

.msg-row.msg-me .msg-bubble {
    background-color: #2563eb;
    color: #ffffff;
    border-radius: 16px 16px 4px 16px;
}

.msg-row.msg-other .msg-bubble {
    background-color: #ffffff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-radius: 16px 16px 16px 4px;
}

/* Pin Action button on message */
.btn-pin-msg {
    opacity: 0;
    background: none;
    border: none;
    font-size: 0.8125rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: #9ca3af;
    transition: opacity 0.15s ease, color 0.15s ease;
    line-height: 1;
}

.msg-row:hover .btn-pin-msg {
    opacity: 1;
}

.btn-pin-msg:hover {
    color: #f59e0b;
    background-color: rgba(243, 244, 246, 0.8);
}

.btn-pin-msg.is-pinned {
    opacity: 1;
    color: #f59e0b;
}

/* Bottom Input Bar */
.chat-footer {
    background-color: #ffffff;
    border-top: 1px solid #e5e7eb;
    padding: 12px 16px;
    flex-shrink: 0;
}

.chat-input-bar {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Media buttons in chat input */
.chat-media-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-icon-btn {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
    line-height: 1;
}

.chat-icon-btn:hover {
    background-color: #e5e7eb;
    transform: scale(1.05);
}

.chat-icon-btn:active {
    transform: scale(0.95);
}

/* Uploading progress bar */
.media-upload-bar {
    margin-top: 8px;
    font-size: 0.8125rem;
    color: #2563eb;
    background-color: #eff6ff;
    border: 1px solid #bfdbfe;
    padding: 6px 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

/* User 1's View-Once Media Tag (User 1 cannot view media, only shows Photo/Video text) */
.media-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 0.9375rem;
    padding: 2px 4px;
}

.media-caption {
    margin-top: 6px;
    font-size: 0.875rem;
    line-height: 1.4;
    word-break: break-word;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 4px;
}

.msg-row.msg-other .media-caption {
    border-top: 1px solid #e5e7eb;
    color: #374151;
}

/* Inbound Image & Video media (for User 2 media) */
.chat-media-img {
    max-width: 260px;
    max-height: 260px;
    border-radius: 8px;
    display: block;
    cursor: pointer;
    object-fit: cover;
}

.chat-media-video {
    max-width: 280px;
    max-height: 280px;
    border-radius: 8px;
    display: block;
}

.chat-text-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    outline: none;
    font-size: 0.9375rem;
    background-color: #ffffff;
}

.chat-text-input:focus {
    border-color: #2563eb;
}

.chat-send-btn {
    background-color: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 20px;
    padding: 10px 20px;
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.15s ease;
}

.chat-send-btn:hover {
    background-color: #1d4ed8;
}

.chat-send-btn:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */
@media (max-width: 640px) {
    .container {
        padding: 14px 12px 60px;
    }
    .header-inner {
        padding: 10px 12px;
    }
    .site-title {
        font-size: 1.125rem;
    }
    .card {
        padding: 14px 14px;
    }
    .chat-container {
        border-left: none;
        border-right: none;
    }
    .msg-row {
        max-width: 90%;
    }
    .btn-pin-msg {
        opacity: 0.7; /* Always slightly visible on mobile since no hover */
    }
    .chat-text-input {
        padding: 9px 12px;
        font-size: 0.875rem;
    }
    .chat-send-btn {
        padding: 9px 16px;
        font-size: 0.875rem;
    }
}
