/* ================================================================
   استایل با سایدبار
   ================================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

body {
    background: #f1f5f9;
    direction: rtl;
    height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* سایدبار */
#sidebar {
    width: 260px;
    background: #ffffff;
    border-left: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    height: 100%;
    flex-shrink: 0;
    box-shadow: 2px 0 10px rgba(0,0,0,0.03);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid #e2e8f0;
}
.sidebar-header h2 {
    font-size: 20px;
    color: #0f172a;
    font-weight: 700;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 12px;
    overflow-y: auto;
}
.nav-item {
    display: block;
    padding: 12px 16px;
    border-radius: 12px;
    color: #334155;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.15s;
    margin-bottom: 4px;
}
.nav-item:hover {
    background: #f1f5f9;
    color: #0f172a;
}
.nav-item.active {
    background: #eef2ff;
    color: #4f46e5;
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid #e2e8f0;
}
.btn-logout-sidebar {
    width: 100%;
    padding: 12px;
    background: #fee2e2;
    color: #dc2626;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-logout-sidebar:hover {
    background: #fecaca;
}

/* محتوای اصلی */
#main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
    background: #f8fafc;
}

#page-container {
    max-width: 800px;
    margin: 0 auto;
}

/* صفحات */
.page {
    display: none;
}
.page.active {
    display: block;
}

/* حالت لاگین نشده (سایدبار مخفی) */
body:not(.logged-in) #sidebar {
    display: none;
}
body:not(.logged-in) #main-content {
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f8fafc;
}

/* صفحه لاگین */
.login-page {
    max-width: 400px;
    width: 100%;
    background: #fff;
    border-radius: 24px;
    padding: 32px 24px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.06);
}
.login-page h1 {
    text-align: center;
    margin-bottom: 6px;
}
.login-page .subtitle {
    text-align: center;
    color: #64748b;
    margin-bottom: 24px;
}
.form-group {
    margin-bottom: 18px;
}
.form-group label {
    display: block;
    font-weight: 500;
    font-size: 14px;
    color: #334155;
    margin-bottom: 5px;
}
.form-group input, .form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-size: 15px;
    background: #f8fafc;
    transition: border-color 0.2s;
}
.form-group input:focus, .form-group textarea:focus {
    outline: none;
    border-color: #4f46e5;
    background: #fff;
}
.btn-primary {
    width: 100%;
    padding: 14px;
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-primary:hover {
    background: #4338ca;
}
.error-msg {
    background: #fee2e2;
    color: #dc2626;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 16px;
    display: none;
}
.error-msg.show {
    display: block;
}

/* کارت‌ها */
.card {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.card .stat {
    font-size: 28px;
    font-weight: 700;
    color: #0f172a;
}

/* فرم تنظیمات */
.form-actions {
    margin-top: 20px;
}
.form-actions .btn-primary {
    width: auto;
    padding: 12px 32px;
}

/* جدول کاربران */
.table-wrap {
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
th, td {
    padding: 12px 16px;
    text-align: right;
    border-bottom: 1px solid #e2e8f0;
}
th {
    background: #f1f5f9;
    color: #475569;
    font-weight: 600;
}
tr:last-child td {
    border-bottom: none;
}

/* واکنش‌گرایی */
@media (max-width: 768px) {
    #sidebar {
        width: 200px;
    }
    #main-content {
        padding: 16px;
    }
}
@media (max-width: 576px) {
    #app {
        flex-direction: column;
    }
    #sidebar {
        width: 100%;
        height: auto;
        border-left: none;
        border-bottom: 1px solid #e2e8f0;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 8px 12px;
    }
    .sidebar-header, .sidebar-footer {
        display: none;
    }
    .sidebar-nav {
        display: flex;
        flex-wrap: wrap;
        padding: 4px 0;
        flex: 1;
    }
    .nav-item {
        padding: 8px 12px;
        margin: 2px;
        font-size: 14px;
    }
    #main-content {
        height: calc(100vh - 60px);
    }
}