@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap');

:root {
    --brand-blue: #128fd8;
    --brand-purple: #7b3ff2;
    --brand-green: #22b34a;
    --sidebar-bg-1: #161b2e;
    --sidebar-bg-2: #1f2748;
}

* {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
}

body {
    background-color: #f3f5f9;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 260px;
    flex: 0 0 260px;
    min-height: 100vh;
    background: linear-gradient(180deg, var(--sidebar-bg-1), var(--sidebar-bg-2));
    color: #fff;
    padding: 0 0 1rem;
    box-shadow: 2px 0 12px rgba(0,0,0,.12);
    position: relative;
}

.btn-close-sidebar {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(255,255,255,.08);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1.15rem 1.25rem;
    font-weight: 700;
    font-size: 1.02rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    margin-bottom: .75rem;
    color: #fff;
}

.sidebar .brand img {
    width: 34px;
    height: 34px;
    object-fit: contain;
}

.sidebar a {
    color: #aab2c5;
    display: flex;
    align-items: center;
    gap: .6rem;
    margin: .15rem .7rem;
    padding: .65rem .9rem;
    border-radius: .6rem;
    text-decoration: none;
    font-size: .92rem;
    transition: .2s;
}

.sidebar a i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
}

.sidebar a:hover {
    background: rgba(255,255,255,.06);
    color: #fff;
}

.sidebar a.active {
    background: linear-gradient(90deg, var(--brand-blue), var(--brand-purple));
    color: #fff;
    box-shadow: 0 6px 16px rgba(18,143,216,.35);
}

/* ===== Topbar ===== */
.topbar {
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

/* ===== Cards ===== */
.card {
    border: none;
    box-shadow: 0 2px 10px rgba(20,30,60,.06);
    border-radius: .9rem;
}

.card-header {
    border-radius: .9rem .9rem 0 0 !important;
}

/* ===== Buttons ===== */
.btn {
    border-radius: .6rem;
    transition: .2s;
}

.btn-primary {
    background: linear-gradient(90deg, var(--brand-blue), var(--brand-purple));
    border: none;
    box-shadow: 0 6px 16px rgba(18,143,216,.25);
}

.btn-primary:hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(123,63,242,.3);
    color: #fff;
}

.btn-outline-primary {
    border-color: var(--brand-blue);
    color: var(--brand-blue);
}

.btn-outline-primary:hover {
    background: var(--brand-blue);
    border-color: var(--brand-blue);
}

/* ===== Login page (legacy fallback, main styles are inline in login.php) ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1f2937, #374151);
}

.login-card {
    width: 100%;
    max-width: 400px;
}

/* ===== Misc ===== */
.nav-tabs .nav-link {
    color: #6b7280;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: .92rem;
}

.nav-tabs .nav-link.active {
    font-weight: 700;
    color: var(--brand-blue);
    border-bottom-color: var(--brand-blue);
    background: none;
}

.table {
    font-size: .92rem;
}

.badge-status-pending { background: #f59e0b; }
.badge-status-progress { background: #3b82f6; }
.badge-status-done { background: #10b981; }

/* ===== Layout base (prevents flex children from overflowing on narrow screens) ===== */
.main-content {
    min-width: 0;
    flex: 1 1 auto;
    width: 100%;
}

/* ===== Hamburger toggle button (mobile/tablet only) ===== */
.btn-hamburger {
    background: #fff;
    border: 1px solid #e5e7eb;
    color: #1f2937;
    width: 40px;
    height: 40px;
    border-radius: .6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* ===== Sidebar backdrop (mobile overlay) ===== */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 20, 35, .5);
    z-index: 1040;
    opacity: 0;
    transition: opacity .25s ease;
}

.sidebar-backdrop.show {
    display: block;
    opacity: 1;
}

/* ===== Responsive breakpoints ===== */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        max-width: 82vw;
        z-index: 1050;
        transform: translateX(100%);
        transition: transform .28s ease;
        overflow-y: auto;
    }

    .sidebar.show {
        transform: translateX(0);
        box-shadow: -8px 0 30px rgba(0,0,0,.25);
    }

    .btn-close-sidebar {
        display: flex;
    }

    .sidebar .brand {
        padding-right: 3rem;
    }
}

@media (min-width: 992px) {
    .btn-hamburger,
    .btn-close-sidebar,
    .sidebar-backdrop {
        display: none !important;
    }
}

/* نوار تب‌های صفحه پروژه (ممکن است تعداد تب زیاد باشد) به‌صورت اسکرول افقی در موبایل */
@media (max-width: 767.98px) {
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .nav-tabs .nav-item,
    .nav-tabs > a {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .nav-tabs::-webkit-scrollbar {
        height: 4px;
    }

    .nav-tabs::-webkit-scrollbar-thumb {
        background: #d1d5db;
        border-radius: 4px;
    }
}

/* کارت‌های آماری (پیشخوان، گزارش مالی و ...) دو ستونه در موبایل */
@media (max-width: 767.98px) {
    .stat-cards-row > [class*="col-"] {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* کوچک‌سازی عمومی فاصله‌ها و فونت در صفحات بسیار کوچک */
@media (max-width: 575.98px) {
    .card-body {
        padding: 1rem;
    }

    .card-header {
        padding: .75rem 1rem;
        font-size: .92rem;
    }

    h5.fw-bold {
        font-size: 1.05rem;
    }

    .table {
        font-size: .82rem;
    }

    .btn {
        font-size: .85rem;
    }
}

/* دکمه‌های کنار هم (مثلا در صفحه فاکتور) در موبایل زیر هم و تمام‌عرض شوند */
@media (max-width: 575.98px) {
    .action-buttons-row {
        flex-direction: column;
        align-items: stretch !important;
    }

    .action-buttons-row > * {
        width: 100%;
    }

    .action-buttons-row form,
    .action-buttons-row a.btn,
    .action-buttons-row button {
        width: 100%;
    }
}

/* جدول‌ها همیشه در صورت سرریز به‌صورت افقی اسکرول شوند */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}
