/* =====================================================================
   TopicPass — Main Stylesheet v2
   New: language bar, reaction buttons, scheduler indicators,
        user profile widget, custom auth forms (login/register)
   ===================================================================== */

/* ── Reset & base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
    background: #f0f2f5;
    color: #1c1e21;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: #2271b1; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ────────────────────────────────────────────────────── */
.tp-header {
    position: sticky; top: 0; z-index: 100;
    background: #fff;
    border-bottom: 1px solid #e4e6eb;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    height: 56px;
}
.tp-header-inner {
    max-width: 1280px; margin: 0 auto; padding: 0 16px;
    height: 100%;
    display: flex; align-items: center; gap: 12px;
}
.tp-logo {
    display: flex; align-items: center; gap: 8px;
    font-size: 1.1rem; font-weight: 800; color: #1c1e21;
    text-decoration: none; flex-shrink: 0;
}
.tp-logo-icon { font-size: 1.3rem; }
.tp-logo-name { color: #2271b1; }

/* ── Language bar (in header) ───────────────────────────────────── */
.tp-lang-bar {
    display: flex; align-items: center; gap: 4px; margin-left: auto;
    background: #f0f2f5; border-radius: 8px; padding: 3px 6px;
}
.tp-lang-label { font-size: .72rem; color: #888; font-weight: 600; margin-right: 2px; }
.tp-lang-btn {
    border: none; background: none; cursor: pointer;
    padding: 3px 10px; border-radius: 6px;
    font-size: .82rem; font-weight: 600; color: #555;
    transition: all .15s;
}
.tp-lang-btn:hover { background: #fff; color: #2271b1; }
.tp-lang-btn.tp-lang-active { background: #2271b1; color: #fff; }

/* ── Header nav ────────────────────────────────────────────────── */
.tp-header-nav { display: flex; align-items: center; gap: 8px; margin-left: 8px; flex-shrink: 0; }
.tp-header-user { display: flex; align-items: center; gap: 8px; }
.tp-header-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: #2271b1; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem;
}
.tp-header-username { font-size: .85rem; font-weight: 600; color: #333; }
.tp-header-logout { font-size: .78rem; color: #e5534b; font-weight: 600; }
.tp-header-login-btn, .tp-header-register-btn {
    padding: 6px 14px; border-radius: 8px;
    font-size: .85rem; font-weight: 600;
    text-decoration: none; transition: all .15s;
}
.tp-header-login-btn { border: 1.5px solid #2271b1; color: #2271b1; }
.tp-header-login-btn:hover { background: #f0f6ff; }
.tp-header-register-btn { background: #2271b1; color: #fff; }
.tp-header-register-btn:hover { background: #1a5fa3; text-decoration: none; }

/* ── App layout ────────────────────────────────────────────────── */
.tp-app {
    flex: 1; display: grid;
    grid-template-columns: 220px 1fr 260px;
    gap: 0;
    max-width: 1280px; margin: 0 auto; width: 100%;
    padding: 20px 12px;
    align-items: start;
}

/* ── Sidebars ──────────────────────────────────────────────────── */
.tp-sidebar {
    background: #fff; border-radius: 12px;
    border: 1px solid #e4e6eb;
    padding: 12px 0;
    position: sticky; top: 72px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}
.tp-sidebar-left  { margin-right: 12px; }
.tp-sidebar-right { margin-left: 12px; }
.tp-sidebar-divider { border: none; border-top: 1px solid #e4e6eb; margin: 8px 12px; }

.tp-sidebar-label {
    font-size: .7rem; font-weight: 700; color: #888; letter-spacing: .08em;
    text-transform: uppercase; padding: 6px 16px 4px;
}
.tp-sidebar-item {
    padding: 9px 16px; font-size: .9rem; cursor: pointer;
    transition: background .12s, color .12s; color: #333;
    border-radius: 0; display: flex; align-items: center; gap: 6px;
}
.tp-sidebar-item:hover  { background: #f0f6ff; color: #2271b1; }
.tp-sidebar-item.tp-active { background: #e6f0fa; color: #2271b1; font-weight: 700; }
.tp-sidebar-item.tp-lang-subject { font-style: italic; }
.tp-sidebar-item.tp-muted { color: #aaa; font-size: .82rem; cursor: default; }
.tp-sched-dot    { color: #30a84b; font-size: .6rem; line-height: 1; }
.tp-sched-dot-sm { color: #f5a623; font-size: .55rem; }

/* ── Main feed ──────────────────────────────────────────────────── */
.tp-main { min-width: 0; }
.tp-feed-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px; padding: 0 2px;
}
.tp-feed-title { font-size: 1rem; font-weight: 700; color: #1c1e21; }
.tp-feed-count  { font-size: .78rem; color: #888; }

/* ── Poll card ──────────────────────────────────────────────────── */
.tp-poll {
    background: #fff; border-radius: 12px;
    border: 1px solid #e4e6eb; padding: 18px 20px;
    margin-bottom: 12px; transition: box-shadow .15s;
}
.tp-poll:hover { box-shadow: 0 2px 8px rgba(0,0,0,.06); }

.tp-poll-meta-top {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    margin-bottom: 10px;
}
.tp-poll-subject {
    font-size: .72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: #2271b1; background: #e6f0fa;
    padding: 2px 7px; border-radius: 4px;
}
.tp-poll-topic {
    font-size: .72rem; color: #555; background: #f0f2f5;
    padding: 2px 7px; border-radius: 4px;
}
.tp-poll-lang {
    font-size: .68rem; font-weight: 700; padding: 2px 7px; border-radius: 4px;
}
.tp-poll-lang-en { background: #e8f5e9; color: #2e7d32; }
.tp-poll-lang-hi { background: #fff3e0; color: #e65100; }

.tp-poll-time {
    font-size: .7rem; color: #888; margin-left: auto;
}

.tp-poll-question {
    font-size: 1rem; font-weight: 600; line-height: 1.55;
    color: #1c1e21; margin-bottom: 14px;
}

/* ── Options ────────────────────────────────────────────────────── */
.tp-poll-options { display: flex; flex-direction: column; gap: 8px; }
.tp-option {
    border: 1.5px solid #e4e6eb; border-radius: 8px;
    cursor: pointer; overflow: hidden; transition: border-color .15s, background .1s;
    position: relative;
}
.tp-option:hover { border-color: #2271b1; background: #f5f9ff; }
.tp-option-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; position: relative; z-index: 1;
}
.tp-check {
    width: 22px; height: 22px; border-radius: 50%;
    border: 1.5px solid #d0d3d9; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: .75rem; font-weight: 700; transition: all .15s;
}
.tp-option-text { flex: 1; font-size: .92rem; line-height: 1.4; }
.tp-percent { font-size: .78rem; color: #888; font-weight: 600; min-width: 32px; text-align: right; }

.tp-track { height: 4px; background: #f0f2f5; overflow: hidden; }
.tp-fill  { height: 100%; background: #c9daf8; transition: width .4s ease; width: 0; }

/* Answered states */
.tp-option.tp-answered { cursor: default; }
.tp-option.tp-correct  { border-color: #30a84b; background: #f0fff4; }
.tp-option.tp-correct .tp-fill  { background: #a8e6b5; }
.tp-option.tp-correct .tp-check { border-color: #30a84b; background: #30a84b; color: #fff; font-size: .8rem; }
.tp-option.tp-wrong    { border-color: #e5534b; background: #fff5f5; }
.tp-option.tp-wrong .tp-fill  { background: #ffc9c9; }
.tp-option.tp-wrong .tp-check { border-color: #e5534b; background: #e5534b; color: #fff; font-size: .8rem; }
.tp-option.tp-selected:not(.tp-correct):not(.tp-wrong) { border-color: #2271b1; }

/* ── Poll footer ────────────────────────────────────────────────── */
.tp-poll-footer {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 12px; padding-top: 10px; border-top: 1px solid #f0f2f5;
    flex-wrap: wrap; gap: 8px;
}
.tp-votes-count { font-size: .78rem; color: #8a8d91; }

/* ── Reactions ──────────────────────────────────────────────────── */
.tp-reactions { display: flex; align-items: center; gap: 6px; }
.tp-reaction-btn {
    display: flex; align-items: center; gap: 4px;
    border: 1.5px solid #e4e6eb; border-radius: 20px;
    padding: 4px 10px; background: #f9fafb; cursor: pointer;
    font-size: .8rem; transition: all .15s; color: #555;
}
.tp-reaction-btn:hover { border-color: #2271b1; background: #f0f6ff; }
.tp-reaction-btn.tp-reacted { border-color: #2271b1; background: #e6f0fa; font-weight: 700; color: #2271b1; }
.tp-reaction-emoji { font-size: 1rem; line-height: 1; }
.tp-reaction-count { font-size: .75rem; font-weight: 600; }

/* ── Spinner ─────────────────────────────────────────────────────── */
.tp-spinner {
    display: flex; justify-content: center; padding: 32px;
}
.tp-spinner-ring {
    width: 36px; height: 36px; border-radius: 50%;
    border: 3px solid #e4e6eb;
    border-top-color: #2271b1;
    animation: tp-spin .7s linear infinite;
}
@keyframes tp-spin { to { transform: rotate(360deg); } }

/* ── Empty feed ──────────────────────────────────────────────────── */
.tp-empty-feed {
    text-align: center; padding: 48px 20px; color: #8a8d91;
    background: #fff; border-radius: 12px; border: 1px solid #e4e6eb;
}
.tp-empty-feed p { font-size: .95rem; }

/* ── Load more ───────────────────────────────────────────────────── */
.tp-load-more-wrap { display: flex; justify-content: center; margin-top: 8px; }
.tp-load-more-btn {
    border: 1.5px solid #2271b1; background: #fff; color: #2271b1;
    border-radius: 8px; padding: 10px 28px; font-size: .9rem; font-weight: 600;
    cursor: pointer; transition: all .15s;
}
.tp-load-more-btn:hover { background: #2271b1; color: #fff; }

/* ── User profile widget ─────────────────────────────────────────── */
.tp-user-profile {
    padding: 12px 16px 16px;
}
.tp-profile-avatar {
    width: 48px; height: 48px; border-radius: 50%;
    background: linear-gradient(135deg, #2271b1, #0ea5e9);
    color: #fff; font-size: 1.3rem; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    margin: 8px auto 10px;
}
.tp-profile-name {
    font-weight: 700; font-size: .95rem; color: #1c1e21; text-align: center;
    margin-bottom: 4px;
}
.tp-profile-meta { font-size: .75rem; color: #888; text-align: center; margin-bottom: 2px; }
.tp-profile-stats {
    display: flex; justify-content: space-around;
    margin: 12px 0; padding: 10px 0;
    border-top: 1px solid #f0f2f5; border-bottom: 1px solid #f0f2f5;
}
.tp-profile-stat { text-align: center; }
.tp-stat-val { display: block; font-size: 1.1rem; font-weight: 800; color: #1c1e21; }
.tp-correct-val { color: #30a84b; }
.tp-stat-lbl { display: block; font-size: .68rem; color: #8a8d91; text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }
.tp-profile-logout {
    display: block; text-align: center; font-size: .78rem; color: #e5534b;
    margin-top: 10px; font-weight: 600;
}

.tp-profile-guest {
    padding: 12px 16px;
    display: flex; flex-direction: column; gap: 8px;
}
.tp-profile-login-btn, .tp-profile-register-btn {
    display: block; text-align: center; padding: 8px 12px;
    border-radius: 8px; font-size: .85rem; font-weight: 600;
    text-decoration: none; transition: all .15s;
}
.tp-profile-login-btn    { border: 1.5px solid #2271b1; color: #2271b1; }
.tp-profile-login-btn:hover { background: #f0f6ff; text-decoration: none; }
.tp-profile-register-btn { background: #2271b1; color: #fff; }
.tp-profile-register-btn:hover { background: #1a5fa3; text-decoration: none; }

/* ── Auth pages (login / register) ──────────────────────────────── */
.tp-auth-page {
    flex: 1; display: flex; align-items: flex-start; justify-content: center;
    padding: 40px 16px;
    background: linear-gradient(135deg, #e6f0fa 0%, #f0f2f5 60%);
    min-height: calc(100vh - 56px);
}
.tp-auth-card {
    background: #fff; border-radius: 16px; border: 1px solid #e4e6eb;
    padding: 36px 32px; width: 100%; max-width: 440px;
    box-shadow: 0 4px 24px rgba(0,0,0,.07);
}
.tp-auth-card-wide { max-width: 620px; }

.tp-auth-logo {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    font-size: 1.4rem; font-weight: 800; color: #2271b1; margin-bottom: 20px;
}
.tp-auth-title {
    font-size: 1.5rem; font-weight: 800; color: #1c1e21; text-align: center; margin-bottom: 6px;
}
.tp-auth-subtitle {
    font-size: .9rem; color: #6c757d; text-align: center; margin-bottom: 24px;
}
.tp-auth-error {
    background: #fff5f5; border: 1px solid #ffc9c9; color: #c62828;
    border-radius: 8px; padding: 12px 14px; margin-bottom: 18px;
    font-size: .88rem; display: flex; align-items: flex-start; gap: 8px;
}
.tp-auth-error-icon { flex-shrink: 0; }

.tp-auth-form { display: flex; flex-direction: column; gap: 16px; }

.tp-form-row {
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.tp-form-group { display: flex; flex-direction: column; gap: 5px; }
.tp-form-label { font-size: .85rem; font-weight: 600; color: #444; }
.tp-required { color: #e5534b; }

.tp-form-input {
    width: 100%; padding: 10px 14px;
    border: 1.5px solid #d0d3d9; border-radius: 8px;
    font-size: .95rem; color: #1c1e21; background: #fff;
    transition: border-color .15s, box-shadow .15s;
    appearance: none; -webkit-appearance: none;
}
.tp-form-input:focus {
    outline: none; border-color: #2271b1;
    box-shadow: 0 0 0 3px rgba(34,113,177,.15);
}
.tp-form-select { cursor: pointer; }
.tp-form-hint { font-size: .75rem; color: #8a8d91; line-height: 1.3; }

.tp-auth-submit-btn {
    width: 100%; padding: 13px 20px;
    background: linear-gradient(135deg, #2271b1, #1a5fa3);
    color: #fff; border: none; border-radius: 10px;
    font-size: 1rem; font-weight: 700; cursor: pointer;
    transition: all .2s; box-shadow: 0 2px 8px rgba(34,113,177,.25);
    margin-top: 4px;
}
.tp-auth-submit-btn:hover {
    background: linear-gradient(135deg, #1a5fa3, #145090);
    box-shadow: 0 4px 12px rgba(34,113,177,.35);
    transform: translateY(-1px);
}
.tp-auth-submit-btn:active { transform: none; }

.tp-auth-footer { text-align: center; margin-top: 18px; font-size: .88rem; color: #555; }
.tp-auth-footer a { color: #2271b1; font-weight: 600; }

.tp-auth-note {
    margin-top: 16px; padding: 12px 14px;
    background: #f0f6ff; border-radius: 8px;
    font-size: .8rem; color: #444; line-height: 1.5;
}

/* ── Footer ──────────────────────────────────────────────────────── */
.tp-footer {
    background: #1c1e21; color: #aaa; padding: 24px 16px;
    margin-top: auto; text-align: center;
}
.tp-footer-inner { max-width: 1280px; margin: 0 auto; }
.tp-footer-logo { font-size: 1rem; font-weight: 700; color: #fff; margin-bottom: 6px; }
.tp-footer-tagline { font-size: .8rem; margin-bottom: 4px; }
.tp-footer-copy { font-size: .75rem; color: #666; }

/* ── Mobile bar ──────────────────────────────────────────────────── */
.tp-mobile-subject-bar { display: none; align-items: center; gap: 10px; margin-bottom: 12px; }
.tp-mobile-menu-btn {
    border: 1.5px solid #e4e6eb; background: #fff; border-radius: 8px;
    padding: 6px 12px; font-size: .85rem; cursor: pointer; flex-shrink: 0;
    font-weight: 600; color: #333;
}
.tp-mobile-topic-name { font-size: .85rem; color: #555; font-weight: 600; }
.tp-mobile-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200;
}

/* ── Generic page content ────────────────────────────────────────── */
.tp-page-content { line-height: 1.7; color: #333; margin-top: 16px; }
.tp-page-content h2 { margin: 20px 0 10px; }
.tp-page-content p  { margin-bottom: 12px; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 1100px) {
    .tp-app { grid-template-columns: 200px 1fr 240px; }
}

@media (max-width: 880px) {
    .tp-app { grid-template-columns: 1fr; padding: 12px; }

    .tp-sidebar-left {
        position: fixed; left: -240px; top: 56px; bottom: 0;
        width: 240px; z-index: 210; border-radius: 0;
        transition: left .25s ease; box-shadow: 2px 0 12px rgba(0,0,0,.12);
        max-height: none; overflow-y: auto;
    }
    .tp-sidebar-left.open { left: 0; }

    .tp-mobile-subject-bar { display: flex; }
    .tp-mobile-overlay.show { display: block; }

    .tp-sidebar-right {
        display: none;
    }

    .tp-lang-bar { display: none !important; }
}

@media (max-width: 520px) {
    .tp-header-inner { padding: 0 10px; }
    .tp-logo-name { display: none; }
    .tp-header-username { display: none; }
    .tp-auth-card { padding: 24px 18px; }
    .tp-form-row { grid-template-columns: 1fr; }
    .tp-poll { padding: 14px 14px; }
    .tp-header-register-btn { display: none; }
}
