/* ثيم الكهرمان — مسابيح بومشعل */

/* خط Tajawal محفوظ داخل الموقع (wwwroot/fonts) عشان يشتغل بدون إنترنت وبنفس الشكل على كل الأجهزة.
   الرخصة: SIL Open Font License — الملف fonts/OFL.txt */
@font-face { font-family: "Tajawal"; font-weight: 400; font-style: normal; font-display: swap; size-adjust: 108%;
    src: url("../fonts/tajawal-400-arabic.woff2") format("woff2");
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Tajawal"; font-weight: 400; font-style: normal; font-display: swap; size-adjust: 108%;
    src: url("../fonts/tajawal-400-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-200B, U+2012-206F, U+20AC, U+2122, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Tajawal"; font-weight: 500; font-style: normal; font-display: swap; size-adjust: 108%;
    src: url("../fonts/tajawal-500-arabic.woff2") format("woff2");
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Tajawal"; font-weight: 500; font-style: normal; font-display: swap; size-adjust: 108%;
    src: url("../fonts/tajawal-500-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-200B, U+2012-206F, U+20AC, U+2122, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Tajawal"; font-weight: 700; font-style: normal; font-display: swap; size-adjust: 108%;
    src: url("../fonts/tajawal-700-arabic.woff2") format("woff2");
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Tajawal"; font-weight: 700; font-style: normal; font-display: swap; size-adjust: 108%;
    src: url("../fonts/tajawal-700-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-200B, U+2012-206F, U+20AC, U+2122, U+2212, U+2215, U+FEFF, U+FFFD; }
:root {
    --bg: #FBF5E8;
    --card: #FFFDF8;
    --tint: #FAEEDA;
    --line: #EBD9B4;
    --line-strong: #DDC18C;
    --amber-100: #FAC775;
    --amber-200: #EF9F27;
    --amber-400: #BA7517;
    --amber-600: #854F0B;
    --amber-800: #633806;
    --ink: #412402;
    --green: #3B6D11;
    --green-bg: #EAF3DE;
    --green-ink: #27500A;
    --red: #A32D2D;
    --red-bg: #FCEBEB;
    --red-ink: #791F1F;
    --radius: 8px;
    color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
    font-family: "Tajawal", "Segoe UI", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--ink);
    background: var(--bg);
    display: flex;
    min-height: 100vh;
    overflow-wrap: break-word; /* كلمة طويلة بدون فراغات (رابط مثلاً) ما تطلّع الصفحة عن الشاشة */
}

a { color: var(--amber-600); text-decoration: none; }
a:hover { color: var(--amber-800); }
h1 { font-size: 20px; font-weight: 600; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 10px; }
p { margin: 0; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- القائمة الجانبية ---------- */
.side {
    width: 224px;
    flex-shrink: 0;
    background: var(--ink);
    padding: 18px 10px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: var(--tint); font-weight: 600; font-size: 16px; white-space: nowrap; }
.brand:hover { color: var(--tint); }
.brand svg { width: 26px; height: 26px; color: var(--amber-200); fill: var(--amber-200); stroke: none; }
.side nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; margin-bottom: 2px;
    border-radius: var(--radius);
    color: var(--amber-100); font-size: 14px;
}
.side nav a:hover { background: rgba(250, 199, 117, .12); color: var(--tint); }
.side nav a.on { background: var(--amber-800); color: var(--tint); font-weight: 600; }
.side nav svg { width: 19px; height: 19px; flex-shrink: 0; }

.side { display: flex; flex-direction: column; }
.me { margin-top: auto; padding: 12px 10px 2px; border-top: 1px solid rgba(250, 199, 117, .22); font-size: 13px; }
.me-name { color: var(--tint); font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.me-name span { font-weight: 400; font-size: 12px; color: var(--amber-100); }
.me a, .me button { display: block; padding: 3px 0; color: var(--amber-100); background: none; border: 0; font: inherit; cursor: pointer; }
.me a:hover, .me button:hover { color: var(--tint); text-decoration: underline; }

.main { flex: 1; min-width: 0; padding: 22px 26px 60px; max-width: 1180px; }

/* ---------- صفحات الدخول ---------- */
body.auth { align-items: center; justify-content: center; padding: 20px 16px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 20px; font-weight: 600; margin-bottom: 16px; }
.auth-brand svg { width: 30px; height: 30px; fill: var(--amber-200); stroke: none; }
.auth-box .card { padding: 20px; }
.auth-box h1 { margin-bottom: 14px; }
input[type=password] {
    width: 100%; height: 38px; padding: 0 10px;
    border: 1px solid var(--line-strong); border-radius: var(--radius);
    background: var(--card); color: var(--ink); font: inherit; font-size: 14px;
    direction: ltr; text-align: right;
}
.who { display: flex; gap: 8px; margin-bottom: 12px; }
.who label { flex: 1; margin: 0; cursor: pointer; }
.who input { position: absolute; opacity: 0; pointer-events: none; }
.who span { display: block; text-align: center; padding: 8px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--card); color: var(--amber-800); font-size: 15px; }
.who input:checked + span { background: var(--amber-600); border-color: var(--amber-600); color: var(--tint); font-weight: 600; }
.who input:focus-visible + span { box-shadow: 0 0 0 3px rgba(250, 199, 117, .7); }

/* ---------- عناصر عامة ---------- */
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--amber-600); }
.small { font-size: 13px; }
.num { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.spacer { flex: 1; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; }
.flash { background: var(--green-bg); color: var(--green-ink); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.errors { background: var(--red-bg); color: var(--red-ink); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.errors ul { margin: 0; padding-inline-start: 18px; }
.errors:empty, .validation-summary-valid { display: none; }
.field-err { color: var(--red); font-size: 12px; display: block; min-height: 4px; }
.empty { text-align: center; padding: 34px 16px; color: var(--amber-600); }
.empty p { margin-bottom: 12px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 36px; padding: 0 14px;
    border: 1px solid var(--line-strong); border-radius: var(--radius);
    background: var(--card); color: var(--amber-800);
    font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--tint); color: var(--amber-800); }
.btn.pri { background: var(--amber-600); border-color: var(--amber-600); color: var(--tint); }
.btn.pri:hover { background: var(--amber-800); color: var(--tint); }
.btn.danger { color: var(--red); border-color: #E9B9B9; }
.btn.danger:hover { background: var(--red-bg); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 36px; padding: 0; font-size: 20px; line-height: 1; flex-shrink: 0; }
.btn:disabled { opacity: .6; cursor: default; }
.btn:focus-visible, a:focus-visible { outline: 2px solid var(--amber-400); outline-offset: 2px; }
td.n .btn + .inline-form { margin-inline-start: 4px; }
.narrow { max-width: 420px; }
.gap-top { margin-top: 10px; }

.pill { display: inline-block; font-size: 12px; padding: 1px 9px; border-radius: 999px; white-space: nowrap; }
.pill.sale, .pill.stock { background: var(--green-bg); color: var(--green-ink); }
.pill.buy { background: var(--tint); color: var(--amber-800); }
.pill.exp { background: var(--red-bg); color: var(--red-ink); }
.pill.sold { background: #EFE7DA; color: #6B5A45; }

/* ---------- النماذج ---------- */
label, .lbl { display: block; font-size: 13px; color: var(--amber-600); margin-bottom: 4px; }
input[type=text], input[type=date], input[type=search], select, textarea {
    width: 100%; height: 38px; padding: 0 10px;
    border: 1px solid var(--line-strong); border-radius: var(--radius);
    background: var(--card); color: var(--ink);
    font: inherit; font-size: 14px;
}
textarea { height: auto; min-height: 70px; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--amber-400); box-shadow: 0 0 0 3px rgba(250, 199, 117, .55); }
input::placeholder, textarea::placeholder { color: #C2A56F; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.full { grid-column: 1 / -1; }
.span2 { grid-column: span 2; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.unit { position: relative; }
.unit input { padding-left: 46px; padding-right: 10px; text-align: right; direction: ltr; }
.unit > span { position: absolute; inset-inline-end: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--amber-400); pointer-events: none; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }
.inline-form { display: inline; }

/* ---------- شريط الشهر ---------- */
.month-nav { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: 16px; }
.month-nav a { display: inline-flex; width: 30px; height: 30px; align-items: center; justify-content: center; border-radius: var(--radius); color: var(--amber-400); font-size: 20px; }
.month-nav a:hover { background: var(--tint); }
.month-nav span { min-width: 118px; text-align: center; }

/* ---------- الرئيسية ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--tint); border-radius: var(--radius); padding: 14px; }
.kpi .k-label { font-size: 13px; color: var(--amber-600); }
.kpi .k-value { font-size: 24px; font-weight: 600; line-height: 1.3; }
.kpi .k-value small { font-size: 12px; font-weight: 400; }
.kpi .k-sub { font-size: 12px; color: var(--amber-600); }

.bars { display: flex; align-items: flex-end; gap: 14px; height: 140px; padding-top: 8px; }
.bars .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bars .bar { width: 100%; max-width: 70px; background: var(--amber-100); border-radius: 5px 5px 0 0; min-height: 2px; flex-shrink: 0; }
.bars .bar.now { background: var(--amber-400); }
.bars .bar.neg { background: #E9A3A3; }
.bars .bar-val { font-size: 11px; color: var(--amber-600); height: 18px; line-height: 18px; margin-bottom: 2px; white-space: nowrap; flex-shrink: 0; }
.bars .v-short { display: none; }
.bar-labels { display: flex; gap: 14px; margin-top: 5px; }
.bar-labels span { flex: 1; text-align: center; font-size: 12px; color: var(--amber-600); }

.rows > .row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.rows > .row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amount { font-weight: 600; white-space: nowrap; }

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: start; font-weight: 600; font-size: 13px; color: var(--amber-600); padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tfoot td { border-top: 1px solid var(--line-strong); border-bottom: 0; font-weight: 600; background: var(--tint); }
td.n, th.n { text-align: left; white-space: nowrap; }
.item-cell { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.thumb { width: 42px; height: 42px; border-radius: 6px; object-fit: cover; background: var(--tint); flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: var(--amber-400); }
.thumb svg { width: 20px; height: 20px; }

/* ---------- السجلات ---------- */
.log-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.log-filters .grow2 { grid-column: span 3; }
.log-actions { display: flex; gap: 8px; }
.log-table td { vertical-align: top; }
.log-table td:last-child { min-width: 230px; }
.log-time { white-space: nowrap; font-size: 13px; }
.pill.k-login { background: #E8EEF6; color: #1F3F66; }
.pill.k-add { background: var(--green-bg); color: var(--green-ink); }
.pill.k-edit { background: var(--tint); color: var(--amber-800); }
.pill.k-delete { background: var(--red-bg); color: var(--red-ink); }
.log-table details { margin-top: 4px; }
.log-table summary { cursor: pointer; font-size: 13px; color: var(--amber-600); width: fit-content; }
.log-details { white-space: pre-line; font-size: 13px; background: var(--tint); border-radius: var(--radius); padding: 8px 12px; margin-top: 4px; line-height: 1.8; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }
@media (max-width: 860px) {
    .log-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .log-filters .grow2 { grid-column: 1 / -1; }
}

/* ---------- المخزون ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { max-width: 260px; }
.tabs { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.tabs a { padding: 6px 14px; font-size: 14px; color: var(--amber-800); border-inline-start: 1px solid var(--line-strong); }
.tabs a:first-child { border-inline-start: 0; }
.tabs a.on { background: var(--amber-600); color: var(--tint); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.m-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; color: var(--ink); display: block; }
.m-card:hover { border-color: var(--amber-400); color: var(--ink); }
.m-card .ph { aspect-ratio: 1; background: var(--tint); display: flex; align-items: center; justify-content: center; color: var(--amber-400); }
.m-card .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.m-card .ph svg { width: 38px; height: 38px; }
.m-card .body { padding: 10px 12px 12px; }
.m-card .name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-card .meta { font-size: 12px; color: var(--amber-600); margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-card .price-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 13px; }

/* ---------- صفحة المسباح ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 18px; align-items: start; }
.gallery .big { aspect-ratio: 1; border-radius: 12px; background: var(--tint); overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--amber-400); border: 1px solid var(--line); }
.gallery .big img { width: 100%; height: 100%; object-fit: contain; }
.gallery .big svg { width: 54px; height: 54px; }
.gallery .strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 8px; }
.gallery .strip img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; cursor: pointer; border: 2px solid transparent; }
.gallery .strip img.on { border-color: var(--amber-400); }
.gallery .strip img:focus-visible { outline: 2px solid var(--amber-600); outline-offset: 1px; }
.specs { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px 16px; }
.specs > div > span { display: block; font-size: 12px; color: var(--amber-600); }
.specs > div > b { font-weight: 600; font-size: 15px; }

/* ---------- نموذج الشراء ---------- */
.buy-form { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 20px; align-items: start; }
.drop { aspect-ratio: 1; border: 1px dashed var(--amber-400); border-radius: var(--radius); background: var(--tint); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--amber-600); font-size: 13px; cursor: pointer; text-align: center; padding: 8px; margin: 0; }
.drop { position: relative; }
.drop:hover, .drop.over { background: #F7E4C2; }
.drop.over { border-style: solid; }
.drop svg { width: 30px; height: 30px; color: var(--amber-400); }
/* مخفي بالشكل بس موجود للكيبورد وقارئ الشاشة */
.drop input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.drop:focus-within { box-shadow: 0 0 0 3px rgba(250, 199, 117, .7); }
.previews { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.pv { position: relative; aspect-ratio: 1; }
.pv img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; display: block; }
.pv button, .pv .rm { position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(65, 36, 2, .78); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.pv input[type=checkbox] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.pv:focus-within { outline: 2px solid var(--amber-600); outline-offset: 1px; border-radius: 6px; }
.pv:has(input:checked) img { opacity: .3; }
.pv:has(input:checked) .rm { background: var(--red); }

/* ---------- خانة اختيار الشخص ---------- */
.cp-row { display: flex; gap: 8px; }
.cp-row input { direction: ltr; text-align: right; }
.cp-list { background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius); margin-top: 6px; overflow: hidden; }
.cp-opt { display: flex; align-items: center; gap: 10px; padding: 8px 12px; font-size: 14px; cursor: pointer; border-top: 1px solid var(--line); width: 100%; background: none; border-inline: 0; border-bottom: 0; font: inherit; color: var(--ink); text-align: start; }
.cp-opt:first-child { border-top: 0; }
.cp-opt:hover, .cp-opt:focus { background: var(--tint); outline: none; }
.cp-av { width: 34px; height: 34px; border-radius: 50%; background: var(--amber-100); color: var(--amber-800); display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0; }
.cp-mid { flex: 1; min-width: 0; }
.cp-mid b { display: block; font-weight: 600; }
.cp-mid span { display: block; font-size: 12px; color: var(--amber-600); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-sel { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--amber-400); border-radius: var(--radius); padding: 8px 12px; }
.cp-new { background: var(--tint); border-radius: var(--radius); padding: 12px; margin-top: 8px; }
.cp-new h3 { font-size: 14px; font-weight: 600; margin: 0 0 10px; }

/* ---------- الجوال ---------- */
@media (max-width: 860px) {
    body { flex-direction: column; }
    .side { width: 100%; height: auto; position: static; padding: 10px 10px 8px; }
    .brand { padding: 2px 6px 8px; }
    .side nav { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 4px; }
    .side nav a { flex-shrink: 0; padding: 7px 10px; margin: 0; }
    .me { margin-top: 4px; padding: 8px 6px 2px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
    .me-name { margin: 0; }
    .main { padding: 16px 16px 50px; }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi .k-value { font-size: 20px; }
    .detail, .buy-form { grid-template-columns: minmax(0, 1fr); }
    .buy-form .photos-col { max-width: 260px; }
    .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
    .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); }
    .span2 { grid-column: auto; }
    .bars { gap: 6px; }
    .bar-labels { gap: 6px; }
    /* على الجوال الرقم الكامل أعرض من العمود، فنعرضه مختصر */
    .bars .v-full { display: none; }
    .bars .v-short { display: inline; }
    .bars .bar-val { font-size: 10px; }
}

[hidden] { display: none !important; }
