/* =========================================================
   Battery Shop - main stylesheet (RTL)
   ========================================================= */
:root {
    --sidebar-width: 250px;
    --sidebar-bg: #1e293b;
    --sidebar-color: #cbd5e1;
    --sidebar-active: #0d6efd;
}

body {
    font-family: 'Cairo', Tahoma, Arial, sans-serif;
    background: #f4f6f9;
    font-size: .95rem;
}

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

.app-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-color);
    position: fixed;
    top: 0; bottom: 0; right: 0;
    overflow-y: auto;
    z-index: 1040;
    transition: transform .2s ease;
}

.app-main {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-topbar { position: sticky; top: 0; z-index: 1030; min-height: 60px; gap: .75rem; }
.global-search { width: 360px; max-width: 40vw; }
.global-search .dropdown-menu { top: 100%; right: 0; left: auto; margin-top: .25rem; }

.sidebar-brand {
    display: flex; align-items: center; gap: .5rem;
    padding: 1rem 1.25rem;
    font-weight: 700; font-size: 1.1rem; color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand i { font-size: 1.6rem; color: #facc15; }

.sidebar-nav { padding: .5rem 0 2rem; }
.sidebar-nav .nav-link {
    color: var(--sidebar-color);
    display: flex; align-items: center; gap: .65rem;
    padding: .55rem 1.25rem;
    border-right: 3px solid transparent;
}
.sidebar-nav .nav-link i { font-size: 1.1rem; width: 1.3rem; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar-nav .nav-link.active {
    background: rgba(13,110,253,.18);
    color: #fff;
    border-right-color: var(--sidebar-active);
}
.sidebar-section {
    padding: 1rem 1.25rem .35rem;
    font-size: .75rem;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 700;
}

.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(100%); }
    .app-main { margin-right: 0; }
    body.sidebar-open .app-sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop {
        display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1035;
    }
}

/* ---------- Cards ---------- */
.card { border: 0; box-shadow: 0 1px 3px rgba(0,0,0,.06); border-radius: .6rem; }
.card-header { border-bottom: 1px solid #eef0f3; }

.stat-card {
    display: flex; align-items: center; gap: 1rem;
    padding: 1.1rem 1.25rem; border-radius: .6rem; height: 100%;
}
.stat-card > i { font-size: 2rem; opacity: .7; }
.stat-value { font-size: 1.35rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: .85rem; color: #555; }

/* ---------- Auth ---------- */
.auth-body {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e293b 0%, #0d6efd 100%);
}
.auth-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 420px; border-radius: 1rem; }
.auth-logo {
    width: 72px; height: 72px; border-radius: 50%;
    background: #fef9c3; color: #ca8a04;
    display: inline-flex; align-items: center; justify-content: center; font-size: 2.2rem;
}

/* ---------- Permission matrix ---------- */
.perm-matrix { max-height: 65vh; }
.perm-matrix .form-check-input { width: 1.15em; height: 1.15em; cursor: pointer; }
.perm-override { outline: 2px solid #fd7e14; outline-offset: 2px; }
.perm-override-legend { color: #fd7e14; }
.perm-special { cursor: pointer; background: #fff; }
.perm-special:hover { background: #f8fafc; }

/* ---------- Products ---------- */
.col-product-name { min-width: 220px; }
.product-thumb {
    width: 38px; height: 38px; border-radius: .375rem; background: #f1f5f9; color: #94a3b8;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0;
}

/* ---------- Tables / forms ---------- */
.table > :not(caption) > * > * { vertical-align: middle; }

/* RTL alignment: header and cells always share the same (right) edge */
.table:not(.text-center) th:not(.text-center),
.table:not(.text-center) td:not(.text-center),
table.dataTable th:not(.text-center),
table.dataTable td:not(.text-center),
table.dataTable th.dt-type-numeric:not(.text-center),
table.dataTable td.dt-type-numeric:not(.text-center),
table.dataTable th.dt-type-date:not(.text-center),
table.dataTable td.dt-type-date:not(.text-center),
.table th.text-start, .table td.text-start { text-align: right !important; }
.table th.text-center, .table td.text-center { text-align: center !important; }
.ltr-text { direction: ltr; unicode-bidi: isolate; display: inline-block; }
/* Bootstrap RTL makes number/tel/email inputs LTR; keep their text on the right like the labels */
input[type="number"].form-control, input[type="tel"].form-control { text-align: right; }

/* DataTables sort indicator on the left in RTL so titles start at the cell edge */
table.dataTable thead > tr > th.dt-orderable-asc,
table.dataTable thead > tr > th.dt-orderable-desc,
table.dataTable thead > tr > th.dt-ordering-asc,
table.dataTable thead > tr > th.dt-ordering-desc,
table.dataTable thead > tr > td.dt-orderable-asc,
table.dataTable thead > tr > td.dt-orderable-desc {
    padding-right: .5rem !important;
    padding-left: 26px !important;
}
table.dataTable thead > tr > th span.dt-column-order,
table.dataTable thead > tr > td span.dt-column-order {
    right: auto !important;
    left: 8px !important;
}
table.dataTable th, table.dataTable td { padding-right: .5rem; }
.table th { white-space: nowrap; }
div.dt-container .dt-paging .dt-paging-button { padding: .25rem .6rem; }
.select2-container--bootstrap-5 .select2-selection { min-height: calc(1.5em + .75rem + 2px); }
.form-label { font-weight: 600; font-size: .9rem; }

@media print {
    .app-sidebar, .app-topbar, .no-print { display: none !important; }
    .app-main { margin: 0 !important; }
}
