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

:root {
    --primary: #1a4f7a;
    --secondary: #e8f4f8;
    --accent: #e74c3c;
    --sidebar-width: 240px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background: #f5f7fa;
    color: #333;
    font-size: 14px;
}

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    min-height: 0;
    background: var(--primary);
    color: #fff;
    position: fixed;
    top: 0; right: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width .25s ease, transform .3s;
    overflow: hidden;
}

.sidebar-brand {
    padding: 18px 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,.15);
    text-align: center;
}

.sidebar-brand .company-name {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.4;
    color: #fff;
}

.sidebar-brand .system-name {
    font-size: 11px;
    color: rgba(255,255,255,.7);
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .35) transparent;
}
.sidebar-nav::-webkit-scrollbar {
    width: 8px;
}
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .28);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, .45);
    background-clip: padding-box;
}
.sidebar-nav::-webkit-scrollbar-corner {
    background: transparent;
}
.sidebar-nav .nav-item { list-style: none; }

.sidebar-brand { flex-shrink: 0; }
.sidebar-footer { flex-shrink: 0; }

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: rgba(255,255,255,.85);
    text-decoration: none;
    font-size: 13.5px;
    border-radius: 0;
    transition: background .2s;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    background: rgba(255,255,255,.15);
    color: #fff;
}

.sidebar-nav .nav-link i { width: 18px; text-align: center; }

/* TreeView-like groups (shared structure with pinplaza) */
.sidebar-tree .tree-node { list-style: none; }
.sidebar-tree .tree-item-parent {
    display: flex;
    align-items: center;
    padding: 0 4px 0 8px;
}
.sidebar-tree .tree-toggle {
    width: 28px; height: 28px; border: 0; background: transparent;
    color: rgba(255,255,255,.55); display: inline-flex; align-items: center; justify-content: center;
    border-radius: 4px; cursor: pointer;
}
.sidebar-tree .tree-toggle:hover { color: #fff; background: rgba(255,255,255,.08); }
.sidebar-tree .tree-toggle-icon { transition: transform .18s ease; }
.sidebar-tree .tree-node.is-open > .tree-item-parent .tree-toggle-icon { transform: rotate(-90deg); }
.sidebar-tree .tree-parent-label {
    flex: 1; display: flex; align-items: center; gap: 10px; min-height: 40px;
    border: 0; background: transparent; color: rgba(255,255,255,.9);
    font-size: 13px; font-weight: 700; text-align: right; padding: 0 8px; cursor: pointer; border-radius: 4px;
}
.sidebar-tree .tree-parent-label:hover { background: rgba(255,255,255,.08); }
.sidebar-tree .tree-parent-icon { width: 20px; text-align: center; color: #7dd3fc; }
.sidebar-tree .tree-children { display: none; }
.sidebar-tree .tree-node.is-open > .tree-children { display: block; }
.sidebar-tree .tree-node-submenu > .tree-children {
    margin-inline-start: 0.45rem;
    border-inline-start: 1px dashed rgba(255,255,255,.2);
}
.sidebar-tree .tree-node-submenu > .tree-item-parent .tree-parent-label {
    font-size: 12.5px;
    font-weight: 600;
    min-height: 34px;
}
.sidebar-tree .tree-item-leaf .sidebar-ext-icon {
    margin-inline-start: auto;
    font-size: 10px;
    opacity: .55;
}
.sidebar-tree .tree-item-leaf {
    display: flex; align-items: center; gap: 12px;
    margin: 1px 8px 1px 12px; padding: 8px 14px; border-radius: 4px;
    color: rgba(255,255,255,.85); text-decoration: none; font-size: 13.5px;
}
.sidebar-tree .tree-item-leaf:hover,
.sidebar-tree .tree-item-leaf.active {
    background: rgba(255,255,255,.12); color: #fff;
}
.sidebar-tree .tree-item-leaf i { width: 18px; text-align: center; }

.sidebar-tree .tree-node-pinned {
    margin-bottom: 0.35rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid rgba(255,255,255,.15);
}
.sidebar-tree .tree-node-pinned .tree-item-leaf {
    font-weight: 700;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,.15);
    font-size: 12px;
    color: rgba(255,255,255,.65);
}

.sidebar-footer .user-name { font-weight: 600; color: #fff; font-size: 13px; }
.sidebar-footer .user-role { font-size: 11px; color: rgba(255,255,255,.65); }
.sidebar-user-card { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sidebar-user-avatar {
    width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.18);
    color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.sidebar-user-meta { min-width: 0; line-height: 1.35; }

.sidebar-footer .btn-logout {
    margin-top: 10px;
    width: 100%;
    font-size: 12.5px;
    color: #fff;
    border-color: rgba(255,255,255,.5);
    background: transparent;
}

.sidebar-footer .btn-logout:hover {
    background: rgba(255,255,255,.15);
    color: #fff;
    border-color: #fff;
}

.main-wrapper {
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-right .25s ease;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar .page-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    margin: 0;
}

.notification-full-item.is-unread { background: #f3f8fc; }

.topbar-user { display: flex; align-items: center; gap: 10px; }

.topbar-user .avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 600;
    flex-shrink: 0;
    object-fit: cover;
}

.topbar-user .avatar.avatar-img,
.topbar-user img.avatar {
    padding: 0;
    background: #e8eef2;
}

.topbar-user-menu .dropdown-toggle {
    border: 0;
    background: transparent;
    padding: 4px 2px;
    cursor: pointer;
}
.topbar-user-menu .dropdown-toggle::after {
    margin-right: 6px;
    margin-left: 0;
    vertical-align: middle;
    opacity: .55;
}
.topbar-user-dropdown {
    min-width: 200px;
    font-size: 13.5px;
    border-radius: 10px;
    padding: .4rem 0;
}
.topbar-user-dropdown .dropdown-item {
    padding: .55rem 1rem;
}
.topbar-user-dropdown .dropdown-item i {
    width: 1.1rem;
    text-align: center;
}

.sidebar-user-avatar.sidebar-user-avatar-img,
img.sidebar-user-avatar {
    object-fit: cover;
    padding: 0;
    display: block;
}

.topbar-user .user-info .name { font-size: 13px; font-weight: 600; }
.topbar-user .user-info .role { font-size: 11px; color: #888; }

.content-area { padding: 24px; flex: 1; }

.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,.07);
    border-right: 4px solid var(--primary);
    transition: transform .2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card .stat-number { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-card .stat-label  { font-size: 12px; color: #777; margin-top: 4px; }
.stat-card.stat-muted  { border-right-color: #6c757d; }
.stat-card.stat-muted  .stat-number { color: #6c757d; }
.stat-card.stat-info   { border-right-color: #0d6efd; }
.stat-card.stat-info   .stat-number { color: #0d6efd; }
.stat-card.stat-success { border-right-color: #198754; }
.stat-card.stat-success .stat-number { color: #198754; }

.table-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.07);
    overflow: hidden;
}
.table-card .table-header {
    padding: 14px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.table-card .table-header h5 { margin: 0; font-size: 15px; color: var(--primary); }
.table { margin: 0; }
.table th { background: #f8f9fa; font-weight: 600; font-size: 12.5px; color: #555; border-bottom: 2px solid #dee2e6; }
.table td { vertical-align: middle; font-size: 13.5px; }
.table tbody tr:hover { background: #fafbfc; }

.form-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.07);
    padding: 24px;
    margin-bottom: 20px;
}
.form-card .section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    border-bottom: 2px solid var(--secondary);
    padding-bottom: 8px;
    margin-bottom: 16px;
}
.form-label { font-size: 13px; font-weight: 500; color: #555; }
.form-control, .form-select {
    font-family: 'Vazirmatn', sans-serif;
    font-size: 13.5px;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 7px 12px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,79,122,.12);
}

.btn { font-family: 'Vazirmatn', sans-serif; font-size: 13.5px; border-radius: 6px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: #163e60; border-color: #163e60; }
.text-primary { color: var(--primary) !important; }

.badge { font-family: 'Vazirmatn', sans-serif; font-size: 11.5px; font-weight: 500; }

.dynamic-table input {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px 8px;
    width: 100%;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 13px;
}
.dynamic-table input:focus { outline: none; border-color: var(--primary); }
.btn-remove-row { color: #dc3545; background: none; border: none; cursor: pointer; padding: 4px 8px; }

.flash-container { margin-bottom: 16px; }
.alert { border-radius: 8px; font-size: 13.5px; border: none; }

.view-form-section {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
}
.view-form-section .section-header {
    background: var(--primary);
    color: #fff;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
}
.view-form-section .section-body { padding: 12px 16px; }
.info-row { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 8px; }
.info-item label { font-size: 11.5px; color: #888; display: block; margin-bottom: 2px; }
.info-item span  { font-size: 13.5px; font-weight: 500; }

.approval-timeline { padding: 0; list-style: none; }
.approval-timeline li {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}
.approval-timeline li:last-child { border-bottom: none; }
.approval-dot {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 13px;
}

body.login-page {
    background: linear-gradient(135deg, #1a4f7a 0%, #2980b9 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-wrapper { width: 100%; max-width: 420px; padding: 20px; }

.login-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    padding: 40px 36px;
}

.login-logo { text-align: center; margin-bottom: 28px; }

.login-logo .logo-icon {
    width: 64px; height: 64px;
    display: inline-flex; align-items: center; justify-content: center;
    margin-bottom: 12px;
}

.login-logo .logo-icon i { font-size: 42px; color: var(--primary); }

.login-logo .co-name { font-size: 17px; font-weight: 700; color: var(--primary); line-height: 1.5; }
.login-logo .sys-name { font-size: 12.5px; color: #888; margin-top: 4px; }
.login-footer { text-align: center; margin-top: 16px; font-size: 11px; color: #aaa; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 999;
}
.sidebar-backdrop.show { display: block; }

.sidebar-close {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255,255,255,.35);
    border-radius: 4px;
    background: transparent;
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2;
}
.sidebar-brand { position: relative; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(100%); }
    .sidebar.open { transform: translateX(0); box-shadow: -4px 0 24px rgba(0, 0, 0, .25); }
    .sidebar-close { display: inline-flex; }
    .main-wrapper { margin-right: 0; }
    .topbar-user .user-info { display: none; }
    body.sidebar-open { overflow: hidden; }
}
