/* AlHayan CRM - Purple Theme */
@font-face { font-family: 'Poppins'; font-weight: 300; font-display: swap; src: url('../vendor/fonts/poppins-latin-300-normal.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 400; font-display: swap; src: url('../vendor/fonts/poppins-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 500; font-display: swap; src: url('../vendor/fonts/poppins-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 600; font-display: swap; src: url('../vendor/fonts/poppins-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 700; font-display: swap; src: url('../vendor/fonts/poppins-latin-700-normal.woff2') format('woff2'); }

:root {
    --ah-primary: #6d28d9;
    --ah-primary-rgb: 109, 40, 217;
    --ah-primary-dark: #4c1d95;
    --ah-primary-light: #ede9fe;
    --ah-accent: #a855f7;
    --ah-sidebar: #2e1065;
    --ah-sidebar-2: #4c1d95;
    --ah-bg: #f6f4fb;
    --ah-card: #ffffff;
    --ah-border: #e7e3f1;
    --ah-text: #1f1633;
    --ah-muted: #6b6485;
    --sidebar-w: 260px;
    --bs-primary: #6d28d9;
    --bs-primary-rgb: 109, 40, 217;
    --bs-link-color: #6d28d9;
    --bs-link-color-rgb: 109, 40, 217;
    --bs-link-hover-color: #4c1d95;
    --bs-body-font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --bs-body-font-size: .875rem;
    --bs-body-color: #1f1633;
    --bs-border-color: #e7e3f1;
}
body { background: var(--ah-bg); color: var(--ah-text); }
a { text-decoration: none; }

/* buttons */
.btn-primary { --bs-btn-bg: var(--ah-primary); --bs-btn-border-color: var(--ah-primary); --bs-btn-hover-bg: var(--ah-primary-dark); --bs-btn-hover-border-color: var(--ah-primary-dark); --bs-btn-active-bg: var(--ah-primary-dark); --bs-btn-active-border-color: var(--ah-primary-dark); --bs-btn-disabled-bg: #a78bfa; --bs-btn-disabled-border-color: #a78bfa; }
.btn-outline-primary { --bs-btn-color: var(--ah-primary); --bs-btn-border-color: var(--ah-primary); --bs-btn-hover-bg: var(--ah-primary); --bs-btn-hover-border-color: var(--ah-primary); --bs-btn-active-bg: var(--ah-primary-dark); --bs-btn-active-border-color: var(--ah-primary-dark); }
.btn-soft { background: var(--ah-primary-light); color: var(--ah-primary); border: 0; }
.btn-soft:hover { background: #ddd6fe; color: var(--ah-primary-dark); }
.btn-icon { background: transparent; border: 0; padding: .25rem .5rem; }
.btn-xs { padding: .15rem .45rem; font-size: .75rem; border-radius: .35rem; }
.text-primary { color: var(--ah-primary) !important; }
.bg-primary { background-color: var(--ah-primary) !important; }
.form-control:focus, .form-select:focus { border-color: #a78bfa; box-shadow: 0 0 0 .2rem rgba(var(--ah-primary-rgb), .15); }
.form-check-input:checked { background-color: var(--ah-primary); border-color: var(--ah-primary); }
.form-label { font-weight: 500; font-size: .8rem; color: #3b3355; margin-bottom: .3rem; }
.form-control, .form-select { font-size: .875rem; border-color: #ddd7ec; }
.nav-pills .nav-link.active { background: var(--ah-primary); }
.nav-tabs .nav-link.active { color: var(--ah-primary); border-bottom: 2px solid var(--ah-primary); }
.nav-tabs .nav-link { color: var(--ah-muted); border: 0; font-weight: 500; }
.page-link { color: var(--ah-primary); }
.active > .page-link, .page-link.active { background: var(--ah-primary); border-color: var(--ah-primary); }
.dropdown-item.active, .dropdown-item:active { background: var(--ah-primary); }

/* layout */
.app-wrapper { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: linear-gradient(180deg, var(--ah-sidebar) 0%, var(--ah-sidebar-2) 100%); color: #ddd6fe; position: fixed; top: 0; bottom: 0; left: 0; z-index: 1040; display: flex; flex-direction: column; transition: transform .25s; }
.sidebar-brand { padding: 1.1rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-logo { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, #a855f7, #7c3aed); color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; margin-right: .65rem; box-shadow: 0 4px 12px rgba(168,85,247,.4); }
.brand-text { color: #fff; font-size: 1.1rem; font-weight: 500; }
.brand-text b { color: #c4b5fd; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .65rem; }
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 5px; }
.sidebar .nav-link { display: flex; align-items: center; gap: .7rem; color: #ddd6fe; padding: .6rem .8rem; border-radius: .55rem; font-weight: 500; margin-bottom: 2px; }
.sidebar .nav-link i:first-child { font-size: 1.05rem; width: 20px; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar .nav-link.active { background: linear-gradient(90deg, #7c3aed, #9333ea); color: #fff; box-shadow: 0 4px 14px rgba(124,58,237,.45); }
.sidebar .nav-link .caret { margin-left: auto; font-size: .7rem; transition: transform .2s; }
.sidebar .nav-link.collapsed .caret { transform: rotate(-90deg); }
.nav-sublink { display: block; color: #c4b5fd; padding: .42rem .8rem .42rem 2.85rem; border-radius: .5rem; font-size: .83rem; position: relative; }
.nav-sublink::before { content: ''; position: absolute; left: 1.6rem; top: 50%; width: 6px; height: 6px; border-radius: 50%; background: rgba(196,181,253,.45); transform: translateY(-50%); }
.nav-sublink:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-sublink.active { color: #fff; background: rgba(255,255,255,.1); }
.nav-sublink.active::before { background: #e9d5ff; box-shadow: 0 0 0 3px rgba(233,213,255,.25); }
.sidebar-foot { padding: .75rem 1.25rem; color: rgba(221,214,254,.5); border-top: 1px solid rgba(255,255,255,.08); }
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 64px; background: #fff; border-bottom: 1px solid var(--ah-border); display: flex; align-items: center; padding: 0 1.5rem; gap: 1rem; position: sticky; top: 0; z-index: 1030; }
.topbar-title { font-weight: 600; font-size: 1rem; color: var(--ah-text); }
.btn-branch { background: var(--ah-primary-light); color: var(--ah-primary-dark); border: 0; font-weight: 500; font-size: .82rem; }
.btn-branch:hover, .btn-branch.show { background: #ddd6fe; color: var(--ah-primary-dark); }
.btn-branch.disabled { opacity: 1; }
.btn-user { display: flex; align-items: center; gap: .55rem; border: 0; background: transparent; padding: .2rem .4rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #8b5cf6, #6d28d9); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .8rem; flex-shrink: 0; }
.avatar-sm { width: 28px; height: 28px; font-size: .7rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }
.content { padding: 1.5rem; flex: 1; }
.app-footer { padding: .9rem 1.5rem; border-top: 1px solid var(--ah-border); background: #fff; display: flex; justify-content: space-between; font-size: .78rem; color: var(--ah-muted); flex-wrap: wrap; gap: .5rem; }
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(20,10,40,.45); z-index: 1035; }
    .main { margin-left: 0; }
    .content { padding: 1rem; }
    .topbar { padding: 0 1rem; }
}

/* cards */
.card { border: 1px solid var(--ah-border); border-radius: .85rem; box-shadow: 0 1px 3px rgba(46,16,101,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--ah-border); padding: .9rem 1.2rem; font-weight: 600; border-radius: .85rem .85rem 0 0 !important; }
.card-body { padding: 1.2rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; margin-bottom: 1.2rem; }
.page-head h1 { font-size: 1.3rem; font-weight: 600; margin: 0; }
.page-head .sub { color: var(--ah-muted); font-size: .82rem; }
.stat-card { border-radius: .95rem; padding: 1.1rem 1.2rem; background: #fff; border: 1px solid var(--ah-border); display: flex; align-items: center; gap: 1rem; height: 100%; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.35rem; flex-shrink: 0; }
.stat-label { color: var(--ah-muted); font-size: .78rem; font-weight: 500; }
.stat-value { font-size: 1.3rem; font-weight: 600; line-height: 1.3; }
.stat-hero { background: linear-gradient(135deg, #6d28d9 0%, #9333ea 60%, #c026d3 100%); color: #fff; border: 0; }
.stat-hero .stat-label { color: #ede9fe; }
.stat-hero .stat-icon { background: rgba(255,255,255,.18) !important; color: #fff !important; }
.bg-soft-primary { background: #ede9fe; color: #6d28d9; }
.bg-soft-success { background: #dcfce7; color: #15803d; }
.bg-soft-warning { background: #fef3c7; color: #b45309; }
.bg-soft-danger { background: #fee2e2; color: #b91c1c; }
.bg-soft-info { background: #e0f2fe; color: #0369a1; }
.bg-soft-pink { background: #fce7f3; color: #be185d; }
.badge { font-weight: 500; padding: .38em .65em; border-radius: .4rem; }
.badge-soft-success { background: #dcfce7; color: #15803d; }
.badge-soft-warning { background: #fef3c7; color: #b45309; }
.badge-soft-danger { background: #fee2e2; color: #b91c1c; }
.badge-soft-info { background: #e0f2fe; color: #0369a1; }
.badge-soft-primary { background: #ede9fe; color: #6d28d9; }
.badge-soft-secondary { background: #f1f0f5; color: #57516b; }
.badge-soft-dark { background: #e5e7eb; color: #1f2937; }

/* tables */
.table { --bs-table-color: var(--ah-text); margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .65rem .75rem; border-color: #efecf6; }
.table thead th { background: #faf8ff; color: #4b4366; font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; border-bottom: 1px solid var(--ah-border); }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #faf7ff; }
.table tfoot td, .table tfoot th { font-weight: 600; background: #faf8ff; }
.table .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.actions { white-space: nowrap; text-align: right; }
.actions .btn { padding: .2rem .45rem; }
div.dt-container .dt-search input { border-radius: .5rem; }
div.dt-container .dt-buttons .btn { background: #fff; color: #4b4366; border-color: var(--ah-border); font-size: .78rem; }
div.dt-container .dt-buttons .btn:hover { background: var(--ah-primary-light); color: var(--ah-primary); }
div.dt-container .dt-paging .page-item.active .page-link { background: var(--ah-primary); border-color: var(--ah-primary); }
div.dt-container { font-size: .85rem; }
.dt-layout-row:first-child { margin-top: 0 !important; }

/* select2 */
.select2-container--bootstrap-5 .select2-selection { border-color: #ddd7ec; font-size: .875rem; min-height: calc(1.5em + .75rem + 2px); }
.select2-container--bootstrap-5.select2-container--focus .select2-selection, .select2-container--bootstrap-5.select2-container--open .select2-selection { border-color: #a78bfa; box-shadow: 0 0 0 .2rem rgba(var(--ah-primary-rgb), .15); }
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option.select2-results__option--highlighted { background-color: var(--ah-primary-light); color: var(--ah-primary-dark); }
.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option.select2-results__option--selected { background-color: var(--ah-primary); color: #fff; }
.items-table .select2-container { min-width: 220px; }

/* line items editor */
.items-table td { vertical-align: top; }
.items-table input.form-control, .items-table select.form-select { font-size: .83rem; padding: .35rem .5rem; }
.items-table .col-qty { width: 90px; } .items-table .col-price { width: 120px; } .items-table .col-disc { width: 100px; }
.items-table .col-tax { width: 130px; } .items-table .col-total { width: 130px; } .items-table .col-del { width: 40px; }
.totals-box { background: #faf8ff; border: 1px solid var(--ah-border); border-radius: .75rem; padding: 1rem; }
.totals-box .row-t { display: flex; justify-content: space-between; padding: .3rem 0; }
.totals-box .grand { font-size: 1.15rem; font-weight: 700; color: var(--ah-primary-dark); border-top: 1px dashed #cfc6e6; margin-top: .4rem; padding-top: .6rem; }

/* kanban */
.kanban { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.kanban-col { flex: 0 0 290px; background: #efebf8; border-radius: .85rem; padding: .75rem; }
.kanban-col h6 { font-weight: 600; font-size: .85rem; display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.kanban-list { min-height: 80px; }
.kanban-card { background: #fff; border-radius: .65rem; padding: .75rem .85rem; margin-bottom: .6rem; border: 1px solid var(--ah-border); cursor: grab; box-shadow: 0 1px 2px rgba(46,16,101,.05); }
.kanban-card:hover { border-color: #c4b5fd; }
.kanban-card .title { font-weight: 600; font-size: .85rem; }
.sortable-ghost { opacity: .4; }

/* timeline */
.timeline { position: relative; padding-left: 1.5rem; }
.timeline::before { content: ''; position: absolute; left: .45rem; top: 0; bottom: 0; width: 2px; background: #e9e3f7; }
.tl-item { position: relative; padding-bottom: 1rem; }
.tl-item::before { content: ''; position: absolute; left: -1.3rem; top: .3rem; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--ah-primary); }
.tl-item.done::before { border-color: #22c55e; }

/* misc */
.profile-head { display: flex; gap: 1rem; align-items: center; }
.kv { display: flex; justify-content: space-between; padding: .45rem 0; border-bottom: 1px dashed #eee9f7; font-size: .85rem; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--ah-muted); }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--ah-muted); }
.empty-state i { font-size: 2.5rem; color: #c4b5fd; }
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.chart-box { position: relative; height: 290px; }
.filter-bar { background: #fff; border: 1px solid var(--ah-border); border-radius: .85rem; padding: .85rem 1rem; margin-bottom: 1rem; }
.report-tile { display: flex; gap: .85rem; align-items: flex-start; padding: 1rem; border: 1px solid var(--ah-border); border-radius: .8rem; background: #fff; color: var(--ah-text); height: 100%; transition: all .15s; }
.report-tile:hover { border-color: #a78bfa; box-shadow: 0 6px 18px rgba(109,40,217,.1); transform: translateY(-2px); color: var(--ah-text); }
.report-tile i { font-size: 1.4rem; }
.report-tile small { color: var(--ah-muted); display: block; }
.acc-group { font-weight: 600; background: #faf8ff; }
.acc-l1 td:first-child { padding-left: 1.8rem !important; }
.acc-l2 td:first-child { padding-left: 3.2rem !important; }
.acc-l3 td:first-child { padding-left: 4.6rem !important; }

/* login */
.login-page { min-height: 100vh; display: flex; background: linear-gradient(135deg, #2e1065 0%, #5b21b6 55%, #9333ea 100%); }
.login-side { flex: 1; color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: center; }
.login-side h1 { font-weight: 700; font-size: 2.4rem; }
.login-side p { color: #ddd6fe; max-width: 460px; }
.login-feat { display: flex; gap: .6rem; align-items: center; color: #ede9fe; margin-bottom: .6rem; }
.login-box { width: 460px; max-width: 100%; background: #fff; display: flex; flex-direction: column; justify-content: center; padding: 3rem; }
@media (max-width: 767.98px) { .login-side { display: none; } .login-box { width: 100%; padding: 2rem 1.25rem; } }

/* POS */
.pos-wrap { display: grid; grid-template-columns: 1fr 420px; gap: 1rem; }
.pos-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: .75rem; max-height: calc(100vh - 290px); overflow-y: auto; padding: .2rem; }
.pos-item { background: #fff; border: 1px solid var(--ah-border); border-radius: .75rem; padding: .8rem; cursor: pointer; transition: all .12s; text-align: left; }
.pos-item:hover { border-color: #8b5cf6; box-shadow: 0 4px 14px rgba(109,40,217,.12); }
.pos-item .ico { width: 40px; height: 40px; border-radius: 10px; background: var(--ah-primary-light); color: var(--ah-primary); display: flex; align-items: center; justify-content: center; font-weight: 700; margin-bottom: .5rem; }
.pos-item .nm { font-weight: 600; font-size: .82rem; line-height: 1.25; min-height: 2.1em; }
.pos-item .pr { color: var(--ah-primary); font-weight: 700; }
.pos-cart { background: #fff; border: 1px solid var(--ah-border); border-radius: .85rem; display: flex; flex-direction: column; height: calc(100vh - 150px); position: sticky; top: 80px; }
.pos-cart-items { flex: 1; overflow-y: auto; }
.pos-cart-items table td { vertical-align: middle; padding: .45rem .5rem; }
.pos-cart .qty-input { width: 58px; text-align: center; padding: .2rem; }
.pos-total { background: linear-gradient(135deg, #6d28d9, #9333ea); color: #fff; border-radius: .65rem; padding: .8rem 1rem; }
@media (max-width: 1199.98px) { .pos-wrap { grid-template-columns: 1fr; } .pos-cart { height: auto; position: static; } .pos-products { max-height: none; } }

/* print */
.doc-print { background: #fff; max-width: 900px; margin: 0 auto; padding: 2.2rem; border-radius: .85rem; border: 1px solid var(--ah-border); }
.doc-print .doc-title { font-size: 1.8rem; font-weight: 700; color: var(--ah-primary); letter-spacing: .04em; }
.doc-print table thead th { background: var(--ah-primary) !important; color: #fff !important; }
@media print {
    .sidebar, .topbar, .app-footer, .no-print, .alert, .dt-buttons, .dt-search, .dt-length, .dt-paging, .dt-info { display: none !important; }
    .main { margin: 0 !important; }
    .content { padding: 0 !important; }
    body { background: #fff; }
    .card, .doc-print { border: 0 !important; box-shadow: none !important; }
    .doc-print { padding: 0; }
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}
