/* Iran SQL Club - User Dashboard (Corporate RTL) */

:root {
    --sidebar-width: 280px;
    --sidebar-bg: #0f172a;
    --sidebar-bg-hover: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #f8fafc;
    --sidebar-accent: #3b82f6;
    --sidebar-border: rgba(148, 163, 184, 0.12);

    --page-bg: #f1f5f9;
    --surface: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --primary-soft: #eff6ff;

    --success-soft: #ecfdf5;
    --success: #059669;
    --warning-soft: #fffbeb;
    --warning: #d97706;
    --danger: #dc2626;
    --danger-soft: #fef2f2;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
    --header-h: 72px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body.dashboard-body {
    font-family: 'Vazirmatn', 'Tahoma', system-ui, sans-serif;
    background: var(--page-bg);
    color: var(--text);
    direction: rtl;
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--primary);
}

img {
    max-width: 100%;
    display: block;
}

/* Layout */
.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 199;
    opacity: 0;
    transition: opacity var(--transition);
    backdrop-filter: blur(2px);
}

body.sidebar-open .sidebar-backdrop {
    display: block;
    opacity: 1;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--sidebar-border);
    transition: transform var(--transition);
    overflow: hidden;
}

.sidebar-header {
    padding: 1.25rem 1.25rem 1rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-header .logo {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-decoration: none;
    color: inherit;
    flex: 1;
    min-width: 0;
}

.logo-mark {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #2563eb, #1e3a8a);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.logo-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.logo-text strong {
    font-size: 0.95rem;
    font-weight: 700;
    color: #f8fafc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logo-text small {
    font-size: 0.72rem;
    color: var(--sidebar-text);
    margin-top: 0.15rem;
}

.sidebar-close {
    display: none;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--sidebar-bg-hover);
    color: #e2e8f0;
    cursor: pointer;
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem 1.25rem;
    margin: 0.75rem 1rem 0;
    background: var(--sidebar-bg-hover);
    border-radius: var(--radius-md);
    border: 1px solid var(--sidebar-border);
}

.sidebar-user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    color: #e2e8f0;
    font-weight: 700;
}

.sidebar-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-user-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.sidebar-user-info strong {
    font-size: 0.88rem;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-info span {
    font-size: 0.72rem;
    color: var(--sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    padding: 0.75rem 0.75rem 0.35rem;
    margin: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.85rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    margin-bottom: 0.2rem;
    transition: background var(--transition), color var(--transition);
    border: none;
    width: 100%;
    cursor: pointer;
    font-family: inherit;
    background: transparent;
    text-align: right;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    opacity: 0.9;
}

.nav-item:hover {
    background: var(--sidebar-bg-hover);
    color: var(--sidebar-text-active);
}

.nav-item.active {
    background: rgba(59, 130, 246, 0.18);
    color: #fff;
}

.nav-item.active i {
    color: #60a5fa;
}

.nav-badge {
    margin-right: auto;
    background: var(--danger);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

.sidebar-footer {
    padding: 1rem 1.25rem 1.25rem;
    border-top: 1px solid var(--sidebar-border);
}

.btn-logout {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1rem;
    border: 1px solid rgba(248, 113, 113, 0.35);
    border-radius: var(--radius-sm);
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.22);
}

/* Main content */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    min-height: var(--header-h);
}

.top-bar-start {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
    flex: 1;
}

.menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
    font-size: 1.1rem;
}

.page-breadcrumb {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}

.page-title h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex-shrink: 0;
}

.user-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: left;
}

.user-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
}

.user-role {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    overflow: hidden;
    border: 2px solid var(--border);
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.content-area {
    padding: 1.5rem;
    flex: 1;
}

.messages-stack {
    margin-bottom: 1rem;
}

/* Welcome panel */
.welcome-panel {
    background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 55%, #2563eb 100%);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    color: #fff;
    box-shadow: var(--shadow-md);
}

.welcome-text h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.welcome-text p {
    font-size: 0.88rem;
    opacity: 0.9;
    max-width: 520px;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.quick-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    transition: background var(--transition);
}

.quick-action-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.quick-action-btn.primary {
    background: #fff;
    color: var(--primary);
    border-color: #fff;
}

.quick-action-btn.primary:hover {
    background: #f8fafc;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.15rem 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.stat-icon-wrap.blue {
    background: var(--primary-soft);
    color: var(--primary);
}

.stat-icon-wrap.green {
    background: var(--success-soft);
    color: var(--success);
}

.stat-icon-wrap.amber {
    background: var(--warning-soft);
    color: var(--warning);
}

.stat-icon-wrap.slate {
    background: #f1f5f9;
    color: #475569;
}

.stat-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stat-title {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.stat-number {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.1;
}

/* Data cards */
.two-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.data-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: #fafbfc;
}

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-header h3 i {
    color: var(--primary);
    font-size: 0.9rem;
}

.card-body {
    padding: 0.25rem 1.25rem 1rem;
}

.view-all {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
}

.view-all:hover {
    text-decoration: underline;
}

.item-row {
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
}

.item-row:last-child {
    border-bottom: none;
}

.item-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.item-title a {
    text-decoration: none;
    color: var(--text);
}

.item-title a:hover {
    color: var(--primary);
}

.item-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.empty-state {
    padding: 1.25rem 0;
    color: var(--text-muted);
    font-size: 0.88rem;
}

/* Forms */
.form-panel {
    max-width: 720px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 1.15rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    color: var(--text);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    font-family: inherit;
    transition: background var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-primary.block {
    width: 100%;
}

.btn-outline {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.88rem;
    color: var(--text);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: border-color var(--transition), background var(--transition);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.page-actions {
    margin-bottom: 1.25rem;
}

.page-actions .btn-primary {
    width: auto;
}

/* Alerts */
.alert {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.alert-success {
    background: var(--success-soft);
    color: #047857;
    border-right: 4px solid var(--success);
}

.alert-error {
    background: var(--danger-soft);
    color: #b91c1c;
    border-right: 4px solid var(--danger);
}

.alert-info {
    background: var(--primary-soft);
    color: #1e40af;
    border-right: 4px solid var(--primary);
}

.notification-banner .alert-link {
    font-weight: 700;
    color: inherit;
    margin-right: auto;
}

.badge {
    display: inline-block;
    font-size: 0.68rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-weight: 600;
}

.badge-new {
    background: var(--danger-soft);
    color: var(--danger);
}

.badge-pending {
    background: var(--warning-soft);
    color: var(--warning);
}

.badge-answered {
    background: var(--success-soft);
    color: var(--success);
}

.question-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.question-detail-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.question-block,
.answer-block {
    background: #f8fafc;
    border-radius: var(--radius-sm);
    padding: 1.1rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.question-block h3,
.answer-block h3 {
    font-size: 0.92rem;
    margin-bottom: 0.65rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.answer-block {
    background: var(--success-soft);
    border-color: #a7f3d0;
}

/* Auth pages (login/register) */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--page-bg);
    padding: 1rem;
}

.auth-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    max-width: 500px;
    width: 100%;
    border: 1px solid var(--border);
}

.auth-card h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.auth-footer {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.88rem;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1023px) {
    .sidebar {
        transform: translateX(100%);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-close {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .main-content {
        margin-right: 0;
    }

    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .user-meta {
        display: none;
    }
}

@media (max-width: 768px) {
    .content-area {
        padding: 1rem;
    }

    .top-bar {
        padding: 0.75rem 1rem;
    }

    .page-title h1 {
        font-size: 1.05rem;
    }

    .page-breadcrumb {
        display: none;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .two-columns {
        grid-template-columns: 1fr;
    }

    .welcome-panel {
        padding: 1.25rem;
    }

    .welcome-text h2 {
        font-size: 1.05rem;
    }

    .quick-actions {
        width: 100%;
    }

    .quick-action-btn {
        flex: 1;
        justify-content: center;
        min-width: calc(50% - 0.35rem);
    }
}

@media (max-width: 480px) {
    .quick-action-btn {
        min-width: 100%;
    }

    .stat-card-inner {
        gap: 0.75rem;
    }

    .stat-number {
        font-size: 1.4rem;
    }
}

/* Admin consultation management */
.admin-panel-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px dashed var(--border);
}

.admin-panel-header {
    margin-bottom: 1.25rem;
}

.admin-panel-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.admin-panel-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.admin-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.9rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.86rem;
    transition: border-color var(--transition), color var(--transition), background var(--transition);
}

.filter-tab:hover,
.filter-tab.active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
}

.filter-count {
    background: #e2e8f0;
    color: var(--text);
    border-radius: 999px;
    padding: 0.05rem 0.45rem;
    font-size: 0.72rem;
    font-weight: 700;
}

.filter-tab.active .filter-count {
    background: var(--primary);
    color: #fff;
}

.admin-search-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.admin-search-form input[type="search"] {
    min-width: 240px;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.88rem;
}

.consultation-table-wrap {
    overflow-x: auto;
}

.consultation-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.consultation-table th,
.consultation-table td {
    padding: 0.85rem 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: right;
    vertical-align: top;
}

.consultation-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    background: #f8fafc;
}

.consultation-table tbody tr:hover {
    background: #f8fafc;
}

.table-sub {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 0.15rem;
}

.btn-sm {
    padding: 0.45rem 0.85rem;
    font-size: 0.8rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.detail-item {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
}

.detail-item-full {
    grid-column: 1 / -1;
}

.detail-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-bottom: 0.25rem;
}

.detail-value {
    font-weight: 600;
    font-size: 0.92rem;
    word-break: break-word;
}

.detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-top: 1.5rem;
}

@media (max-width: 768px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .admin-search-form input[type="search"] {
        min-width: 100%;
    }
}

.admin-charts-grid .data-card {
    min-height: 360px;
}

.chart-wrap {
    position: relative;
    height: 280px;
}

.poll-table-wrap {
    overflow-x: auto;
}

.poll-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.poll-table th,
.poll-table td {
    padding: 0.75rem 0.65rem;
    border-bottom: 1px solid var(--border);
    text-align: right;
    vertical-align: top;
}

.poll-table th {
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.8rem;
}

.poll-table tbody tr:hover {
    background: #f8fafc;
}
