/* ═══════════════════════════════════════════
   Variables — از themeParams پر می‌شن
   ═══════════════════════════════════════════ */
:root {
    --bg: var(--splus-bg, #ffffff);
    --text: var(--splus-text, #000000);
    --hint: var(--splus-hint, #707579);
    --link: var(--splus-link, #2481cc);
    --button: var(--splus-button, #2481cc);
    --button-text: var(--splus-button-text, #ffffff);
    --secondary-bg: var(--splus-secondary-bg, #f4f4f5);
    --header-bg: var(--splus-header-bg, #ffffff);
    --accent: var(--splus-accent, #2481cc);
    --destructive: var(--splus-destructive, #e53935);
    --separator: var(--splus-separator, rgba(0,0,0,0.08));
    --section-bg: var(--splus-section-bg, #ffffff);
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);
}

/* حالت dark */
body.dark {
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.4);
    --separator: rgba(255,255,255,0.08);
}

/* ═══════════════════════════════════════════
   Reset
   ═══════════════════════════════════════════ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Vazir', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
    direction: rtl;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    font-size: inherit;
}

.hidden { display: none !important; }

/* ═══════════════════════════════════════════
   Loading / Error
   ═══════════════════════════════════════════ */
.loading-screen, .error-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 40px 20px;
    text-align: center;
    background: var(--bg);
    z-index: 999;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--separator);
    border-top-color: var(--button);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-icon { font-size: 48px; }
.error-screen button {
    padding: 12px 28px;
    background: var(--button);
    color: var(--button-text);
    border-radius: var(--radius-sm);
    font-weight: 600;
    margin-top: 10px;
}

/* ═══════════════════════════════════════════
   App Layout
   ═══════════════════════════════════════════ */
#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

.app-header {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--separator);
    z-index: 100;
    min-height: 56px;
}

.header-title {
    flex: 1;
    font-size: 17px;
    font-weight: 600;
    text-align: center;
    padding: 0 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-spacer {
    width: 40px;
    flex-shrink: 0;
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text);
    transition: background 0.15s;
    flex-shrink: 0;
}

.icon-btn:active {
    background: var(--secondary-bg);
}

.app-content {
    flex: 1;
    padding: 16px;
    padding-bottom: 100px;
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
}

/* ═══════════════════════════════════════════
   User Hero
   ═══════════════════════════════════════════ */
.user-hero {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px;
    background: var(--secondary-bg);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.user-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--button);
    color: var(--button-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
    flex-shrink: 0;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-info { flex: 1; min-width: 0; }
.user-name {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-username {
    font-size: 13px;
    color: var(--hint);
    direction: ltr;
    text-align: right;
}

/* ═══════════════════════════════════════════
   Tabs
   ═══════════════════════════════════════════ */
.tabs {
    display: flex;
    background: var(--secondary-bg);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 20px;
    gap: 4px;
}

.tab {
    flex: 1;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--hint);
    text-align: center;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab.active {
    background: var(--section-bg);
    color: var(--text);
    box-shadow: var(--shadow);
}

/* ═══════════════════════════════════════════
   Cards / Lists
   ═══════════════════════════════════════════ */
.section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--hint);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 20px 0 12px;
}

.channel-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--section-bg);
    border: 1px solid var(--separator);
    border-radius: var(--radius);
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
    text-align: right;
}

.channel-card:active {
    transform: scale(0.98);
    background: var(--secondary-bg);
}

.channel-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--button), var(--accent));
    color: var(--button-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.channel-info { flex: 1; min-width: 0; }
.channel-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.channel-meta {
    font-size: 12px;
    color: var(--hint);
    direction: ltr;
    text-align: right;
}
.channel-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--button);
    color: var(--button-text);
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    margin-inline-start: 8px;
    vertical-align: middle;
}

/* ═══════════════════════════════════════════
   Post Card
   ═══════════════════════════════════════════ */
.post-card {
    padding: 16px;
    background: var(--section-bg);
    border: 1px solid var(--separator);
    border-radius: var(--radius);
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
    text-align: right;
}

.post-card:active {
    transform: scale(0.98);
    background: var(--secondary-bg);
}

.post-text {
    font-size: 15px;
    line-height: 1.7;
    margin-bottom: 12px;
    white-space: pre-wrap;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-media {
    width: 100%;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    max-height: 300px;
    object-fit: cover;
}

.post-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--hint);
}

.post-comments-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--button);
    font-weight: 600;
}

/* ═══════════════════════════════════════════
   Comments
   ═══════════════════════════════════════════ */
.comment {
    padding: 14px;
    background: var(--section-bg);
    border: 1px solid var(--separator);
    border-radius: var(--radius);
    margin-bottom: 10px;
}

.comment-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.comment-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--button);
    color: var(--button-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.comment-author {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.comment-time {
    font-size: 11px;
    color: var(--hint);
    direction: ltr;
}

.comment-text {
    font-size: 15px;
    line-height: 1.7;
    margin-bottom: 10px;
    white-space: pre-wrap;
    word-break: break-word;
}

.comment-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.reactions-bar {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.reaction-btn {
    padding: 5px 10px;
    border-radius: 20px;
    background: var(--secondary-bg);
    border: 1px solid var(--separator);
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transition: all 0.15s;
    line-height: 1;
}

.reaction-btn:active { transform: scale(0.92); }

.reaction-btn.active {
    background: var(--button);
    color: var(--button-text);
    border-color: var(--button);
}

.reaction-count {
    font-size: 11px;
    font-weight: 700;
}

.action-btn {
    padding: 5px 10px;
    border-radius: 20px;
    background: transparent;
    border: 1px solid var(--separator);
    font-size: 12px;
    color: var(--hint);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
}

.action-btn:active { background: var(--secondary-bg); }

.action-btn.danger {
    color: var(--destructive);
    border-color: var(--destructive);
}

/* ═══════════════════════════════════════════
   Replies
   ═══════════════════════════════════════════ */
.replies {
    margin-top: 10px;
    padding-right: 16px;
    border-right: 2px solid var(--separator);
}

.reply {
    padding: 10px 12px;
    background: var(--secondary-bg);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
}

.reply:last-child { margin-bottom: 0; }

.reply-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.reply-author {
    font-size: 13px;
    font-weight: 600;
    color: var(--button);
}

.reply-time {
    font-size: 10px;
    color: var(--hint);
    direction: ltr;
}

.reply-text {
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ═══════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════ */
.btn-primary {
    display: block;
    width: 100%;
    padding: 14px 20px;
    background: var(--button);
    color: var(--button-text);
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 15px;
    text-align: center;
    transition: all 0.15s;
    margin: 16px 0;
}

.btn-primary:active { transform: scale(0.98); opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
    display: block;
    width: 100%;
    padding: 14px 20px;
    background: var(--secondary-bg);
    color: var(--text);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 15px;
    text-align: center;
    margin: 8px 0;
}

/* ═══════════════════════════════════════════
   Modals
   ═══════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 500;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn { from { opacity: 0; } }

.modal {
    width: 100%;
    max-width: 600px;
    background: var(--bg);
    border-radius: 20px 20px 0 0;
    padding: 20px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
}

.modal-handle {
    width: 40px;
    height: 4px;
    background: var(--separator);
    border-radius: 2px;
    margin: 0 auto 16px;
}

.modal-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 16px;
    text-align: center;
}

.modal textarea {
    width: 100%;
    min-height: 120px;
    padding: 14px;
    background: var(--secondary-bg);
    border: 1px solid var(--separator);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 15px;
    resize: vertical;
    line-height: 1.6;
}

.modal textarea:focus {
    outline: none;
    border-color: var(--button);
}

.char-count {
    font-size: 12px;
    color: var(--hint);
    text-align: left;
    margin-top: 6px;
    direction: ltr;
}

.char-count.warning { color: var(--destructive); }

/* ═══════════════════════════════════════════
   Empty / Loading states
   ═══════════════════════════════════════════ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--hint);
}

.empty-icon {
    font-size: 56px;
    display: block;
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-state p { font-size: 15px; }

.inline-loader {
    text-align: center;
    padding: 30px;
    color: var(--hint);
}

.inline-loader .spinner {
    width: 28px;
    height: 28px;
    margin: 0 auto 12px;
}

/* ═══════════════════════════════════════════
   Toast
   ═══════════════════════════════════════════ */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.85);
    color: white;
    padding: 12px 20px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    animation: toastIn 0.3s;
    max-width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
}

/* ═══════════════════════════════════════════
   Pagination
   ═══════════════════════════════════════════ */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 20px 0;
}

.page-btn {
    padding: 10px 18px;
    background: var(--secondary-bg);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    transition: all 0.15s;
}

.page-btn:active { transform: scale(0.95); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.page-info {
    font-size: 13px;
    color: var(--hint);
    direction: ltr;
    font-weight: 600;
}

/* ═══════════════════════════════════════════
   Stats Grid (Admin)
   ═══════════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 16px 0;
}

.stat-card {
    padding: 16px 12px;
    background: var(--section-bg);
    border: 1px solid var(--separator);
    border-radius: var(--radius);
    text-align: center;
}

.stat-num {
    font-size: 24px;
    font-weight: 800;
    color: var(--button);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 11px;
    color: var(--hint);
    font-weight: 600;
}

/* ═══════════════════════════════════════════
   Blocked User Card
   ═══════════════════════════════════════════ */
.blocked-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--section-bg);
    border: 1px solid var(--separator);
    border-radius: var(--radius);
    margin-bottom: 10px;
}

.blocked-info { flex: 1; min-width: 0; }
.blocked-id {
    font-size: 13px;
    font-weight: 600;
    direction: ltr;
    text-align: right;
    color: var(--text);
}
.blocked-date {
    font-size: 11px;
    color: var(--hint);
    margin-top: 2px;
    direction: ltr;
    text-align: right;
}

/* ═══════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════ */
@media (min-width: 600px) {
    .app-content { padding: 20px 24px 100px; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
}