﻿/* /css/layout.css */

:root {
    --primary-color: #10b981;
    --primary-dark: #059669;
    --primary-light: #34d399;
    --bg-color: #FAF6EA;
    --header-bg: #fdfefc;
    --sidebar-bg: #f8fbf9;
    --text-color: #1f2937;
    --border-color: rgba(0,0,0,0.06);
    --sidebar-width: 250px;
    --sidebar-width-collapsed: 60px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.7;
    min-height: 100vh;
}

/* --- سایدبار --- */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    padding: 1rem;
    border-left: 1px solid var(--border-color);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, padding 0.3s ease;
    overflow-y: auto; /* ✅ فعال‌سازی اسکرول عمودی */
    overflow-x: hidden;
    scrollbar-width: thin; /* ✅ اسکرول ظریف در مرورگرهای مدرن */
    scrollbar-color: rgba(0,0,0,0.15) transparent;
}

    /* ✅ استایل زیبا برای اسکرول در دسکتاپ */
    .sidebar::-webkit-scrollbar {
        width: 6px;
    }

    .sidebar::-webkit-scrollbar-track {
        background: transparent;
    }

    .sidebar::-webkit-scrollbar-thumb {
        background-color: rgba(0, 0, 0, 0.15);
        border-radius: 4px;
    }

        .sidebar::-webkit-scrollbar-thumb:hover {
            background-color: rgba(0, 0, 0, 0.3);
        }

    .sidebar.collapsed {
        width: var(--sidebar-width-collapsed);
        padding: 0;
        overflow-y: hidden;
    }

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

.sidebar-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: #065f46;
    overflow: hidden;
}

.close-sidebar {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #065f46;
    transition: transform 0.2s;
    display: none;
}

.collapse-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: #065f46;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .close-sidebar:hover,
    .collapse-toggle:hover {
        transform: scale(1.1);
    }

/* --- لیست ناوبری سایدبار --- */
.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav a,
.sidebar-nav button {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: calc(100% + 2rem);
    height: 44px;
    padding: 0 1rem;
    margin: 0 -1rem;
    border: none;
    background: none;
    text-decoration: none;
    color: inherit;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    border-radius: 0;
    transition: all 0.2s ease;
    box-sizing: border-box;
    line-height: 1;
    position: relative;
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
    font-size: 0.9rem; /* اندازه متعادل‌تر */
}

    .sidebar-nav a span,
    .sidebar-nav button span {
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: normal;
    }

    .sidebar-nav a:hover,
    .sidebar-nav button:hover {
        background-color: rgba(16, 185, 129, 0.08);
        color: var(--primary-dark);
    }

    .sidebar-nav a.active,
    .sidebar-nav button.active {
        background-color: rgba(16, 185, 129, 0.12);
        color: var(--primary-dark);
        font-weight: 600;
    }

        .sidebar-nav a.active::before,
        .sidebar-nav button.active::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            height: 100%;
            width: 4px;
            background-color: var(--primary-color);
        }

.sidebar-nav li {
    margin-bottom: 0.1rem;
}

.menu-section {
    font-weight: 600;
    color: #047857;
    padding: 0.4rem 1rem 0.3rem 1rem;
    margin: 0.75rem -1rem 0.3rem -1rem;
    border-top: 1px solid rgba(16, 185, 129, 0.20);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: none; /* حذف گرادیان برای یکدستی رنگ */
    border-radius: 0; /* حذف خمیدگی */
    font-size: 0.95rem;
    line-height: 1.2;
}

.user-info {
    list-style: none; /* حذف بولت‌های پیش‌فرض */
    padding: 0 0 0 15px; /* هم‌راستا با زیرمنوها */
    margin: 5px 0;
    font-size: 0.85rem;
    color: #888; /* رنگ کم‌رنگ */
}

.user-info li {
    padding: 1px 20px;
}

/* استایل برای خط جداکننده ساده */
.menu-divider {
    height: 1px;
    background: rgba(16, 185, 129, 0.25);
    margin: 1rem -1rem;
    border: none;
}


.content-column {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin-right: var(--sidebar-width);
    transition: margin-right 0.3s ease;
}

    .content-column.sidebar-collapsed {
        margin-right: var(--sidebar-width-collapsed);
    }

header {
    background-color: var(--header-bg);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 90;
    height: 64px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
}

.logo {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--primary-dark);
}

.menu-toggle {
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: var(--text-color);
    transition: transform 0.2s;
    display: none;
}

    .menu-toggle:hover {
        transform: scale(1.1);
    }

main.content {
    flex: 1;
    padding: 2rem 1.5rem;
    overflow-y: auto;
    background-color: var(--bg-color);
}

footer {
    background-color: #065f46;
    color: #fff;
    text-align: center;
    padding: 1rem;
    margin-top: auto;
}

/* --- Overlay موبایل --- */
.overlay {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
    z-index: 150;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

    .overlay.active {
        display: block;
        opacity: 1;
    }

/* --- موبایل --- */
@media (max-width: 767px) {
    .sidebar {
        width: 250px;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        overflow-y: auto;
        padding-bottom: 80px; /* ✅ تضمین نمایش آخرین گزینه */
    }

        .sidebar.active {
            transform: translateX(0);
        }

    .close-sidebar {
        display: block;
        font-size: 1.5rem;
        transform: scale(1.3);
        padding: 4px;
    }

    .collapse-toggle {
        display: none;
    }

    .content-column,
    .content-column.sidebar-collapsed {
        margin-right: 0;
    }

    .menu-toggle {
        display: block;
    }

    .sidebar-nav a,
    .sidebar-nav button {
        margin: 0;
        width: 100%;
        border-radius: 8px;
    }

    .menu-section {
        margin: 1rem 0 0.5rem 0;
        border-radius: 8px;
    }

    .sidebar-nav a.active::before,
    .sidebar-nav button.active::before {
        left: 0;
        border-radius: 0 4px 4px 0;
    }
}

/* --- دسکتاپ --- */
@media (min-width: 768px) {
    .sidebar.collapsed .sidebar-header {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 60px;
        padding: 0;
        margin-bottom: 0;
        border: none;
    }

    .sidebar.collapsed .sidebar-title,
    .sidebar.collapsed .close-sidebar {
        display: none;
    }

    .sidebar.collapsed .sidebar-nav {
        display: none;
    }

    .collapse-toggle::before {
        font-size: 1.4rem;
        display: block;
        color: var(--primary-dark);
    }

    .sidebar:not(.collapsed) .collapse-toggle::before {
        content: '❮';
    }

    .sidebar.collapsed .collapse-toggle::before {
        content: '❯';
    }

    .sidebar.collapsed .sidebar-nav a,
    .sidebar.collapsed .sidebar-nav button {
        margin: 0;
        width: 100%;
        padding: 0;
        justify-content: center;
    }

    .sidebar.collapsed .menu-section {
        display: none;
    }
}

