/* ===== سیستم اطلاع‌رسانی - رابط RTL فارسی ===== */
:root {
    --bg: #0b0e12;
    --bg-card: #151b24;
    --bg-input: #1c242e;
    --border: #2a3544;
    --text: #e8eaed;
    --text-muted: #9aa0a6;
    --primary: #2d8ef0;
    --primary-hover: #2470c9;
    --success: #22c58b;
    --danger: #ea4335;
    --radius: 14px;
    --shadow: 0 8px 32px rgba(0,0,0,.35);
    --font: 'Vazirmatn', 'Vazir', 'Tahoma', sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    direction: rtl;
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

a {
    color: var(--primary);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ----- Header ----- */
.site-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
}
.site-header .inner {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.site-header .brand {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text);
}
.site-header nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.site-header nav a {
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.site-header nav a:hover {
    background: var(--bg-input);
    color: var(--text);
    text-decoration: none;
}
.site-header nav a.active {
    color: var(--primary);
}
.site-header .header-username {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-left: 0.5rem;
}
.site-header .header-username::before {
    content: 'سلام، ';
    color: var(--text-muted);
}
.site-header .header-username::after {
    content: ' |';
    color: var(--border);
}
.site-header nav a:first-of-type {
    margin-right: 0.25rem;
}

/* ----- Cards ----- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.card h1, .card h2, .card h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

/* ----- Forms ----- */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}
input[type="text"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(29,155,240,.2);
}
textarea {
    min-height: 120px;
    resize: vertical;
}

/* ----- Buttons ----- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.1rem;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background .15s, transform .1s;
}
.btn:active {
    transform: scale(0.98);
}
.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-hover);
    text-decoration: none;
}
.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--border);
    text-decoration: none;
}
.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
}

/* ----- Alerts ----- */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}
.alert-error {
    background: rgba(244,33,46,.15);
    border: 1px solid var(--danger);
    color: #ff6b6b;
}
.alert-success {
    background: rgba(0,186,124,.15);
    border: 1px solid var(--success);
    color: #34d399;
}

/* ----- List ----- */
.channel-list, .user-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.channel-list li, .user-list li {
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.channel-list li:last-child, .user-list li:last-child {
    border-bottom: none;
}
.channel-list a, .user-list a {
    flex: 1;
    color: var(--text);
    font-weight: 500;
}
.channel-list a:hover, .user-list a:hover {
    color: var(--primary);
    text-decoration: none;
}

/* ----- Posts ----- */
.post {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
}
.post-content {
    white-space: pre-wrap;
    word-wrap: break-word;
    margin-bottom: 0.5rem;
    line-height: 1.7;
}
.post-content a.post-link {
    color: #1d9bf0;
    text-decoration: underline;
    word-break: break-all;
}
.post-content a.post-link:hover {
    color: #71c9f8;
}
.post-content strong {
    font-weight: 700;
}
.post-content em {
    font-style: italic;
}
.post-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.post-actions {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
}
.post-actions .btn {
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
}

/* ----- Auth (Login / Register) ----- */
.auth-wrap {
    min-height: calc(100vh - 70px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.auth-card, .login-card {
    width: 100%;
    max-width: 420px;
}
.auth-card .card, .login-card .card { margin-bottom: 0; }
.auth-switch {
    text-align: center;
    margin-top: 1.25rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}
.auth-switch a { font-weight: 500; }
.btn-block { width: 100%; }
.required { color: var(--danger); }
.input-readonly {
    background: var(--bg) !important;
    cursor: not-allowed;
    opacity: .9;
}
.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 1.5rem;
}
.form-inline .form-group { margin-bottom: 0; }
.form-inline .form-group label { margin-bottom: 0.25rem; }
.login-wrap {
    min-height: calc(100vh - 60px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.login-card {
    width: 100%;
    max-width: 380px;
}

/* ----- Empty state ----- */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}
.empty-state .icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    opacity: .6;
}

/* ----- Admin grid ----- */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
.admin-grid a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-weight: 500;
    transition: border-color .15s, background .15s;
}
.admin-grid a:hover {
    border-color: var(--primary);
    background: var(--bg-card);
    text-decoration: none;
}
.admin-grid a .icon {
    font-size: 1.5rem;
}

/* ----- Assign row ----- */
.assign-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}
.assign-row:last-child {
    border-bottom: none;
}
.assign-row .username {
    min-width: 120px;
    font-weight: 500;
}
.assign-row select {
    width: auto;
    min-width: 160px;
}
.assign-row .channels-have {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}
.channel-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--bg-input);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border);
}
.channel-tag .revoke-link {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 0 0.15rem;
}
.channel-tag .revoke-link:hover {
    color: var(--danger);
    text-decoration: none;
}
.form-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* ----- Back link ----- */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.back-link:hover {
    color: var(--primary);
    text-decoration: none;
}

/* ----- Pagination ----- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    padding: 0.4rem 0.65rem;
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.pagination a:hover {
    background: var(--bg-input);
    color: var(--primary);
    text-decoration: none;
}
.pagination .current {
    background: var(--primary);
    color: #fff;
}

/* ----- Tickets ----- */
.card-head-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.card-head-flex h2 { margin-bottom: 0; }
.ticket-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.ticket-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}
.ticket-list li:last-child { border-bottom: none; }
.ticket-link {
    flex: 1;
    color: var(--text);
    text-decoration: none;
}
.ticket-link:hover { color: var(--primary); text-decoration: none; }
.ticket-subject { display: block; font-weight: 600; margin-bottom: 0.2rem; }
.ticket-meta { font-size: 0.85rem; color: var(--text-muted); }
.ticket-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-weight: 500;
}
.ticket-status-open { background: rgba(34,197,94,.2); color: var(--success); }
.ticket-status-closed { background: var(--bg-input); color: var(--text-muted); }
.ticket-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.ticket-header h2 { margin: 0; }
.ticket-thread { margin: 1.5rem 0; }
.ticket-msg {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
}
.ticket-msg-user { background: var(--bg-input); margin-right: 0; margin-left: 2rem; }
.ticket-msg-admin { background: rgba(45,142,240,.12); border-color: rgba(45,142,240,.3); margin-left: 0; margin-right: 2rem; }
.ticket-msg-head { display: flex; justify-content: space-between; margin-bottom: 0.5rem; font-size: 0.85rem; }
.ticket-msg-who { font-weight: 600; color: var(--text-muted); }
.ticket-msg-date { color: var(--text-muted); }
.ticket-msg-body { line-height: 1.65; white-space: pre-wrap; word-wrap: break-word; }
.ticket-reply-form { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.text-muted { color: var(--text-muted); font-size: 0.9rem; }

/* ----- User table (admin) ----- */
.card-hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.user-table-wrap { overflow-x: auto; }
.user-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.user-table th, .user-table td { padding: 0.75rem 0.5rem; text-align: right; border-bottom: 1px solid var(--border); }
.user-table th { color: var(--text-muted); font-weight: 600; }
.badge-admin { background: var(--primary); color: #fff; padding: 0.15rem 0.5rem; border-radius: 6px; font-size: 0.75rem; }

/* ----- Footer ----- */
.site-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}
