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

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

/* ------------------------------ بطاقات الأرقام ------------------------------ */
.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-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); }
}
