
/* =========================================================
   BregoERP — Enterprise Light Design System
   RTL | Responsive | Light Mode
========================================================= */

:root {
    color-scheme: light;
    --primary: #173b67;
    --primary-dark: #102b4d;
    --primary-light: #eaf1fa;
    --accent: #c99d45;
    --accent-light: #fbf4e6;
    --success: #16865b;
    --success-light: #eaf7f0;
    --danger: #d34d55;
    --danger-light: #fff0f0;
    --warning: #d49427;
    --warning-light: #fff7e8;
    --info: #287db6;
    --info-light: #edf6fc;
    --page-bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f9fafc;
    --text-main: #192b43;
    --text-secondary: #718096;
    --text-muted: #98a5b6;
    --border: #e6ebf2;
    --border-strong: #d9e1ec;
    --sidebar-width: 270px;
    --sidebar-mini-width: 82px;
    --topbar-height: 76px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 17px;
    --radius-xl: 22px;
    --shadow-sm: 0 2px 8px rgba(24, 45, 75, .045);
    --shadow-md: 0 8px 24px rgba(24, 45, 75, .075);
    --shadow-lg: 0 15px 40px rgba(24, 45, 75, .11);
    --transition: .25s ease;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    direction: rtl;
    background: var(--page-bg);
    color: var(--text-main);
    font-family: "Cairo", Tahoma, Arial, sans-serif;
    font-size: 13px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
}

::selection {
    background: #dce9f8;
    color: var(--primary-dark);
}

/* =========================================================
   APPLICATION SHELL
========================================================= */

.app-shell {
    min-height: 100vh;
    display: flex;
    direction: rtl;
}

.main-wrapper {
    width: calc(100% - var(--sidebar-width));
    min-width: 0;
    min-height: 100vh;
    margin-right: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    transition: width var(--transition), margin var(--transition);
}

.content-wrapper {
    flex: 1;
    min-width: 0;
    padding: 24px;
}

.page-container {
    width: 100%;
    max-width: 1800px;
    margin-inline: auto;
}

/* =========================================================
   SIDEBAR
========================================================= */

.sidebar {
    position: fixed;
    z-index: 1050;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #eaf1fa;
    background: radial-gradient(circle at 100% 0%, rgba(201,157,69,.12), transparent 30%), linear-gradient(165deg, #173b67 0%, #102b4d 58%, #0b213d 100%);
    box-shadow: -8px 0 28px rgba(13, 37, 66, .12);
    transition: width var(--transition), transform var(--transition);
}

.sidebar-brand {
    min-height: 84px;
    padding: 14px 17px;
    display: flex;
    align-items: center;
    gap: 11px;
    border-bottom: 1px solid rgba(255,255,255,.10);
}

.brand-link {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 11px;
    flex: 1;
}

.brand-logo {
    width: 45px;
    height: 45px;
    flex: 0 0 45px;
    display: grid;
    place-items: center;
    color: #18385e;
    background: linear-gradient(145deg, #f7dfaa, #c99d45);
    border-radius: 13px;
    box-shadow: 0 5px 16px rgba(201,157,69,.22);
    font-size: 21px;
}

.brand-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.55;
}

    .brand-text strong {
        color: #fff;
        font-size: 17px;
        font-weight: 900;
        letter-spacing: .3px;
    }

    .brand-text span {
        color: #b9c9dc;
        font-size: 9px;
        white-space: nowrap;
    }

.sidebar-close {
    width: 33px;
    height: 33px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 9px;
    color: #fff;
    background: rgba(255,255,255,.08);
}

.sidebar-user {
    margin: 14px 12px 10px;
    padding: 11px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 13px;
    background: rgba(255,255,255,.07);
}

.sidebar-avatar {
    width: 39px;
    height: 39px;
    flex: 0 0 39px;
    display: grid;
    place-items: center;
    color: var(--primary);
    background: #fff;
    border-radius: 11px;
    font-size: 18px;
}

.sidebar-user-info {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

    .sidebar-user-info strong {
        overflow: hidden;
        color: #fff;
        font-size: 11px;
        font-weight: 800;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .sidebar-user-info span {
        color: #e5c77e;
        font-size: 10px;
    }

.user-status {
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    background: #3bd49b;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(59,212,155,.12);
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 5px 11px 18px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.2) transparent;
}

    .sidebar-nav::-webkit-scrollbar {
        width: 4px;
    }

    .sidebar-nav::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,.2);
        border-radius: 8px;
    }

.nav-section-title {
    padding: 17px 12px 6px;
    color: #94abc5;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .3px;
}

.nav-item-custom {
    position: relative;
    width: 100%;
    min-height: 43px;
    margin: 3px 0;
    padding: 7px 10px;
    display: flex;
    align-items: center;
    gap: 11px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: #dce7f3;
    background: transparent;
    text-align: right;
    font-size: 11px;
    font-weight: 700;
    transition: var(--transition);
}

    .nav-item-custom:hover {
        color: #fff;
        background: rgba(255,255,255,.09);
    }

    .nav-item-custom.active {
        color: #193657;
        background: linear-gradient(100deg, #f3d99e, #d9b15e);
        border-color: rgba(255,255,255,.45);
        box-shadow: 0 5px 15px rgba(0,0,0,.10);
    }

.nav-item-icon {
    width: 29px;
    height: 29px;
    flex: 0 0 29px;
    display: grid;
    place-items: center;
    color: #e8c77d;
    background: rgba(255,255,255,.10);
    border-radius: 8px;
    font-size: 15px;
}

.nav-item-custom.active .nav-item-icon {
    color: #173b67;
    background: rgba(255,255,255,.55);
}

.nav-item-label {
    flex: 1;
    white-space: nowrap;
}

.nav-chevron {
    margin-right: auto;
    font-size: 10px;
    transition: transform var(--transition);
}

.nav-toggle[aria-expanded="true"] .nav-chevron {
    transform: rotate(180deg);
}

.submenu {
    margin: 2px 15px 7px 0;
    padding: 3px 9px 3px 0;
    border-right: 1px solid rgba(231,194,113,.45);
}

    .submenu a {
        min-height: 34px;
        padding: 6px 9px;
        display: flex;
        align-items: center;
        gap: 9px;
        border-radius: 8px;
        color: #bdcddd;
        font-size: 10px;
        font-weight: 600;
        transition: var(--transition);
    }

        .submenu a i {
            font-size: 12px;
        }

        .submenu a:hover {
            color: #fff;
            background: rgba(255,255,255,.09);
        }

        .submenu a.active {
            color: #f2d38d;
            background: rgba(231,194,113,.12);
        }

.sidebar-footer {
    padding: 13px 15px;
    border-top: 1px solid rgba(255,255,255,.12);
    background: rgba(0,0,0,.08);
}

.sidebar-footer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #e8c77d;
}

    .sidebar-footer-brand > i {
        font-size: 21px;
    }

    .sidebar-footer-brand div {
        display: flex;
        flex-direction: column;
        line-height: 1.55;
    }

    .sidebar-footer-brand strong {
        color: #fff;
        font-size: 11px;
    }

    .sidebar-footer-brand span {
        color: #aebfd2;
        font-size: 9px;
    }

.sidebar-version {
    margin-top: 8px;
    color: #8299b3;
    text-align: center;
    font-size: 9px;
}

/* =========================================================
   SIDEBAR COLLAPSED — DESKTOP
========================================================= */

@media (min-width: 992px) {

    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-mini-width);
    }

    body.sidebar-collapsed .main-wrapper {
        width: calc(100% - var(--sidebar-mini-width));
        margin-right: var(--sidebar-mini-width);
    }

    body.sidebar-collapsed .brand-text,
    body.sidebar-collapsed .sidebar-user-info,
    body.sidebar-collapsed .user-status,
    body.sidebar-collapsed .nav-section-title,
    body.sidebar-collapsed .nav-item-label,
    body.sidebar-collapsed .nav-chevron,
    body.sidebar-collapsed .submenu,
    body.sidebar-collapsed .sidebar-footer-brand div,
    body.sidebar-collapsed .sidebar-version {
        display: none !important;
    }

    body.sidebar-collapsed .sidebar-brand {
        justify-content: center;
        padding-inline: 8px;
    }

    body.sidebar-collapsed .sidebar-user {
        justify-content: center;
        padding: 8px 4px;
    }

    body.sidebar-collapsed .nav-item-custom {
        justify-content: center;
        padding-inline: 5px;
    }

    body.sidebar-collapsed .nav-item-icon {
        width: 36px;
        height: 36px;
        flex-basis: 36px;
    }

    body.sidebar-collapsed .sidebar-footer-brand {
        justify-content: center;
    }
}

/* =========================================================
   MOBILE OVERLAY
========================================================= */

.sidebar-overlay {
    position: fixed;
    z-index: 1040;
    inset: 0;
    visibility: hidden;
    opacity: 0;
    background: rgba(11, 27, 48, .45);
    backdrop-filter: blur(3px);
    transition: var(--transition);
}

    .sidebar-overlay.show {
        visibility: visible;
        opacity: 1;
    }

/* =========================================================
   TOPBAR
========================================================= */

.topbar {
    position: sticky;
    z-index: 1000;
    top: 0;
    min-height: var(--topbar-height);
    padding: 10px 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    background: rgba(255,255,255,.94);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(15px);
}

.topbar-right,
.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.sidebar-toggle {
    width: 39px;
    height: 39px;
    flex: 0 0 39px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--primary);
    background: #fff;
    font-size: 17px;
    transition: var(--transition);
}

    .sidebar-toggle:hover {
        color: #fff;
        background: var(--primary);
        border-color: var(--primary);
    }

.topbar-title {
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

    .topbar-title > span {
        color: var(--text-muted);
        font-size: 9px;
    }

    .topbar-title h1 {
        margin: 0;
        color: var(--text-main);
        font-size: 16px;
        font-weight: 900;
    }

.topbar-icon-button {
    position: relative;
    width: 39px;
    height: 39px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: #53677f;
    background: #fff;
    font-size: 16px;
    transition: var(--transition);
}

    .topbar-icon-button:hover {
        color: var(--primary);
        background: var(--primary-light);
    }

.notification-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 7px;
    height: 7px;
    border: 1px solid #fff;
    border-radius: 50%;
    background: #e45d5d;
}

.topbar-date {
    height: 39px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-secondary);
    background: #fff;
    font-size: 10px;
    font-weight: 700;
}

    .topbar-date i {
        color: var(--accent);
        font-size: 14px;
    }

.user-menu-button {
    min-height: 43px;
    padding: 3px 7px;
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid transparent;
    border-radius: 11px;
    background: transparent;
    color: var(--text-main);
}

    .user-menu-button:hover {
        background: var(--surface-soft);
        border-color: var(--border);
    }

    .user-menu-button::after {
        margin-right: 5px;
    }

.top-user-avatar {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    color: var(--primary);
    background: var(--primary-light);
    border-radius: 10px;
    font-size: 17px;
}

.top-user-info {
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.5;
}

    .top-user-info strong {
        font-size: 10px;
        font-weight: 800;
    }

    .top-user-info small {
        color: var(--text-muted);
        font-size: 9px;
    }

.user-dropdown {
    min-width: 210px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 13px;
    box-shadow: var(--shadow-lg);
}

.user-dropdown-header {
    padding: 9px 10px;
    display: flex;
    flex-direction: column;
}

    .user-dropdown-header strong {
        color: var(--text-main);
        font-size: 12px;
    }

    .user-dropdown-header span {
        color: var(--text-muted);
        font-size: 10px;
    }

.user-dropdown .dropdown-item {
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 11px;
}

    .user-dropdown .dropdown-item i {
        margin-left: 8px;
    }

/* =========================================================
   PAGE CONTENT
========================================================= */

.content-wrapper {
    flex: 1;
    min-width: 0;
    padding: 24px;
}

.page-container {
    width: 100%;
    max-width: 1800px;
    margin-inline: auto;
}

/* =========================================================
   FOOTER
========================================================= */

.main-footer {
    min-height: 53px;
    padding: 12px 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--text-muted);
    background: #fff;
    border-top: 1px solid var(--border);
    font-size: 10px;
}

    .main-footer strong {
        color: var(--primary);
        font-weight: 900;
    }

.footer-developer {
    direction: ltr;
    text-align: left;
}

/* =========================================================
   MOBILE BOTTOM NAVIGATION
========================================================= */

.mobile-bottom-nav {
    display: none;
}

/* =========================================================
   GLOBAL COMPONENTS
========================================================= */

/* Cards */

.card,
.erp-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 15px 18px;
    color: var(--text-main);
    background: #fff;
    border-bottom: 1px solid var(--border);
    font-weight: 800;
}

.card-body {
    padding: 18px;
}

/* Buttons */

.btn {
    min-height: 37px;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 700;
    transition: var(--transition);
}

.btn-primary {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

    .btn-primary:hover {
        color: #fff;
        background: var(--primary-dark);
        border-color: var(--primary-dark);
        transform: translateY(-1px);
    }

.btn-gold {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
}

    .btn-gold:hover {
        color: #fff;
        background: #ad8231;
    }

/* Forms */

.form-control,
.form-select {
    min-height: 40px;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    color: var(--text-main);
    background-color: #fff;
    font-size: 11px;
}

    .form-control:focus,
    .form-select:focus {
        border-color: #83a6d0;
        box-shadow: 0 0 0 3px rgba(39,101,166,.10);
    }

.form-label {
    margin-bottom: 6px;
    color: #40536b;
    font-size: 11px;
    font-weight: 800;
}

/* Tables */

.table-responsive {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
}

.table {
    margin-bottom: 0;
    color: var(--text-main);
    font-size: 11px;
    vertical-align: middle;
}

    .table thead th {
        padding: 13px 12px;
        color: #50637c;
        background: #f5f8fc;
        border-bottom: 1px solid var(--border);
        font-weight: 900;
        white-space: nowrap;
    }

    .table tbody td {
        padding: 12px;
        border-color: #edf0f5;
    }

    .table tbody tr:hover {
        background: #f8fafd;
    }

/* Badges */

.badge {
    padding: 6px 9px;
    border-radius: 7px;
    font-size: 9px;
    font-weight: 800;
}

/* Alerts */

.alert {
    border: 1px solid transparent;
    border-radius: 11px;
    font-size: 11px;
}

/* Modals */

.modal-content {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 16px 20px;
    background: #f8fafd;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    color: var(--primary-dark);
    font-size: 14px;
    font-weight: 900;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 13px 20px;
    border-top: 1px solid var(--border);
}

/* Dropdown */

.dropdown-menu {
    border-color: var(--border);
    border-radius: 11px;
    box-shadow: var(--shadow-md);
    font-size: 11px;
}

.dropdown-item {
    padding: 8px 12px;
}

    .dropdown-item:active {
        background: var(--primary);
    }

/* Pagination */

.pagination {
    gap: 4px;
}

.page-link {
    min-width: 32px;
    border: 1px solid var(--border);
    border-radius: 7px !important;
    color: var(--primary);
    text-align: center;
    font-size: 10px;
}

.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
}

/* =========================================================
   RESPONSIVE TABLET
========================================================= */

@media (max-width: 1200px) {

    .content-wrapper {
        padding: 19px;
    }

    .topbar {
        padding-inline: 19px;
    }
}

/* =========================================================
   RESPONSIVE MOBILE
========================================================= */

@media (max-width: 991.98px) {

    .sidebar {
        width: min(290px, 86vw);
        transform: translateX(105%);
        box-shadow: -10px 0 35px rgba(0,0,0,.15);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .main-wrapper {
        width: 100%;
        margin-right: 0;
    }

    body.sidebar-collapsed .main-wrapper {
        width: 100%;
        margin-right: 0;
    }

    body.sidebar-collapsed .sidebar {
        width: min(290px, 86vw);
    }

    body.sidebar-collapsed .brand-text,
    body.sidebar-collapsed .sidebar-user-info,
    body.sidebar-collapsed .user-status,
    body.sidebar-collapsed .nav-section-title,
    body.sidebar-collapsed .nav-item-label,
    body.sidebar-collapsed .nav-chevron,
    body.sidebar-collapsed .submenu,
    body.sidebar-collapsed .sidebar-footer-brand div,
    body.sidebar-collapsed .sidebar-version {
        display: initial;
    }

    body.sidebar-collapsed .nav-section-title {
        display: block;
    }

    body.sidebar-collapsed .brand-text,
    body.sidebar-collapsed .sidebar-user-info,
    body.sidebar-collapsed .nav-item-label,
    body.sidebar-collapsed .nav-chevron {
        display: flex;
    }

    body.sidebar-collapsed .submenu {
        display: block;
    }

    body.sidebar-collapsed .sidebar-brand {
        justify-content: flex-start;
    }

    body.sidebar-collapsed .sidebar-user {
        justify-content: flex-start;
    }

    body.sidebar-collapsed .nav-item-custom {
        justify-content: flex-start;
    }

    body.sidebar-collapsed .nav-item-icon {
        width: 29px;
        height: 29px;
        flex-basis: 29px;
    }

    body.sidebar-collapsed .sidebar-footer-brand {
        justify-content: flex-start;
    }

    .topbar {
        min-height: 66px;
        padding: 9px 13px;
    }

    .topbar-right,
    .topbar-left {
        gap: 8px;
    }

    .topbar-title h1 {
        font-size: 13px;
    }

    .topbar-title > span {
        font-size: 8px;
    }

    .content-wrapper {
        padding: 14px 12px 90px;
    }

    .main-footer {
        padding: 10px 14px;
        margin-bottom: 66px;
        font-size: 9px;
    }

    .mobile-bottom-nav {
        position: fixed;
        z-index: 1030;
        right: 0;
        bottom: 0;
        left: 0;
        min-height: 65px;
        padding: 6px 7px calc(6px + env(safe-area-inset-bottom));
        display: flex;
        align-items: center;
        justify-content: space-around;
        background: rgba(255,255,255,.97);
        border-top: 1px solid var(--border);
        box-shadow: 0 -5px 20px rgba(20,40,70,.07);
        backdrop-filter: blur(12px);
    }

    .mobile-nav-item {
        min-width: 55px;
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 5px 2px;
        border: 0;
        border-radius: 10px;
        color: #8492a5;
        background: transparent;
        font-size: 9px;
        font-weight: 700;
    }

        .mobile-nav-item i {
            font-size: 18px;
            line-height: 1.2;
        }

        .mobile-nav-item.active {
            color: var(--primary);
            background: var(--primary-light);
        }

            .mobile-nav-item.active i {
                color: var(--accent);
            }
}

/* =========================================================
   SMALL MOBILE
========================================================= */

@media (max-width: 575.98px) {

    body {
        font-size: 12px;
    }

    .topbar {
        min-height: 61px;
        padding-inline: 9px;
    }

    .sidebar-toggle,
    .topbar-icon-button {
        width: 35px;
        height: 35px;
        flex-basis: 35px;
        font-size: 15px;
    }

    .topbar-title h1 {
        font-size: 12px;
    }

    .topbar-title > span {
        display: none;
    }

    .topbar-left {
        gap: 5px;
    }

    .user-menu-button {
        padding: 2px;
    }

    .top-user-avatar {
        width: 33px;
        height: 33px;
    }

    .content-wrapper {
        padding: 10px 9px 85px;
    }

    .page-container {
        width: 100%;
    }

    .main-footer {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 4px;
    }

    .footer-developer {
        text-align: center;
    }

    .card-body {
        padding: 13px;
    }

    .modal-body {
        padding: 14px;
    }
}

/* =========================================================
   ACCESSIBILITY AND MOTION
========================================================= */

:focus-visible {
    outline: 3px solid rgba(46,112,185,.35);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
    }
}

/* =========================================================
   PRINT
========================================================= */

@media print {

    body {
        background: #fff !important;
    }

    .sidebar,
    .topbar,
    .mobile-bottom-nav,
    .main-footer,
    .sidebar-overlay,
    .no-print {
        display: none !important;
    }

    .main-wrapper {
        width: 100% !important;
        margin: 0 !important;
    }

    .content-wrapper {
        padding: 0 !important;
    }

    .card,
    .erp-card {
        box-shadow: none !important;
    }
}
