/* ==========================================================
   سامانه مدیریت اموال - استایل اصلی
   ========================================================== */

:root {
    --brand-navy: #101838;
    --brand-navy-light: #1b2550;
    --brand-primary: #3454d1;
    --brand-primary-dark: #2740a8;
    --brand-teal: #17b0a7;
    --brand-amber: #f5a524;
    --brand-rose: #e5484d;
    --brand-violet: #7c5cf0;
    --bg-app: #f2f4fb;
    --text-main: #1f2440;
    --text-muted: #7d84a3;
    --border-soft: #e7e9f5;
    --radius-lg: 16px;
    --radius-md: 12px;
    --shadow-card: 0 4px 20px rgba(23, 30, 70, 0.06);
}

* { box-sizing: border-box; }

body {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background: var(--bg-app);
    color: var(--text-main);
    margin: 0;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; margin: 0; padding: 0; }

/* ---------------- Topbar ---------------- */
.topbar {
    height: 68px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.topbar-right { display: flex; align-items: center; gap: 14px; }

.btn-toggle-sidebar {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-main);
    cursor: pointer;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--brand-navy);
}
.topbar-brand i { color: var(--brand-primary); font-size: 1.5rem; }
.topbar-logo { height: 34px; width: auto; border-radius: 4px; }

.topbar-left { display: flex; align-items: center; gap: 22px; }

.topbar-info-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 18px;
    border-left: 1px solid var(--border-soft);
}
.topbar-info-item i { font-size: 1.2rem; color: var(--brand-primary); }
.topbar-info-item small { display: block; color: var(--text-muted); font-size: .72rem; }
.topbar-info-item strong { display: block; font-size: .88rem; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 10px;
    transition: background .15s;
}
.topbar-user:hover { background: var(--bg-app); }

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-violet));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}
.user-name { font-weight: 600; font-size: .9rem; }

/* ---------------- App layout ---------------- */
.app-body { display: flex; min-height: calc(100vh - 68px); }

.sidebar {
    width: 268px;
    flex-shrink: 0;
    background: var(--brand-navy);
    color: #cdd3ee;
    padding: 18px 12px;
    position: sticky;
    top: 68px;
    height: calc(100vh - 68px);
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px 18px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-brand-logo {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 10px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.sidebar-brand-logo img { width: 100%; height: 100%; object-fit: contain; }
.sidebar-brand-text { display: flex; flex-direction: column; overflow: hidden; }
.sidebar-brand-text strong { font-size: .85rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-brand-text span { font-size: .75rem; color: #9aa2c7; }

.sidebar-item { margin-bottom: 4px; }

.sidebar-link, .submenu-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 10px;
    color: #b7bede;
    font-size: .92rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.sidebar-link i, .submenu-toggle i { font-size: 1.05rem; width: 20px; text-align: center; }

.sidebar-link:hover, .submenu-toggle:hover {
    background: var(--brand-navy-light);
    color: #fff;
}

.sidebar-link.active, .submenu-toggle.active {
    background: var(--brand-primary);
    color: #fff;
}

.submenu-arrow { margin-right: auto; margin-left: 0; font-size: .75rem; transition: transform .2s; }
.sidebar-item.open .submenu-arrow { transform: rotate(180deg); }

.submenu {
    display: none;
    padding-right: 18px;
    margin-top: 2px;
}
.submenu-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-radius: 8px;
    color: #9aa1c4;
    font-size: .85rem;
}
.submenu-link i { font-size: .95rem; width: 18px; text-align: center; }
.submenu-link:hover { background: var(--brand-navy-light); color: #fff; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 1020;
}

/* ---------------- Main content ---------------- */
.main-content {
    flex: 1;
    padding: 26px 28px 40px;
    min-width: 0;
}

.page-header { margin-bottom: 22px; }
.page-header h4 { font-weight: 700; color: var(--brand-navy); margin: 0; }

/* ---------------- Dashboard cards ---------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 18px;
    margin-bottom: 26px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-soft);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    flex-shrink: 0;
}

.stat-card .stat-body { min-width: 0; }
.stat-card .stat-label { color: var(--text-muted); font-size: .82rem; margin-bottom: 4px; }
.stat-card .stat-value { font-size: 1.35rem; font-weight: 800; color: var(--text-main); white-space: nowrap; }
.stat-card .stat-unit { font-size: .78rem; color: var(--text-muted); font-weight: 500; }

.bg-icon-blue   { background: linear-gradient(135deg, #3454d1, #5c7bef); }
.bg-icon-teal   { background: linear-gradient(135deg, #0d9488, #17b0a7); }
.bg-icon-amber  { background: linear-gradient(135deg, #d97706, #f5a524); }
.bg-icon-violet { background: linear-gradient(135deg, #6d28d9, #7c5cf0); }
.bg-icon-rose   { background: linear-gradient(135deg, #be123c, #e5484d); }
.bg-icon-slate  { background: linear-gradient(135deg, #475569, #64748b); }

.dashboard-panel {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-soft);
    padding: 22px;
}
.dashboard-panel h6 {
    font-weight: 700;
    color: var(--brand-navy);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.dashboard-panel h6 i { color: var(--brand-primary); }

.mini-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 0;
    border-bottom: 1px dashed var(--border-soft);
    font-size: .88rem;
}
.mini-list-item:last-child { border-bottom: none; }

.badge-status {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: .74rem;
    font-weight: 600;
}
.badge-active { background: #e6f7f5; color: #0d9488; }
.badge-transferred { background: #fff4e0; color: #d97706; }
.badge-disposed { background: #fdeaea; color: #be123c; }

.empty-state {
    text-align: center;
    padding: 30px 10px;
    color: var(--text-muted);
}
.empty-state i { font-size: 2.2rem; margin-bottom: 10px; display: block; color: #c7cbe6; }

/* ---------------- Login page ---------------- */
.login-page {
    background: linear-gradient(135deg, var(--brand-navy) 0%, #263172 55%, var(--brand-primary) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-wrapper { width: 100%; max-width: 420px; }
.login-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 34px 30px;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-logo {
    width: 76px; height: 76px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid var(--border-soft);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem;
    margin: 0 auto 14px;
    overflow: hidden;
}
.login-logo img { width: 100%; height: 100%; object-fit: contain; }
.login-brand h1 { font-size: 1.15rem; font-weight: 800; color: var(--brand-navy); margin-bottom: 6px; }
.login-brand p { font-size: .84rem; color: var(--text-muted); margin: 0; }
.login-footer { text-align: center; color: rgba(255,255,255,.75); font-size: .8rem; margin-top: 18px; }

.form-label { font-size: .85rem; font-weight: 600; color: var(--text-main); }
.btn-primary {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    font-weight: 700;
}
.btn-primary:hover { background: var(--brand-primary-dark); border-color: var(--brand-primary-dark); }

/* ---------------- Responsive ---------------- */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        right: -280px;
        top: 0;
        height: 100vh;
        z-index: 1040;
        transition: right .25s ease;
        padding-top: 84px;
    }
    .sidebar.show { right: 0; }
    .sidebar-overlay.show { display: block; }
    .topbar-info-item small, .topbar-info-item strong { font-size: .75rem; }
    .topbar-info-item { padding-left: 10px; }
}

@media (max-width: 575.98px) {
    .topbar-info-item { display: none; }
    .main-content { padding: 18px 14px 30px; }
}

/* ==========================================================
   فرم‌های اطلاعات پایه (واحدها، کارکنان، محل‌ها، گروه‌های اموال،
   روش‌های استهلاک) - کلاس‌های عمومی صفحات لیست و فرم
   ========================================================== */

.page-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--brand-navy);
    margin: 0 0 18px;
}

.card {
    background: #ffffff;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 20px;
    margin-bottom: 20px;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: .88rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-success { background: #e6f7f0; color: #0d9488; border: 1px solid #b7ebdd; }
.alert-error   { background: #fdeaea; color: #be123c; border: 1px solid #f7c6cf; }

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.search-input {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 8px 14px;
    font-family: inherit;
    font-size: .86rem;
    min-width: 240px;
}
.search-input:focus { outline: none; border-color: var(--brand-primary); }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--radius-md);
    font-size: .86rem;
    padding: 8px 16px;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
}
.btn-secondary {
    background: #fff;
    color: var(--text-main);
    border-color: var(--border-soft);
}
.btn-secondary:hover { background: var(--bg-app); }
.btn-danger { background: #fdeaea; color: #be123c; border-color: #f7c6cf; }
.btn-danger:hover { background: #fbd9de; }
.btn-sm { padding: 5px 10px; font-size: .78rem; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px 20px;
}
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: .84rem; font-weight: 600; color: var(--text-main); }
.form-field input[type="text"],
.form-field input[type="tel"],
.form-field input[type="number"],
.form-field select,
.form-field textarea {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 9px 12px;
    font-family: inherit;
    font-size: .88rem;
    background: #fff;
    color: var(--text-main);
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
    outline: none;
    border-color: var(--brand-primary);
}
.form-field.checkbox-field { flex-direction: row; align-items: center; gap: 8px; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; }

.table-scroll { overflow-x: auto; overflow-y: visible; }
.log-scroll { max-height: 300px; }
.data-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.data-table th, .data-table td {
    padding: 10px 12px;
    text-align: right;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
}
.data-table th { color: var(--text-muted); font-weight: 600; font-size: .8rem; }
.data-table td.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; white-space: normal; }

.badge-inactive { background: #f1f2f8; color: var(--text-muted); }
.badge-system { background: #eef1fc; color: var(--brand-primary); }

/* ساختار درختی (واحدها / محل‌ها / گروه‌های اموال) */
.acc-tree ul { padding-right: 20px; }
.acc-tree > ul { padding-right: 0; }
.acc-node {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-md);
}
.acc-node:hover { background: var(--bg-app); }
.acc-code { color: var(--text-muted); font-size: .8rem; }
.acc-title { font-weight: 600; flex: 1; }
.acc-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.acc-toggle, .acc-toggle-spacer { width: 14px; flex: none; }
.acc-toggle::before { content: "▾"; color: var(--text-muted); cursor: pointer; }
details.acc-branch:not([open]) > summary .acc-toggle::before { content: "◂"; }
.acc-branch summary { list-style: none; cursor: default; }
.acc-branch summary::-webkit-details-marker { display: none; }

@media (max-width: 767px) {
    .form-grid { grid-template-columns: 1fr; }
}

.badge-leaf { background: #eef7f0; color: #1b7a3d; }

/* ==========================================================
   حالت چاپ: فقط نتیجه‌ی گزارش چاپ شود، نه کل صفحه (منو، هدر، فیلترها)
   ========================================================== */
@media print {
    @page {
        size: landscape;
        margin: 10mm;
    }

    .topbar, .sidebar, .sidebar-overlay, .no-print, .page-header {
        display: none !important;
    }
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    .app-body { display: block !important; }
    .card {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
    }
    body { background: #fff !important; }
    .print-only { display: block !important; }

    /* رفع مشکل اصلی: کانتینر اسکرول‌دار نباید محتوای جدول را قبل از چاپ کِراپ کند */
    .table-scroll {
        overflow: visible !important;
        width: auto !important;
        max-width: none !important;
    }
    .log-scroll {
        max-height: none !important;
    }

    .data-table {
        width: 100% !important;
        table-layout: auto;
        font-size: 10px;
        border-collapse: collapse;
    }
    .data-table th, .data-table td {
        padding: 3px 5px;
        white-space: normal;
        word-break: break-word;
    }

    /* هدر جدول در هر صفحه تکرار شود و ردیف‌ها وسط صفحه قطع نشوند */
    .data-table thead { display: table-header-group; }
    .data-table tfoot { display: table-footer-group; }
    .data-table tr { page-break-inside: avoid; break-inside: avoid; }
    .data-table { page-break-inside: auto; }
}

.print-only { display: none; }
