/* TBP Order Tracking */
:root { --tbp-ot-accent: #0073aa; --tbp-ot-ok: #00a32a; --tbp-ot-bad: #d63638; }

.tbp-ot-wrap, .tbp-ot-captain { direction: rtl; text-align: right; box-sizing: border-box; }
.tbp-ot-wrap *, .tbp-ot-captain * { box-sizing: border-box; }
.tbp-ot-wrap { max-width: 600px; margin: 20px auto; padding: 20px; border: 1px solid #ddd; border-radius: 8px; background: #fff; }
.tbp-ot-captain { margin: 0 0 25px; }

.tbp-ot-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.tbp-ot-head h3 { margin: 0; font-size: 18px; }
.tbp-ot-live { color: var(--tbp-ot-bad); font-weight: bold; font-size: 13px; animation: tbpOtBlink 1.4s infinite; }
.tbp-ot-empty, .tbp-ot-cap-empty { padding: 15px; background: #f9f9f9; border: 1px dashed #ccc; border-radius: 8px; color: #666; text-align: center; }
[hidden] { display: none !important; }

/* الاستعلام برقم الجوال */
.tbp-ot-lookup { background: #fff; border: 1px solid #e3e3e3; border-style: solid; text-align: right; }
.tbp-ot-lookup h4 { margin: 0 0 4px; font-size: 16px; color: #222; }
.tbp-ot-lookup p { margin: 0 0 12px; color: #666; font-size: 13px; }
.tbp-ot-lookup-row { display: flex; gap: 8px; }
.tbp-ot-lookup-input { flex: 1; min-width: 0; padding: 12px; border: 1px solid #ccc; border-radius: 4px; direction: ltr; text-align: right; font-size: 15px; }
.tbp-ot-lookup-row .tbp-ot-btn { width: auto; margin-top: 0; padding: 12px 20px; }
.tbp-ot-lookup-btn:disabled { opacity: .6; cursor: wait; }
.tbp-ot-lookup-msg { margin-top: 10px; font-size: 13px; color: #11602b; background: #e7f6ec; padding: 8px 12px; border-radius: 6px; }
.tbp-ot-lookup-msg.is-bad { color: #8a1f1f; background: #fcecec; }

/* لوحة الكابتن */
.tbp-ot-panel-title { margin: 0 0 15px; background: var(--tbp-ot-accent); color: #fff; padding: 15px; border-radius: 8px; font-size: 18px; text-align: right; }
.tbp-ot-cap-status { margin-bottom: 12px; padding: 10px 12px; border-radius: 6px; background: #e7f6ec; color: #11602b; font-weight: bold; font-size: 14px; }
.tbp-ot-cap-status.is-bad { background: #fcecec; color: #8a1f1f; }
.tbp-ot-tip { color: #666; font-size: 13px; margin: 12px 0 0; }
.tbp-ot-card { border: 1px solid #ddd; border-radius: 8px; background: #fff; padding: 15px; margin-bottom: 18px; box-shadow: 0 2px 5px rgba(0,0,0,0.06); }
.tbp-ot-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.tbp-ot-chip { background: #e6f1f8; color: var(--tbp-ot-accent); border-radius: 12px; padding: 3px 10px; font-size: 12px; font-weight: bold; white-space: nowrap; }
.tbp-ot-card-sub { color: #555; font-size: 14px; margin-bottom: 14px; }
.tbp-ot-controls { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; padding: 12px; background: #f9f9f9; border: 1px solid #eee; border-radius: 8px; }
.tbp-ot-hint { color: #777; font-size: 13px; }

/* مفاتيح التبديل */
.tbp-ot-switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: bold; font-size: 14px; }
.tbp-ot-switch.is-disabled { opacity: .6; cursor: not-allowed; }
.tbp-ot-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.tbp-ot-slider { position: relative; flex: 0 0 46px; height: 26px; background: #c3c4c7; border-radius: 26px; transition: .25s; }
.tbp-ot-slider::before { content: ""; position: absolute; width: 20px; height: 20px; top: 3px; right: 3px; background: #fff; border-radius: 50%; transition: .25s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.tbp-ot-switch input:checked + .tbp-ot-slider { background: var(--tbp-ot-ok); }
.tbp-ot-switch input:checked + .tbp-ot-slider::before { transform: translateX(-20px); }

/* الخط الزمني العمودي */
.tbp-ot-timeline { list-style: none; margin: 0; padding: 0; }
.tbp-ot-step { display: flex; gap: 14px; position: relative; padding-bottom: 22px; }
.tbp-ot-step:last-child { padding-bottom: 0; }
.tbp-ot-step::before { content: ""; position: absolute; top: 40px; bottom: 2px; right: 18px; width: 3px; background: #e3e3e3; border-radius: 2px; }
.tbp-ot-step:last-child::before { display: none; }
.tbp-ot-step.is-done::before { background: var(--tbp-ot-ok); }
.tbp-ot-dot { position: relative; flex: 0 0 38px; height: 38px; border-radius: 50%; background: #f0f0f0; border: 2px solid #d5d5d5; display: flex; align-items: center; justify-content: center; font-size: 18px; z-index: 1; }
.tbp-ot-step.is-done .tbp-ot-dot { background: #e7f6ec; border-color: var(--tbp-ot-ok); }
.tbp-ot-step.is-done .tbp-ot-dot::after { content: "✓"; position: absolute; bottom: -4px; left: -4px; width: 17px; height: 17px; border-radius: 50%; background: var(--tbp-ot-ok); color: #fff; font-size: 11px; line-height: 17px; text-align: center; }
.tbp-ot-step.is-active .tbp-ot-dot { background: #e6f1f8; border-color: var(--tbp-ot-accent); animation: tbpOtPulse 1.6s infinite; }
.tbp-ot-step.is-pending { opacity: .55; }
.tbp-ot-step-body { flex: 1; min-width: 0; padding-top: 3px; }
.tbp-ot-step-title { font-weight: bold; font-size: 15px; display: flex; justify-content: space-between; gap: 8px; }
.tbp-ot-step-title time { font-weight: normal; color: #777; font-size: 12px; }
.tbp-ot-step-desc { color: #555; font-size: 13px; margin-top: 3px; }
.tbp-ot-count { display: inline-block; margin-top: 6px; background: #fff7e0; border: 1px solid #f0d98a; color: #7a5b00; border-radius: 12px; padding: 2px 10px; font-size: 12px; font-weight: bold; }

/* نسخة أفقية مصغرة (لوحة الكابتن) */
.tbp-ot-h .tbp-ot-timeline { display: flex; }
.tbp-ot-h .tbp-ot-step { flex: 1; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 0 2px; }
.tbp-ot-h .tbp-ot-step::before { top: 18px; bottom: auto; right: 50%; left: -50%; width: auto; height: 3px; }
.tbp-ot-h .tbp-ot-step-title { flex-direction: column; align-items: center; font-size: 12px; gap: 0; }
.tbp-ot-h .tbp-ot-step-desc { display: none; }
.tbp-ot-h .tbp-ot-step-body { padding-top: 0; }
.tbp-ot-h .tbp-ot-count { font-size: 11px; padding: 1px 7px; }

/* شريط الحالة */
.tbp-ot-banner { padding: 12px 14px; border-radius: 8px; background: #e6f1f8; color: #0b4a6f; font-weight: bold; margin-bottom: 18px; font-size: 14px; }
.tbp-ot-banner.is-done { background: #e7f6ec; color: #11602b; }
.tbp-ot-banner.is-arrived { background: #fff3d6; color: #7a5b00; }
.tbp-ot-banner:empty { display: none; }

/* الخريطة */
.tbp-ot-map-wrap { position: relative; margin: 18px 0 8px; }
.tbp-ot-map { height: 280px; border-radius: 8px; background: #eee; z-index: 1; }
.tbp-ot-card .tbp-ot-map { height: 230px; }
.tbp-ot-refocus { position: absolute; top: 10px; left: 10px; z-index: 500; background: #fff; border: 1px solid #ccc; border-radius: 6px; padding: 5px 8px; cursor: pointer; font-size: 16px; }
.tbp-ot-pin span { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; font-size: 20px; background: #fff; border: 3px solid var(--tbp-ot-accent); border-radius: 50%; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.tbp-ot-pin.is-target span { border-color: var(--tbp-ot-bad); }
.tbp-ot-pin.is-captain span { border-color: var(--tbp-ot-ok); }
.tbp-ot-note { font-size: 13px; color: #7a5b00; background: #fff7e0; border: 1px solid #f0d98a; padding: 8px 12px; border-radius: 6px; margin: 8px 0; }

/* لوحة الإحصائيات */
.tbp-ot-stats { margin-top: 14px; }
.tbp-ot-stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tbp-ot-stat { background: #f9f9f9; border: 1px solid #eee; border-radius: 8px; padding: 10px 6px; text-align: center; }
.tbp-ot-stat-ico { font-size: 18px; }
.tbp-ot-stat-val { font-size: 18px; font-weight: bold; color: var(--tbp-ot-accent); margin: 2px 0; }
.tbp-ot-stat-lbl { font-size: 12px; color: #666; }
.tbp-ot-progress { height: 10px; background: #e8e8e8; border-radius: 10px; overflow: hidden; }
.tbp-ot-progress-bar { height: 100%; background: linear-gradient(270deg, var(--tbp-ot-ok), var(--tbp-ot-accent)); border-radius: 10px; transition: width .8s ease; }
.tbp-ot-progress-txt { font-size: 12px; color: #666; margin: 5px 0 12px; }

/* أزرار */
.tbp-ot-btn { display: block; width: 100%; padding: 12px; border: none; border-radius: 5px; background: var(--tbp-ot-accent); color: #fff; cursor: pointer; font-weight: bold; font-size: 15px; text-align: center; text-decoration: none; margin-top: 10px; }
.tbp-ot-btn:hover { opacity: .92; color: #fff; }
.tbp-ot-btn-light { background: #e0e0e0; color: #333; }
.tbp-ot-btn-light:hover { color: #333; }
.tbp-ot-btn-wa { background: #25D366; }
.tbp-ot-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.tbp-ot-actions .tbp-ot-btn { flex: 1; min-width: 160px; margin-top: 0; }
.tbp-ot-consent { margin-top: 15px; padding: 12px; background: #fff7e0; border: 1px solid #f0d98a; border-radius: 8px; }
.tbp-ot-consent p { margin: 0 0 6px; font-weight: bold; }

/* التقييم */
.tbp-ot-rate { margin-top: 18px; padding: 14px; border: 1px solid #eee; border-radius: 8px; background: #fafafa; text-align: center; }
.tbp-ot-rate h4 { margin: 0 0 8px; }
.tbp-ot-stars { display: flex; justify-content: center; gap: 4px; direction: ltr; }
.tbp-ot-stars button { background: none; border: none; font-size: 34px; color: #ccc; cursor: pointer; padding: 0 2px; line-height: 1; }
.tbp-ot-stars button.on { color: #f5b301; }
.tbp-ot-rate textarea { width: 100%; margin-top: 8px; padding: 8px; border: 1px solid #ccc; border-radius: 4px; }

/* إشعار منبثق */
.tbp-ot-toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 30px); background: #1e1e1e; color: #fff; padding: 12px 18px; border-radius: 8px; z-index: 99999; opacity: 0; transition: .35s; max-width: 90%; font-size: 14px; direction: rtl; text-align: center; }
.tbp-ot-toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes tbpOtPulse { 0% { box-shadow: 0 0 0 0 rgba(0,115,170,.45); } 70% { box-shadow: 0 0 0 12px rgba(0,115,170,0); } 100% { box-shadow: 0 0 0 0 rgba(0,115,170,0); } }
@keyframes tbpOtBlink { 50% { opacity: .35; } }

@media (max-width: 480px) {
    .tbp-ot-wrap { padding: 14px; }
    .tbp-ot-stat-val { font-size: 16px; }
}


/* قبول / رفض الطلبات (بنفس تنسيق بطاقات النظام الأساسي) */
.tbp-ot-pending-title { margin: 0 0 15px; background: #0073aa; color: #fff; padding: 15px; border-radius: 8px; font-size: 18px; text-align: right; }
.tbp-ot-req { border: 1px solid #ddd; padding: 20px; margin-bottom: 20px; border-radius: 8px; background: #fff; box-shadow: 0 4px 10px rgba(0,0,0,0.08); text-align: right; direction: rtl; }
.tbp-ot-req.is-direct { border-color: #28a745; background: #f4fdf6; }
.tbp-ot-req-tag { display: inline-block; background: #28a745; color: #fff; padding: 4px 10px; border-radius: 20px; font-size: 13px; font-weight: bold; margin-bottom: 10px; }
.tbp-ot-req-line { margin: 0 0 10px; color: #333; font-size: 16px; }
.tbp-ot-req-svc { margin: 0 0 10px; color: #d63638; font-size: 18px; }
.tbp-ot-req-map { display: block; text-align: center; background: #ff9800; color: #fff !important; padding: 10px; text-decoration: none; border-radius: 5px; font-weight: bold; font-size: 14px; margin: 10px 0 15px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.tbp-ot-req-accept, .tbp-ot-req-reject { display: block; width: 100%; padding: 15px; border: none; border-radius: 5px; cursor: pointer; font-weight: bold; font-size: 16px; color: #fff; transition: 0.3s; }
.tbp-ot-req-accept { background: #2271b1; }
.tbp-ot-req-reject { background: #d63638; margin-top: 10px; }
.tbp-ot-req-accept:hover { opacity: .9; }
.tbp-ot-req-reject:hover { opacity: .9; }
.tbp-ot-req button:disabled { opacity: .6; cursor: wait; }
.tbp-ot-sep { margin: 25px 0; border: 0; border-top: 1px solid #eee; }

/* ===== v1.2.0: قنوات الاتصال + تمت الخدمة / إلغاء الخدمة (بنفس تنسيق النظام الأساسي) ===== */
.tbp-ot-maplink { margin: 14px 0 0; }
.tbp-ot-contact-box { margin-top: 15px; border-top: 1px dashed #ccc; padding-top: 20px; }
.tbp-ot-contact-box h4 { margin: 0 0 12px; color: #555; text-align: center; font-size: 15px; }
.tbp-ot-contact-row { display: flex; gap: 10px; }
.tbp-ot-call, .tbp-ot-wa { flex: 1; text-align: center; color: #fff !important; padding: 15px; text-decoration: none; border-radius: 5px; font-weight: bold; font-size: 16px; }
.tbp-ot-call { background: #1e1e1e; }
.tbp-ot-wa { background: #25D366; }
.tbp-ot-finish-row { display: flex; gap: 10px; margin-top: 15px; }
.tbp-ot-done-btn, .tbp-ot-cancel-btn { flex: 1; color: #fff; padding: 15px; border: none; border-radius: 5px; font-weight: bold; font-size: 16px; cursor: pointer; }
.tbp-ot-done-btn { background: #00a32a; }
.tbp-ot-cancel-btn { background: #d63638; }
.tbp-ot-done-btn:hover, .tbp-ot-cancel-btn:hover { opacity: .9; }
.tbp-ot-done-btn:disabled, .tbp-ot-cancel-btn:disabled { opacity: .6; cursor: wait; }

/* ===== طلب موقع الكابتن (العميل) + تنبيه الكابتن ===== */
.tbp-ot-creq { margin-top: 15px; padding: 12px; background: #e6f1f8; border: 1px solid #b9d9ec; border-radius: 8px; }
.tbp-ot-creq p { margin: 0 0 6px; font-size: 14px; color: #0b4a6f; font-weight: bold; }
.tbp-ot-creq .tbp-ot-btn:disabled { opacity: .65; cursor: not-allowed; }
.tbp-ot-creq-banner { display: flex; flex-direction: column; gap: 6px; padding: 12px; background: #fff7e0; border: 1px solid #f0d98a; border-radius: 8px; animation: tbpOtPulse 1.6s infinite; }
.tbp-ot-creq-banner strong { color: #7a5b00; font-size: 15px; }
.tbp-ot-creq-banner span { color: #555; font-size: 13px; }
.tbp-ot-creq-banner .tbp-ot-btn { margin-top: 4px; }

/* ===== لوحة الإدارة: محرر عنوان العميل ===== */
#tbp-ot-addr-map { height: 340px; border-radius: 8px; background: #eee; z-index: 1; }
.tbp-ot-latlng { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.tbp-ot-addr-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.tbp-ot-addr-cell { margin-bottom: 4px; color: #333; }

/* شريط طلب السماح بإشعارات كروم */
.tbp-ot-permbar { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 99998; display: flex; align-items: center; gap: 10px; background: #1e1e1e; color: #fff; padding: 10px 14px; border-radius: 10px; max-width: 94%; width: max-content; box-shadow: 0 6px 24px rgba(0,0,0,.28); font-size: 14px; direction: rtl; line-height: 1.5; }
.tbp-ot-permbar span { flex: 1; }
.tbp-ot-permbar button { border: 0; cursor: pointer; border-radius: 6px; font-weight: 700; font-size: 13px; padding: 8px 12px; font-family: inherit; }
.tbp-ot-perm-yes { background: var(--tbp-ot-accent, #0073aa); color: #fff; white-space: nowrap; }
.tbp-ot-perm-no { background: transparent; color: #bbb; padding: 6px 8px !important; }
@media (max-width: 600px) { .tbp-ot-permbar { flex-wrap: wrap; justify-content: center; text-align: center; } }
