@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700&display=swap');

:root {
    --bg: #0f172a;
    --bg-2: #111827;
    --surface: rgba(255, 255, 255, 0.05);
    --surface-strong: rgba(255, 255, 255, 0.09);
    --border: rgba(255, 255, 255, 0.1);
    --ink: #e5e7eb;
    --muted: #94a3b8;
    --primary: #6366f1;
    --primary-2: #8b5cf6;
    --danger: #ef4444;
    --ok: #22c55e;
    --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background: radial-gradient(1200px 600px at 20% -10%, rgba(99, 102, 241, 0.18), transparent),
                radial-gradient(1000px 500px at 100% 0%, rgba(139, 92, 246, 0.14), transparent),
                var(--bg);
    color: var(--ink);
    font-family: 'Vazirmatn', system-ui, sans-serif;
    direction: rtl;
}

a { color: inherit; }

.wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin-bottom: 28px;
}

.brand .dot {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    flex-shrink: 0;
}

.brand span {
    font-weight: 700;
    font-size: 1.15rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(16px) saturate(160%);
    padding: 26px;
}

.login-grid {
    width: 100%;
    max-width: 860px;
}

.login-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

@media (max-width: 720px) {
    .login-cards { grid-template-columns: 1fr; }
}

.login-cards h2 {
    margin: 0 0 4px;
    font-size: 1.05rem;
}

.login-cards p.hint {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 0.85rem;
}

label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 6px;
}

input[type=text], input[type=password] {
    width: 100%;
    padding: 11px 13px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
    color: var(--ink);
    font-family: inherit;
    font-size: 0.95rem;
    margin-bottom: 14px;
}

input:focus { outline: 2px solid var(--primary); }

button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: 10px;
    padding: 11px 18px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    width: 100%;
}

.btn-ghost {
    background: var(--surface-strong);
    color: var(--ink);
    width: auto;
}

.btn-danger { background: var(--danger); width: auto; }

.error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.divider-v {
    display: none;
}

/* Chat layout */
.chat-shell {
    max-width: 760px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.chat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 4px 16px;
}

.chat-top .who {
    font-size: 0.85rem;
    color: var(--muted);
}

.chat-top .actions { display: flex; gap: 8px; }

.thread {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 6px 2px 20px;
}

.bubble {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.92rem;
    line-height: 1.6;
    word-break: break-word;
}

.bubble.mine {
    margin-right: auto;
    margin-left: 0;
    background: linear-gradient(135deg, rgba(99,102,241,0.35), rgba(139,92,246,0.28));
    border-color: rgba(139,92,246,0.4);
}

.bubble .meta {
    font-size: 0.72rem;
    color: var(--muted);
    margin-bottom: 4px;
}

.bubble .file {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    padding: 8px 10px;
    margin-top: 6px;
    text-decoration: none;
}

.bubble img.att {
    max-width: 100%;
    border-radius: 10px;
    margin-top: 6px;
    display: block;
}

.composer {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.composer textarea {
    flex: 1;
    resize: none;
    min-height: 44px;
    max-height: 140px;
    padding: 11px 13px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(0,0,0,0.2);
    color: var(--ink);
    font-family: inherit;
    font-size: 0.95rem;
}

.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--surface-strong);
    border: 1px solid var(--border);
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 1.1rem;
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    flex-shrink: 0;
    padding: 0;
}

.file-preview {
    display: none;
    align-items: center;
    gap: 8px;
    background: var(--surface-strong);
    border-radius: 10px;
    padding: 6px 10px;
    font-size: 0.8rem;
    margin-bottom: 8px;
    color: var(--muted);
}

.file-preview button {
    width: auto;
    padding: 2px 8px;
    background: var(--danger);
    font-size: 0.75rem;
}

/* Admin */
.admin-shell {
    max-width: 760px;
    margin: 0 auto;
    padding: 24px 16px 60px;
}

.key-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.key-row .label { font-weight: 600; }
.key-row .val { font-family: monospace; color: var(--muted); direction: ltr; }
.key-row .grow { flex: 1; }
.badge {
    font-size: 0.72rem;
    padding: 2px 9px;
    border-radius: 999px;
    background: rgba(34,197,94,0.15);
    color: #4ade80;
    border: 1px solid rgba(34,197,94,0.3);
}
.badge.off {
    background: rgba(239,68,68,0.12);
    color: #fca5a5;
    border-color: rgba(239,68,68,0.3);
}

.top-link {
    display: inline-block;
    margin-bottom: 18px;
    font-size: 0.85rem;
    color: var(--muted);
    text-decoration: none;
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 40px 10px;
    font-size: 0.9rem;
}

/* Pinned bar */
.pinned-bar {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.pinned-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 10px;
    padding: 7px 10px;
    font-size: 0.82rem;
    cursor: pointer;
}

.pinned-item .pi-label {
    font-weight: 600;
    flex-shrink: 0;
}

.pinned-item .pi-snippet {
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.pinned-item .pi-unpin {
    width: auto;
    background: transparent;
    color: var(--muted);
    padding: 2px 6px;
    flex-shrink: 0;
}

/* Reply quote inside a bubble */
.reply-quote {
    border-right: 3px solid var(--primary);
    padding: 4px 8px;
    margin-bottom: 6px;
    background: rgba(0, 0, 0, 0.18);
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.reply-quote .rq-label {
    font-weight: 600;
    color: var(--primary-2);
}

.reply-quote .rq-snippet {
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 260px;
}

/* Reactions */
.reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}

.reaction-pill {
    width: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 9px;
    font-size: 0.78rem;
    color: var(--ink);
}

.reaction-pill.active {
    background: rgba(99, 102, 241, 0.3);
    border-color: var(--primary);
}

.reaction-pill span {
    color: var(--muted);
    font-size: 0.72rem;
}

/* Bubble action row */
.bubble-actions {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.mini-btn {
    width: auto;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 8px;
}

.mini-btn.danger {
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.3);
}

.pin-flag {
    font-size: 0.72rem;
    color: var(--primary-2);
    margin-bottom: 3px;
    font-weight: 600;
}

.bubble.pinned {
    border-color: rgba(139, 92, 246, 0.5);
}

.bubble.flash {
    animation: flash-highlight 1.2s ease;
}

@keyframes flash-highlight {
    0% { background: rgba(99, 102, 241, 0.5); }
    100% { background: inherit; }
}

.deleted-text {
    color: var(--muted);
    font-style: italic;
}

/* Reply banner above composer */
.reply-banner {
    display: none;
    align-items: center;
    gap: 8px;
    background: var(--surface-strong);
    border-radius: 10px;
    padding: 8px 12px;
    margin-bottom: 8px;
    font-size: 0.82rem;
}

.reply-banner .rb-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
}

.reply-banner button {
    width: auto;
    background: transparent;
    color: var(--muted);
    padding: 2px 6px;
}

/* Reaction picker popup */
.react-popup {
    display: none;
    position: fixed;
    z-index: 50;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 8px;
    gap: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.react-opt {
    width: auto;
    background: transparent;
    font-size: 1.15rem;
    padding: 2px 5px;
    border-radius: 999px;
}

.react-opt:hover {
    background: rgba(255, 255, 255, 0.1);
}
