/* =====================================================================
   Targap - Main Stylesheet
   ---------------------------------------------------------------------
   استایل‌های اصلی پروژه. شامل:
   - تعریف فونت Vazirmatn (9 وزن، لوکال)
   - متغیرهای CSS (رنگ‌ها، spacing، radius)
   - تایپوگرافی عمومی
   - کامپوننت‌های سفارشی (sidebar، topbar، cards)
   ===================================================================== */

/* ---------- 1. Vazirmatn Font Face (local, no CDN) ---------- */
/* تعریف 9 وزن فونت. مرورگر فقط وزن‌های مورد استفاده رو load می‌کنه. */

@font-face {
    font-family: "Vazirmatn";
    font-style: normal;
    font-weight: 100;
    font-display: swap;
    src: url("../fonts/vazirmatn/Vazirmatn-Thin.woff2") format("woff2");
}
@font-face {
    font-family: "Vazirmatn";
    font-style: normal;
    font-weight: 200;
    font-display: swap;
    src: url("../fonts/vazirmatn/Vazirmatn-ExtraLight.woff2") format("woff2");
}
@font-face {
    font-family: "Vazirmatn";
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: url("../fonts/vazirmatn/Vazirmatn-Light.woff2") format("woff2");
}
@font-face {
    font-family: "Vazirmatn";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/vazirmatn/Vazirmatn-Regular.woff2") format("woff2");
}
@font-face {
    font-family: "Vazirmatn";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/vazirmatn/Vazirmatn-Medium.woff2") format("woff2");
}
@font-face {
    font-family: "Vazirmatn";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/vazirmatn/Vazirmatn-SemiBold.woff2") format("woff2");
}
@font-face {
    font-family: "Vazirmatn";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/vazirmatn/Vazirmatn-Bold.woff2") format("woff2");
}
@font-face {
    font-family: "Vazirmatn";
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url("../fonts/vazirmatn/Vazirmatn-ExtraBold.woff2") format("woff2");
}
@font-face {
    font-family: "Vazirmatn";
    font-style: normal;
    font-weight: 900;
    font-display: swap;
    src: url("../fonts/vazirmatn/Vazirmatn-Black.woff2") format("woff2");
}

/* ---------- 2. CSS Variables (Design Tokens) ---------- */
:root {
    /* برند تارگپ */
    --tg-primary: #0a66c2;
    --tg-primary-dark: #084d93;
    --tg-primary-light: #e7f1fb;

    --tg-success: #10b981;
    --tg-warning: #f59e0b;
    --tg-danger:  #ef4444;
    --tg-info:    #0ea5e9;

    /* خاکستری‌ها */
    --tg-gray-50:  #f9fafb;
    --tg-gray-100: #f3f4f6;
    --tg-gray-200: #e5e7eb;
    --tg-gray-300: #d1d5db;
    --tg-gray-500: #6b7280;
    --tg-gray-700: #374151;
    --tg-gray-900: #111827;

    /* layout */
    --tg-sidebar-width: 260px;
    --tg-sidebar-width-collapsed: 72px;
    --tg-topbar-height: 60px;
    --tg-content-bg: #f5f7fa;

    /* border & shadow */
    --tg-border-color: #e5e9f0;
    --tg-radius-sm: 4px;
    --tg-radius-md: 8px;
    --tg-radius-lg: 12px;
    --tg-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --tg-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);

    /* override Bootstrap primary with Targap brand */
    --bs-primary: var(--tg-primary);
    --bs-primary-rgb: 10, 102, 194;
}

/* ---------- 3. Typography ---------- */
html, body {
    font-family: "Vazirmatn", "Tahoma", "Segoe UI", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.7;
    color: var(--tg-gray-900);
    background-color: var(--tg-content-bg);
    direction: rtl;
    text-align: right;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.4;
    color: var(--tg-gray-900);
}

code, pre, kbd, samp, .font-mono {
    font-family: "Consolas", "Courier New", monospace;
    direction: ltr;
    unicode-bidi: embed;
}

/* اعداد در همه جا ltr باشن برای خوانایی بهتر */
.ltr-numbers {
    direction: ltr;
    unicode-bidi: embed;
    display: inline-block;
}

/* ---------- 4. Layout: App Shell ---------- */
.tg-app {
    display: flex;
    min-height: 100vh;
}

/* ---------- 5. Sidebar ---------- */
.tg-sidebar {
    width: var(--tg-sidebar-width);
    background: #ffffff;
    border-left: 1px solid var(--tg-border-color);
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 1030;
    transition: transform 0.25s ease;
}

.tg-sidebar-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--tg-border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--tg-topbar-height);
}

.tg-sidebar-logo {
    font-size: 20px;
    font-weight: 800;
    color: var(--tg-primary);
    margin: 0;
}

.tg-sidebar-subtitle {
    font-size: 11px;
    color: var(--tg-gray-500);
    margin: 0;
}

.tg-sidebar-nav {
    list-style: none;
    padding: 12px 0;
    margin: 0;
}

.tg-sidebar-nav .nav-section {
    padding: 16px 20px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--tg-gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tg-sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--tg-gray-700);
    text-decoration: none;
    transition: all 0.15s ease;
    border-right: 3px solid transparent;
}

.tg-sidebar-nav a:hover {
    background: var(--tg-gray-50);
    color: var(--tg-primary);
}

.tg-sidebar-nav a.active {
    background: var(--tg-primary-light);
    color: var(--tg-primary);
    border-right-color: var(--tg-primary);
    font-weight: 600;
}

.tg-sidebar-nav a i {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

/* ---------- 6. Topbar ---------- */
.tg-main {
    flex: 1;
    margin-right: var(--tg-sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0; /* مهم: برای اجازه کوچک‌شدن به main در flex */
}

.tg-topbar {
    height: var(--tg-topbar-height);
    background: #ffffff;
    border-bottom: 1px solid var(--tg-border-color);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.tg-topbar-toggle {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--tg-gray-700);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--tg-radius-sm);
}

.tg-topbar-toggle:hover {
    background: var(--tg-gray-100);
}

.tg-topbar-search {
    flex: 1;
    max-width: 480px;
    position: relative;
}

.tg-topbar-search input {
    width: 100%;
    padding: 8px 36px 8px 14px;
    border: 1px solid var(--tg-border-color);
    border-radius: var(--tg-radius-md);
    background: var(--tg-gray-50);
    font-size: 13px;
}

.tg-topbar-search input:focus {
    outline: none;
    border-color: var(--tg-primary);
    background: #ffffff;
}

.tg-topbar-search .search-icon {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    color: var(--tg-gray-500);
    pointer-events: none;
}

.tg-topbar-actions {
    margin-right: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tg-topbar-icon-btn {
    position: relative;
    background: none;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: var(--tg-radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--tg-gray-700);
    cursor: pointer;
    font-size: 18px;
}

.tg-topbar-icon-btn:hover {
    background: var(--tg-gray-100);
}

.tg-topbar-icon-btn .badge-dot {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 8px;
    height: 8px;
    background: var(--tg-danger);
    border-radius: 50%;
    border: 2px solid #ffffff;
}

/* ---------- 7. Content area ---------- */
.tg-content {
    flex: 1;
    padding: 24px;
    min-width: 0;
}

.tg-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.tg-page-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
}

/* ---------- 8. Footer ---------- */
.tg-footer {
    padding: 14px 24px;
    background: #ffffff;
    border-top: 1px solid var(--tg-border-color);
    text-align: center;
    font-size: 12px;
    color: var(--tg-gray-500);
}

/* ---------- 9. Cards ---------- */
.tg-card {
    background: #ffffff;
    border: 1px solid var(--tg-border-color);
    border-radius: var(--tg-radius-lg);
    padding: 20px;
    box-shadow: var(--tg-shadow-sm);
}

.tg-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--tg-border-color);
}

.tg-card-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

/* ---------- 10. Empty state ---------- */
.tg-empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--tg-gray-500);
}

.tg-empty-state i {
    font-size: 48px;
    color: var(--tg-gray-300);
    margin-bottom: 12px;
    display: block;
}

.tg-empty-state p {
    margin: 0;
    font-size: 14px;
}

/* ---------- 11. Mobile responsive ---------- */
@media (max-width: 991.98px) {
    .tg-sidebar {
        transform: translateX(100%);
    }

    .tg-sidebar.is-open {
        transform: translateX(0);
    }

    .tg-main {
        margin-right: 0;
    }

    .tg-sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1025;
    }

    .tg-sidebar-backdrop.is-visible {
        display: block;
    }
}

/* ---------- 12. Print ---------- */
@media print {
    .tg-sidebar, .tg-topbar, .tg-footer { display: none !important; }
    .tg-main { margin-right: 0 !important; }
    .tg-content { padding: 0 !important; }
    body { background: #ffffff !important; }
}
