﻿/* =============================================================================
   مراكز صيانة السيارات
   -----------------------------------------------------------------------------
   كل صنف هنا يبدأ بـ ws- فلا يصطدم بشيء في الملفات العامة. لا قواعد على
   body ولا html ولا :root حتى لا يتسرب شيء الى بقية النظام.
   ============================================================================= */

.ws-wrap {
    --ws-ink: #0f172a;
    --ws-muted: #64748b;
    --ws-line: #e2e8f0;
    --ws-soft: #f8fafc;
    --ws-brand: #047857;
    --ws-brand-soft: #ecfdf5;
}

/* ---------------------- ترويسة الصفحة ----------------------
   شاشات الورشة على نظام SALES البصري نفسه الذي بُنيت عليه شاشة أمر الشغل: بطاقة بيضاء
   وحبر داكن وزر أخضر واحد للإجراء الرئيسي، بدل التدرّج البنفسجي العام في Containers.css.
   المدى مقصور على .ws-wrap فلا تتأثر ترويسة أي شاشة أخرى. */
.ws-wrap { background: transparent; }
.ws-wrap .ui-page-header-enhanced {
    background: #fff !important;
    color: var(--ws-ink) !important;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    box-shadow: 0 4px 16px -12px rgba(15, 23, 42, .25) !important;
    padding: 16px 20px !important;
    margin-bottom: 14px;
}
.ws-wrap .ui-page-header-enhanced::before, .ws-wrap .ui-page-header-enhanced::after { display: none !important; }
.ws-wrap .ui-page-header-enhanced h2 {
    display: flex; align-items: center; gap: .55rem;
    color: var(--ws-ink) !important; font-size: 1.35rem !important; font-weight: 800 !important; margin: 0;
    text-shadow: none !important;
}
.ws-wrap .ui-page-header-enhanced h2 > .bi, .ws-wrap .ui-page-header-enhanced h2 > i {
    width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center;
    background: #ecfdf5; color: #047857; font-size: 1.1rem; margin: 0 !important;
}
.ws-wrap .ui-page-header-enhanced .ui-page-sub, .ws-wrap .ui-page-header-enhanced p {
    color: var(--ws-muted) !important; margin: .35rem 0 0; opacity: 1 !important;
}
.ws-wrap .ui-page-header-enhanced a.ui-btn, .ws-wrap .ui-page-header-enhanced button.ui-btn,
.ws-wrap .ui-page-header-enhanced .d-flex button {
    background: #fff !important; border: 1px solid #cbd5e1 !important; color: var(--ws-ink) !important;
    backdrop-filter: none; height: 40px; border-radius: 10px; font-weight: 700; transform: none !important;
    display: inline-flex; align-items: center; gap: 6px; box-shadow: none !important;
}
.ws-wrap .ui-page-header-enhanced a.ui-btn:hover, .ws-wrap .ui-page-header-enhanced button.ui-btn:hover,
.ws-wrap .ui-page-header-enhanced .d-flex button:hover { background: #f1f5f9 !important; color: var(--ws-ink) !important; }

/* الإجراء الرئيسي وحده أخضر ممتلئ (#047857 يحمل نصًّا أبيض بتباين كافٍ) */
.ws-wrap .ui-page-header-enhanced a.ui-btn-primary, .ws-wrap .ui-page-header-enhanced a.ui-btn-success,
.ws-wrap .ui-page-header-enhanced button.ui-btn-primary, .ws-wrap .ui-page-header-enhanced button.ui-btn-success {
    background: #047857 !important; border-color: #047857 !important; color: #fff !important;
}
.ws-wrap .ui-page-header-enhanced a.ui-btn-primary:hover, .ws-wrap .ui-page-header-enhanced a.ui-btn-success:hover,
.ws-wrap .ui-page-header-enhanced button.ui-btn-primary:hover, .ws-wrap .ui-page-header-enhanced button.ui-btn-success:hover {
    background: #065f46 !important; color: #fff !important;
}

/* ------------------------------ بطاقات الأرقام ------------------------------ */
.ws-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.25rem;
}

.ws-kpi {
    background: #fff;
    border: 1px solid var(--ws-line);
    border-radius: 14px;
    padding: 0.9rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    /* الشريط الملون يحمل المعنى: كل حالة لها لونها في WsOrderStatus */
    border-inline-start: 4px solid var(--ws-brand);
    transition: transform .15s ease, box-shadow .15s ease;
}

.ws-kpi:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(15, 23, 42, .08);
}

.ws-kpi__icon {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    font-size: 1.1rem;
    color: #fff;
    flex: 0 0 auto;
}

.ws-kpi__val {
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--ws-ink);
    font-variant-numeric: tabular-nums;
}

.ws-kpi__lbl {
    font-size: .78rem;
    color: var(--ws-muted);
}

.ws-kpi--link { cursor: pointer; }

/* ------------------------------ لوحة الورشة ------------------------------ */
.ws-board {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 0.9rem;
}

.ws-card {
    background: #fff;
    border: 1px solid var(--ws-line);
    border-radius: 14px;
    padding: 0.85rem 0.95rem;
    cursor: pointer;
    border-top: 3px solid var(--ws-brand);
    transition: transform .15s ease, box-shadow .15s ease;
}

.ws-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(15, 23, 42, .1);
}

.ws-card--late {
    background: linear-gradient(180deg, #fff5f5 0%, #fff 55%);
}

.ws-card__top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    margin-bottom: .5rem;
}

.ws-card__no {
    font-weight: 700;
    color: var(--ws-brand);
    font-variant-numeric: tabular-nums;
}

.ws-card__plate {
    font-weight: 700;
    font-size: 1.02rem;
    color: var(--ws-ink);
    letter-spacing: .5px;
}

.ws-card__veh {
    font-size: .82rem;
    color: var(--ws-muted);
    margin-bottom: .45rem;
}

.ws-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem .75rem;
    font-size: .78rem;
    color: var(--ws-muted);
    border-top: 1px dashed var(--ws-line);
    padding-top: .5rem;
    margin-top: .5rem;
}

.ws-card__meta span { display: inline-flex; align-items: center; gap: .25rem; }

/* ------------------------------ شارة الحالة ------------------------------ */
.ws-badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}

.ws-badge--soft {
    color: inherit;
    background: var(--ws-soft);
    border: 1px solid var(--ws-line);
}

.ws-late {
    color: #b91c1c;
    font-weight: 600;
}

/* ------------------------------ مسار الحالة ------------------------------ */
.ws-flow {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin: .25rem 0 1rem;
}

.ws-flow__step {
    border: 1px solid var(--ws-line);
    background: #fff;
    border-radius: 999px;
    padding: .3rem .8rem;
    font-size: .8rem;
    color: var(--ws-muted);
    cursor: pointer;
    transition: all .15s ease;
}

.ws-flow__step:hover:not(:disabled) { border-color: var(--ws-brand); color: var(--ws-brand); }
.ws-flow__step:disabled { opacity: .45; cursor: not-allowed; }
.ws-flow__step.is-current { color: #fff; border-color: transparent; }
.ws-flow__step.is-done { background: var(--ws-brand-soft); border-color: transparent; color: #115e59; }

/* ------------------------------ بنود أمر الشغل ------------------------------ */
.ws-lines {
    width: 100%;
    border-collapse: collapse;
}

.ws-lines th {
    background: var(--ws-soft);
    font-size: .78rem;
    font-weight: 600;
    color: var(--ws-muted);
    padding: .55rem .5rem;
    border-bottom: 1px solid var(--ws-line);
    text-align: start;
    white-space: nowrap;
}

.ws-lines td {
    padding: .4rem .5rem;
    border-bottom: 1px solid var(--ws-line);
    vertical-align: middle;
}

.ws-lines tfoot td {
    font-weight: 700;
    background: var(--ws-soft);
}

.ws-lines .ws-num {
    text-align: end;
    font-variant-numeric: tabular-nums;
}

.ws-lines input.ui-input,
.ws-lines select.ui-input {
    padding: .3rem .5rem;
    font-size: .85rem;
    min-height: auto;
}

/* الجداول العريضة تمرّر داخل حاويتها لا على عرض الصفحة */
.ws-scroll { overflow-x: auto; }

/* ------------------------------ ملخص الاجماليات ------------------------------ */
.ws-totals {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: .75rem;
}

.ws-total {
    background: #fff;
    border: 1px solid var(--ws-line);
    border-radius: 12px;
    padding: .7rem .85rem;
}

.ws-total__lbl { font-size: .76rem; color: var(--ws-muted); }

.ws-total__val {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ws-ink);
    font-variant-numeric: tabular-nums;
}

.ws-total--grand { background: var(--ws-brand-soft); border-color: transparent; }
.ws-total--grand .ws-total__val { color: #115e59; }

/* ------------------------ اضافة سريعة داخل الحقل ------------------------
   الزر في سطر العنوان لا فوق الحقل: لا يزيح شيئا حين يظهر ولا يترك فراغا
   حين يختفي. والنموذج يحل محل القائمة لا يُضاف تحتها، فارتفاع الصف ثابت. */
.ws-inline-add {
    border: 1px solid var(--ws-line);
    background: #fff;
    color: var(--ws-brand);
    width: 22px;
    height: 22px;
    border-radius: 6px;
    display: inline-grid;
    place-items: center;
    font-size: .7rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: background .15s, color .15s, border-color .15s;
}

.ws-inline-add:hover:not(:disabled) {
    background: var(--ws-brand);
    border-color: var(--ws-brand);
    color: #fff;
}

.ws-inline-add:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.ws-inline-form {
    display: flex;
    gap: .4rem;
    align-items: stretch;
}

.ws-inline-form .ui-input {
    flex: 1;
    min-width: 0;
    border-color: var(--ws-brand);
}

.ws-inline-form .ui-btn {
    flex: 0 0 auto;
    padding-inline: .7rem;
}

/* ------------------------------ بحث المركبة ------------------------------ */
.ws-find { position: relative; }

.ws-find__list {
    position: absolute;
    inset-inline: 0;
    top: calc(100% + 4px);
    z-index: 40;
    background: #fff;
    border: 1px solid var(--ws-line);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .12);
    max-height: 320px;
    overflow-y: auto;
}

.ws-find__row {
    padding: .55rem .8rem;
    cursor: pointer;
    border-bottom: 1px solid var(--ws-line);
}

.ws-find__row:last-child { border-bottom: 0; }
.ws-find__row:hover { background: var(--ws-soft); }
.ws-find__row b { color: var(--ws-brand); }

.ws-find__sub { font-size: .78rem; color: var(--ws-muted); }

/* ------------------------------ المرافع ------------------------------ */
.ws-bays {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: .8rem;
}

.ws-bay {
    border: 1px solid var(--ws-line);
    border-radius: 12px;
    padding: .8rem;
    background: #fff;
    text-align: center;
}

.ws-bay--busy { background: #fff7ed; border-color: #fed7aa; }
.ws-bay__name { font-weight: 700; color: var(--ws-ink); }
.ws-bay__state { font-size: .78rem; color: var(--ws-muted); margin-top: .3rem; }

/* ------------------------------ صور الاستلام ------------------------------ */
.ws-photos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: .6rem;
}

.ws-photo {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--ws-line);
    aspect-ratio: 4 / 3;
}

.ws-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.ws-photo__x {
    position: absolute;
    top: 4px;
    inset-inline-end: 4px;
    border: 0;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    background: rgba(15, 23, 42, .65);
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
}

/* ------------------------------ تنبيه بلا نافذة منبثقة ------------------------------ */
.ws-alert {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .7rem 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    border: 1px solid var(--ws-line);
    background: #fff;
}

.ws-alert--info { background: #ecfeff; border-color: #a5f3fc; color: #155e75; }
.ws-alert--danger { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.ws-alert--warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }

.ws-alert__x {
    margin-inline-start: auto;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    opacity: .7;
}

.ws-alert__x:hover { opacity: 1; }

/* ------------------------------ فراغ ------------------------------ */
.ws-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--ws-muted);
}

.ws-empty i { font-size: 2.6rem; opacity: .35; display: block; margin-bottom: .6rem; }

@media (max-width: 640px) {
    .ws-board { grid-template-columns: 1fr; }
    .ws-kpis { grid-template-columns: repeat(2, 1fr); }
}
