/* =========================================
   1. VARIABLES & RESET
   ========================================= */
@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');

:root {
    /* پالت رنگی */
    --bg-body: #0f172a;
    --bg-sidebar: #020617;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --primary: #6366f1;
    --primary-glow: #818cf8;
    --primary-dark: #4f46e5;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --radius: 16px;
    --header-height: 70px;
    --sidebar-width: 260px;
    /* رنگ‌های وضعیت */
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-info: #3b82f6;
    --color-purple: #a855f7;
    --color-pink: #ec4899;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Vazirmatn', sans-serif;
    outline: none;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.5;
    overflow-x: hidden;
    direction: rtl; /* جهت راست‌چین برای فارسی */
}

a {
    text-decoration: none;
    color: inherit;
    transition: 0.3s;
}

ul {
    list-style: none;
}

/* اسکرول بار */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: var(--primary);
    }

/* =========================================
   2. LAYOUT & STRUCTURE (Fixed)
   ========================================= */

.panel-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- هدر پنل (اصلاح شده) --- */
.panel-header {
    background-color: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    width: 100%;
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px; /* افزایش پدینگ طرفین */
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* اصلاح فاصله آیتم‌های هدر */
.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 25px; /* فاصله بین آیتم‌ها از 15 به 25 افزایش یافت */
}

    /* اگر داخل هدر لیست منو دارید */
    .header-right ul {
        display: flex;
        gap: 20px;
    }

.app-name {
    color: var(--text-main);
    font-size: 1.5rem;
    font-weight: 900;
}

/* ناحیه اصلی */
.panel-content {
    display: flex;
    flex: 1;
    width: 100%;
    position: relative;
}

/* --- سایدبار --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    flex-shrink: 0;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
}

.sidebar-title {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    font-weight: bold;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-link {
    color: var(--text-muted);
    padding: 12px 15px;
    border-radius: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    white-space: nowrap; /* جلوگیری از شکستن متن */
}

    .sidebar-link:hover {
        background-color: rgba(255, 255, 255, 0.03);
        color: var(--text-main);
        transform: translateX(-4px);
    }

    .sidebar-link.active {
        background: linear-gradient(270deg, rgba(99, 102, 241, 0.15), transparent); /* گرادینت اصلاح شده برای RTL */
        color: var(--primary-glow);
        border-right: 3px solid var(--primary);
    }

/* --- محتوای اصلی --- */
.main-content {
    flex: 1;
    padding: 30px;
    width: calc(100% - var(--sidebar-width));
    overflow-x: hidden;
}

/* =========================================
   3. COMPONENTS
   ========================================= */

.info-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    position: relative;
    transition: transform 0.2s;
}

    .info-card:hover {
        border-color: var(--primary);
    }

    .info-card h3 {
        font-size: 1.1rem;
        margin-bottom: 15px;
        color: var(--text-main);
    }

input[type="text"], input[type="password"], input[type="url"],select,textarea {
    width: 100%;
    padding: 12px;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-main);
    margin-bottom: 10px;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    display: inline-block;
    text-align: center;
}

    .btn-primary:hover {
        background-color: var(--primary-dark);
    }

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 8px;
    background: var(--bg-hover);
    color: var(--text-main);
    border: none;
    cursor: pointer;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.btn-service {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: 0.3s;
    min-height: 160px;
    cursor: pointer;
}

    .btn-service:hover {
        transform: translateY(-5px);
        box-shadow: 0 10px 25px rgba(0,0,0,0.2);
        border-color: var(--primary);
    }

.service-icon {
    font-size: 2.5rem;
    margin-bottom: 15px;
    color: var(--text-muted);
}

.btn-service:hover .service-icon {
    color: var(--primary-glow);
}

.service-title {
    font-weight: bold;
    font-size: 1rem;
}

.recent-history, .chart-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 25px;
    margin-top: 30px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid var(--border);
}

    .history-item:last-child {
        border-bottom: none;
    }

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 450px;
}

/* =========================================
   4. RESPONSIVE DESIGN (اصلاح شده)
   ========================================= */

@media screen and (max-width: 992px) {
    .panel-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        top: 0;
        border-left: none;
        border-bottom: 1px solid var(--border);
        padding: 15px;
        overflow-y: visible;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 10px; /* فضای بیشتر برای اسکرول بار */
        gap: 15px; /* فاصله بیشتر بین دکمه‌های منوی موبایل */
    }

    .sidebar-link {
        flex-shrink: 0;
        padding: 10px 16px;
        font-size: 0.9rem;
        border-right: none;
        background: var(--bg-card); /* کمی روشن‌تر برای تمایز */
        margin-left: 0; /* مارجین حذف شد و از gap استفاده شد */
        border-radius: 10px;
        border: 1px solid transparent;
    }

        .sidebar-link:hover {
            border-color: var(--primary);
        }

        .sidebar-link.active {
            border-right: none;
            border-bottom: 3px solid var(--primary);
            background: var(--bg-hover);
        }

    .main-content {
        width: 100%;
        padding: 20px;
    }

    .services-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media screen and (max-width: 600px) {
    .panel-header {
        padding: 0 15px;
    }

    .app-name {
        font-size: 1.2rem;
    }

    /* در موبایل کوچک فاصله هدر را کمی کمتر می‌کنیم تا جا شوند */
    .header-left, .header-right {
        gap: 15px;
    }

    .services-grid {
        grid-template-columns: 1fr;
    }

    .history-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

        .history-item button {
            width: 100%;
        }

    .info-cards {
        grid-template-columns: 1fr;
    }
    input[type="url"].form-control,
    input[type="url"] {
        background-color: #212529 !important;
        color: #ffffff !important;
        border-color: #444 !important;
    }
