/* =====================================================================
   ABANEESH AGENCY - Bootstrap 5 theme
   ===================================================================== */
:root {
    --app-primary: #4f46e5;
    --app-primary-rgb: 79, 70, 229;
    --app-primary-dark: #4338ca;
    --app-accent: #06b6d4;
    --app-bg: #f4f6fb;
    --app-surface: #ffffff;
    --app-border: #e5e7eb;
    --app-text: #1f2937;
    --app-muted: #6b7280;
    --app-sidebar: #0f172a;
    --app-sidebar-2: #1e293b;
    --app-sidebar-text: #cbd5e1;
    --app-sidebar-w: 260px;
    --app-topbar-h: 64px;
    --app-radius: .75rem;
    --app-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .08);
    --app-shadow-lg: 0 12px 24px -6px rgba(16, 24, 40, .12);

    --bs-primary: var(--app-primary);
    --bs-primary-rgb: var(--app-primary-rgb);
    --bs-link-color: var(--app-primary);
    --bs-link-color-rgb: var(--app-primary-rgb);
    --bs-link-hover-color: var(--app-primary-dark);
    --bs-body-font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-font-size: .925rem;
    --bs-body-color: var(--app-text);
    --bs-border-radius: .5rem;
}

body.app { background: var(--app-bg); }

.btn-primary {
    --bs-btn-bg: var(--app-primary); --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary-dark); --bs-btn-hover-border-color: var(--app-primary-dark);
    --bs-btn-active-bg: var(--app-primary-dark); --bs-btn-active-border-color: var(--app-primary-dark);
    --bs-btn-disabled-bg: var(--app-primary); --bs-btn-disabled-border-color: var(--app-primary);
}
.btn-outline-primary {
    --bs-btn-color: var(--app-primary); --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary); --bs-btn-hover-border-color: var(--app-primary);
    --bs-btn-active-bg: var(--app-primary-dark);
}
.text-primary { color: var(--app-primary) !important; }
.bg-primary { background-color: var(--app-primary) !important; }
.form-control:focus, .form-select:focus {
    border-color: rgba(var(--app-primary-rgb), .55);
    box-shadow: 0 0 0 .2rem rgba(var(--app-primary-rgb), .15);
}

/* ----------------------------------------------------------- layout */
.app-wrapper { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--app-sidebar-w);
    background: linear-gradient(180deg, var(--app-sidebar) 0%, var(--app-sidebar-2) 100%);
    color: var(--app-sidebar-text);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
    flex-shrink: 0;
    z-index: 1040;
}
@media (max-width: 991.98px) {
    .app-sidebar { position: fixed; height: 100%; }
    .app-sidebar.offcanvas-lg { --bs-offcanvas-width: var(--app-sidebar-w); background: var(--app-sidebar); }
}
.sidebar-brand {
    height: var(--app-topbar-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1rem; border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-link { display: flex; align-items: center; gap: .65rem; color: #fff; text-decoration: none; }
.brand-mark {
    width: 38px; height: 38px; border-radius: .65rem;
    background: linear-gradient(135deg, var(--app-primary), var(--app-accent));
    display: grid; place-items: center; font-weight: 800; font-size: 1.15rem; color: #fff;
    box-shadow: 0 6px 14px rgba(var(--app-primary-rgb), .45);
}
.brand-text { font-weight: 700; letter-spacing: .02em; line-height: 1.1; font-size: .95rem; }
.brand-text small { display: block; font-weight: 400; font-size: .7rem; color: #94a3b8; letter-spacing: .04em; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .6rem; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }
.sidebar-nav .nav-link {
    color: var(--app-sidebar-text); display: flex; align-items: center; gap: .7rem;
    padding: .55rem .8rem; border-radius: .55rem; font-size: .9rem; transition: background .15s, color .15s;
}
.sidebar-nav .nav-link > .bi:first-child { font-size: 1.1rem; width: 1.25rem; text-align: center; opacity: .85; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link.active { background: rgba(var(--app-primary-rgb), .9); color: #fff; box-shadow: 0 4px 12px rgba(var(--app-primary-rgb), .35); }
.sidebar-nav .chevron { font-size: .75rem; transition: transform .2s; }
.sidebar-nav .nav-toggle:not(.collapsed) .chevron { transform: rotate(180deg); }
.sidebar-nav .nav-toggle:not(.collapsed) { color: #fff; }
.sidebar-nav .sub-menu { list-style: none; padding: .25rem 0 .4rem 2.35rem; margin: 0; }
.sidebar-nav .sub-menu .nav-link { padding: .38rem .7rem; font-size: .85rem; color: #94a3b8; position: relative; }
.sidebar-nav .sub-menu .nav-link::before {
    content: ""; position: absolute; left: -.9rem; top: 50%; width: 5px; height: 5px; border-radius: 50%;
    background: currentColor; opacity: .5; transform: translateY(-50%);
}
.sidebar-nav .sub-menu .nav-link.active { background: rgba(255,255,255,.08); color: #fff; box-shadow: none; }
.sidebar-footer { padding: .75rem 1rem; font-size: .75rem; color: #94a3b8; border-top: 1px solid rgba(255,255,255,.06); }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
    height: var(--app-topbar-h); background: rgba(255,255,255,.9); backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--app-border); position: sticky; top: 0; z-index: 1030;
    display: flex; align-items: center; gap: 1rem; padding: 0 1.25rem;
}
.topbar-title h1 { font-weight: 700; }
.topbar-title .breadcrumb { font-size: .75rem; --bs-breadcrumb-divider-color: var(--app-muted); }
.topbar-title .breadcrumb a { color: var(--app-muted); text-decoration: none; }
.btn-icon { border: 0; font-size: 1.5rem; line-height: 1; padding: .25rem .4rem; }
.btn-user { display: flex; align-items: center; gap: .5rem; border: 0; background: transparent; font-weight: 500; }
.btn-user .avatar {
    width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--app-primary), var(--app-accent)); color: #fff; font-weight: 700;
}
.branch-switch .form-select { min-width: 190px; }
@media (max-width: 575.98px) { .branch-switch .form-select { min-width: 120px; max-width: 150px; } }

.app-content { flex: 1; padding: 1.5rem; }
@media (max-width: 575.98px) { .app-content { padding: 1rem .75rem; } }
.app-footer {
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
    padding: .9rem 1.5rem; font-size: .8rem; color: var(--app-muted); border-top: 1px solid var(--app-border); background: #fff;
}

/* ----------------------------------------------------------- page title (original markup) */
.page-title { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.page-title h3 { font-size: 1.35rem; font-weight: 700; margin: 0; }
.page-title .breadcrumb { margin: 0; font-size: .8rem; }
.page-title .breadcrumb a { color: var(--app-muted); text-decoration: none; }
.panel-title { font-size: 1rem; font-weight: 600; margin: 0; }

/* ----------------------------------------------------------- cards */
.card {
    --bs-card-border-color: var(--app-border);
    --bs-card-border-radius: var(--app-radius);
    --bs-card-cap-bg: transparent;
    box-shadow: var(--app-shadow);
    margin-bottom: 1.25rem;
}
.card-header { padding: .9rem 1.25rem; display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.card-header .card-title, .card-title { font-size: 1rem; font-weight: 600; margin: 0; }
.card-body { padding: 1.25rem; }

.stat-card { border: 0; overflow: hidden; position: relative; }
.stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: .8rem; display: grid; place-items: center; font-size: 1.4rem;
}
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-card .stat-label { color: var(--app-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.bg-soft-primary { background: rgba(var(--app-primary-rgb), .1); color: var(--app-primary); }
.bg-soft-success { background: rgba(16,185,129,.12); color: #059669; }
.bg-soft-warning { background: rgba(245,158,11,.14); color: #d97706; }
.bg-soft-danger  { background: rgba(239,68,68,.12); color: #dc2626; }
.bg-soft-info    { background: rgba(6,182,212,.12); color: #0891b2; }

/* ----------------------------------------------------------- forms */
.form-label { font-weight: 500; font-size: .85rem; color: #374151; margin-bottom: .3rem; }
.form-label .req, label .req { color: #dc2626; }
.help-block, label.error, span.error { color: #dc2626; font-size: .8rem; display: block; margin-top: .25rem; }
.form-control.error, .form-select.error { border-color: #dc2626; }
.form-section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--app-muted); font-weight: 600; margin: 1rem 0 .5rem; }
.input-group-text { background: #f9fafb; }

/* ----------------------------------------------------------- tables */
.table { --bs-table-hover-bg: rgba(var(--app-primary-rgb), .035); vertical-align: middle; }
.table > thead th {
    background: #f8fafc; color: #475569; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
    font-weight: 600; border-bottom-width: 1px; white-space: nowrap;
}
.table tfoot td, .table tfoot th { font-weight: 700; background: #f8fafc; }
.table-responsive { border-radius: .5rem; }
.table td .btn + .btn, .table td .btn + a, .table td a + .btn, .table td a + a.btn { margin-left: .25rem; }
.table td .btn { margin-bottom: .15rem; }
table.dataTable { width: 100% !important; }
div.dt-container .dt-search input { min-width: 200px; }
div.dt-container .dt-layout-row { margin: .5rem 0; }

.report-toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* report / list alignment: DataTables guesses numeric & date columns - we decide with text-end */
table.dataTable th.dt-type-numeric, table.dataTable td.dt-type-numeric,
table.dataTable th.dt-type-date, table.dataTable td.dt-type-date { text-align: left; }
table.dataTable th.text-end, table.dataTable td.text-end,
.table th.text-end, .table td.text-end { text-align: right !important; }
table.dataTable thead th.text-end .dt-column-order { margin-left: .25rem; }
.table td.text-end, .table tfoot td { white-space: nowrap; font-variant-numeric: tabular-nums; }
.table tfoot td { border-top: 2px solid #cbd5e1; }
.table td.action, .table th.action { white-space: nowrap; width: 1%; }
.report-table td, .report-table th { padding: .45rem .6rem; }
.report-meta table td:nth-child(3n+1) { color: var(--app-muted); white-space: nowrap; }
.report-meta table td:nth-child(3n+3) { padding-right: 1.5rem; font-weight: 600; }
div.dt-container .dt-layout-row:first-child { align-items: center; }
#form-report .form-label { white-space: nowrap; }
.report-meta { background: #f8fafc; border: 1px dashed var(--app-border); border-radius: .5rem; padding: .6rem .9rem; font-size: .85rem; margin-bottom: 1rem; }
.report-meta table { width: 100%; }
.report-meta td { padding: .15rem .35rem; }

/* ----------------------------------------------------------- legacy (BS3) compat for server-rendered HTML */
.btn-xs { --bs-btn-padding-y: .15rem; --bs-btn-padding-x: .45rem; --bs-btn-font-size: .75rem; --bs-btn-border-radius: .35rem; }
.btn-default { --bs-btn-color: #374151; --bs-btn-bg: #fff; --bs-btn-border-color: #d1d5db; --bs-btn-hover-bg: #f3f4f6; --bs-btn-hover-border-color: #d1d5db; }
.label { display: inline-block; padding: .25em .6em; font-size: .75em; font-weight: 600; border-radius: 50rem; color: #fff; }
.label-success { background: #10b981; } .label-danger { background: #ef4444; } .label-warning { background: #f59e0b; }
.label-info { background: #06b6d4; } .label-primary { background: var(--app-primary); } .label-default { background: #6b7280; }
.pull-right { float: right !important; } .pull-left { float: left !important; }
.text-right { text-align: right !important; } .text-left { text-align: left !important; }
.hidden { display: none !important; }
legend { font-size: 1rem; border-bottom: 1px solid var(--app-border); margin-bottom: 1rem; }

/* ----------------------------------------------------------- toasts / misc */
.toast { border: 0; box-shadow: var(--app-shadow-lg); }
.app-loading { position: fixed; inset: 0; background: rgba(255,255,255,.55); display: none; place-items: center; z-index: 2000; }
.app-loading.show { display: grid; }
.badge-soft { font-weight: 600; }
.select2-container--bootstrap-5 .select2-selection { min-height: calc(1.5em + .75rem + 2px); }

/* ----------------------------------------------------------- login */
.auth-page {
    min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
    background:
        radial-gradient(1000px 500px at 10% -10%, rgba(var(--app-primary-rgb), .35), transparent 60%),
        radial-gradient(800px 400px at 110% 110%, rgba(6,182,212,.30), transparent 60%),
        #0f172a;
}
.auth-card { width: 100%; max-width: 420px; border: 0; border-radius: 1rem; box-shadow: 0 30px 60px -20px rgba(0,0,0,.5); }
.auth-card .card-body { padding: 2.25rem; }
.auth-card .brand-mark { width: 52px; height: 52px; font-size: 1.5rem; margin: 0 auto 1rem; }

/* ----------------------------------------------------------- print */
@media print {
    .app-sidebar, .app-topbar, .app-footer, .no-print, .hidden-print, .page-actions, .dt-search, .dt-length, .dt-paging, .dt-info, .btn { display: none !important; }
    .app-content { padding: 0; }
    .card { box-shadow: none; border: 0; }
    body.app { background: #fff; }
}
