/* ====================================================================
   📱 تصميم الجوال — شاشات أقل من 700px
==================================================================== */

/* ===== Bottom Nav (الأزرار السفلية الثابتة) ===== */

/* إخفاء النافبار العلوي والروابط */
.navbar .nav-left {
    display: none !important;
}

/* الإبقاء على الشعار فقط في الأعلى — مدمج */
.navbar {
    flex-direction: row !important;
    justify-content: center !important;
    padding: 10px 0 !important;
    width: 96% !important;
    border-bottom: 1px solid #eee;
    margin-bottom: 0;
}

.navbar .nav-right {
    text-align: center;
}

.navbar .logo {
    font-size: 1.05rem;
}

.navbar .logo-tagline {
    font-size: 0.7rem;
}

/* شريط التنقل السفلي */
body {
    padding-bottom: 70px !important;
}

.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex !important;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
    padding: 6px 4px 8px;
}

.mbn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 2px;
    color: #6b7280;
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    transition: color 0.15s;
    min-width: 0;
}

.mbn-item:hover {
    color: #1d4ed8;
}

.mbn-item.active {
    color: #1d4ed8;
}

.mbn-icon {
    font-size: 1.3rem;
    line-height: 1;
}

.mbn-label {
    font-size: 0.68rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* لو لوحة التحكم ظاهرة، ٤ عناصر؛ لو لا، ٣ عناصر */
.mbn-item.mbn-admin {
    color: #c026d3;
}

/* ===== الداشبورد ===== */

.dashboard-layout {
    grid-template-columns: 1fr !important;
    width: 96% !important;
    gap: 12px;
}

.dl-side { order: 1; }
.dl-main { order: 2; }

.dl-cards {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
}

.dl-card.dl-card-value,
.dl-card.dl-card-pos,
.dl-card.dl-card-neg {
    grid-column: 1 / -1;
}

.dl-chart-canvas-wrap {
    width: 200px !important;
    height: 200px !important;
    max-width: 200px !important;
    margin: 0 auto !important;
    position: relative !important;
}

/* ===== جدول الأسهم → بطاقات ===== */

.container {
    width: 96%;
    margin: 14px auto;
}

.container > table {
    display: block;
    background: transparent;
    border: none;
    box-shadow: none;
    width: 100%;
}

.container > table thead { display: none; }

.container > table tbody {
    display: block;
    width: 100%;
}

.container > table tbody tr {
    display: block;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 10px;
    padding: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.container > table tbody tr td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    border: none;
    border-bottom: 1px dashed #f3f4f6;
    font-size: 0.92rem;
    text-align: start;
}

.container > table tbody tr td:last-child {
    border-bottom: none;
    padding-top: 12px;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

/* العنوان: الشركة [اسم الشركة] [السعر] في سطر واحد */
.container > table tbody tr td:nth-child(1) {
    display: grid !important;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    color: #1f2937;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 12px;
    margin-bottom: 4px;
    font-size: 0.78rem;
    font-weight: 500;
    text-align: center;
}

.container > table tbody tr td:nth-child(1)::before {
    content: 'الشركة';
    color: #1f2937;
    font-size: 0.78rem;
    font-weight: 500;
    text-align: start;
}

/* الاسم في العمود الأوسط */
.container > table tbody tr td:nth-child(1) strong {
    display: inline !important;
    color: #1f2937;
    font-size: 0.78rem;
    font-weight: 500;
    text-align: center;
}

/* الرمز في العمود اليسار، نفس سطر الاسم */
.container > table tbody tr td:nth-child(1) .stock-symbol-sub {
    display: inline !important;
    color: #9ca3af;
    font-size: 0.7rem;
    font-weight: 500;
    direction: ltr;
    text-align: end;
    margin-top: 0;
}

/* (تم حذف إخفاء :nth-child(2) لأن العمود الثاني الآن "الكمية" وليس "السعر") */

/* labels قبل القيم — الترتيب الجديد:
   1: الشركة | 2: الكمية | 3: المتوسط | 4: السعر | 5: القيمة السوقية | 6: الربح/الخسارة | 7: إجمالي التوزيعات | 8: إجراءات */
.container > table tbody tr td:nth-child(2)::before { content: 'الكمية'; }
.container > table tbody tr td:nth-child(3)::before { content: 'متوسط الشراء'; }
.container > table tbody tr td:nth-child(4)::before { content: 'السعر الحالي'; }
.container > table tbody tr td:nth-child(5)::before { content: '💼 القيمة السوقية'; }
.container > table tbody tr td:nth-child(6)::before { content: 'الربح/الخسارة'; }
.container > table tbody tr td:nth-child(7)::before { content: 'إجمالي التوزيعات'; }

.container > table tbody tr td::before {
    color: #6b7280;
    font-size: 0.82rem;
    font-weight: 500;
}

.container > table tbody tr td:last-child::before {
    display: none;
}

/* القيمة السوقية — بارزة (العمود الخامس الآن) */
.container > table tbody tr td:nth-child(5) {
    background: #eff6ff;
    margin: 6px -14px;
    padding: 12px 14px !important;
    border: none;
    border-top: 1px solid #dbeafe;
    border-bottom: 1px solid #dbeafe;
    font-size: 1.05rem;
    font-weight: 800;
    color: #1d4ed8;
}

.container > table tbody tr td:nth-child(5)::before {
    color: #1d4ed8;
    font-size: 0.85rem;
    font-weight: 700;
}

/* الأزرار */
.container > table tbody tr td:last-child button {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
    margin: 0;
    padding: 8px 10px;
    font-size: 0.78rem;
    border-radius: 8px;
}

/* ===== Modal "عرض" — جدول المعاملات ===== */

/* الجداول داخل modal الـ stock-details */
#stockDetailsModal .modal-content {
    width: 96% !important;
    max-width: 96% !important;
    padding: 14px !important;
    max-height: 92vh !important;
    overflow-y: auto !important;
}

/* ====================================================================
   جدولا المعاملات (.txn-table) والتوزيعات (.div-table) → بطاقات
==================================================================== */

#stockDetailsModal .table-scroll,
.modal-content .table-scroll {
    overflow: visible !important;
}

#stockDetailsModal .details-table,
.modal-content .details-table {
    display: block !important;
    width: 100% !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

#stockDetailsModal .details-table thead,
.modal-content .details-table thead {
    display: none !important;
}

#stockDetailsModal .details-table tbody,
.modal-content .details-table tbody {
    display: block !important;
    width: 100% !important;
}

/* كل صف يصير بطاقة */
#stockDetailsModal .details-table tbody tr,
.modal-content .details-table tbody tr {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
    background: #fff !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 12px !important;
    padding: 14px !important;
    margin-bottom: 10px !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04) !important;
    position: relative;
}

#stockDetailsModal .details-table tbody tr td,
.modal-content .details-table tbody tr td {
    display: flex !important;
    flex-direction: column;
    gap: 3px;
    padding: 0 !important;
    border: none !important;
    text-align: start !important;
    font-size: 0.9rem;
}

#stockDetailsModal .details-table tbody tr td::before,
.modal-content .details-table tbody tr td::before {
    color: #9ca3af;
    font-size: 0.72rem;
    font-weight: 500;
}

/* ===== رقم # (نفس الشي في الجدولين) ===== */
#stockDetailsModal .details-table tbody tr td:nth-child(1),
.modal-content .details-table tbody tr td:nth-child(1) {
    position: absolute;
    top: 10px;
    left: 12px;
    background: #f3f4f6;
    color: #6b7280;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0 !important;
}

#stockDetailsModal .details-table tbody tr td:nth-child(1)::before,
.modal-content .details-table tbody tr td:nth-child(1)::before {
    content: '';
}

/* ===== الإجراءات (آخر عمود في الجدولين) — full-width ===== */
#stockDetailsModal .details-table tbody tr td:last-child,
.modal-content .details-table tbody tr td:last-child {
    grid-column: 1 / -1;
    border-top: 1px dashed #f3f4f6;
    padding-top: 10px !important;
    margin-top: 4px;
    flex-direction: row !important;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

#stockDetailsModal .details-table tbody tr td:last-child::before,
.modal-content .details-table tbody tr td:last-child::before {
    content: 'إجراءات';
    width: 100%;
    margin-bottom: 4px;
}

#stockDetailsModal .details-table tbody tr td:last-child button,
.modal-content .details-table tbody tr td:last-child button {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
    padding: 7px 10px;
    font-size: 0.78rem;
    border-radius: 6px;
}

/* ====================================================================
   📋 جدول المعاملات (.txn-table) — labels خاصة
   الأعمدة: 1:# | 2:التاريخ | 3:النوع | 4:عدد الأسهم | 5:سعر الشراء | 6:الإجمالي | 7:إجراءات
==================================================================== */

#stockDetailsModal .txn-table tbody tr td:nth-child(2)::before,
.modal-content .txn-table tbody tr td:nth-child(2)::before { content: 'التاريخ'; }

#stockDetailsModal .txn-table tbody tr td:nth-child(3)::before,
.modal-content .txn-table tbody tr td:nth-child(3)::before { content: 'النوع'; }

#stockDetailsModal .txn-table tbody tr td:nth-child(4)::before,
.modal-content .txn-table tbody tr td:nth-child(4)::before { content: 'عدد الأسهم'; }

#stockDetailsModal .txn-table tbody tr td:nth-child(5)::before,
.modal-content .txn-table tbody tr td:nth-child(5)::before { content: 'سعر الشراء'; }

#stockDetailsModal .txn-table tbody tr td:nth-child(6)::before,
.modal-content .txn-table tbody tr td:nth-child(6)::before { content: 'الإجمالي'; }

/* تكبير الأرقام في المعاملات */
#stockDetailsModal .txn-table tbody tr td:nth-child(4),
#stockDetailsModal .txn-table tbody tr td:nth-child(5),
#stockDetailsModal .txn-table tbody tr td:nth-child(6),
.modal-content .txn-table tbody tr td:nth-child(4),
.modal-content .txn-table tbody tr td:nth-child(5),
.modal-content .txn-table tbody tr td:nth-child(6) {
    font-weight: 700;
    color: #1f2937;
}

/* الإجمالي بلون أخضر */
#stockDetailsModal .txn-table tbody tr td:nth-child(6),
.modal-content .txn-table tbody tr td:nth-child(6) {
    color: #047857;
    font-size: 1rem;
}

/* المعاملات: السعر والإجمالي يأخذون السطر كامل (full-width) */
#stockDetailsModal .txn-table tbody tr td:nth-child(5),
#stockDetailsModal .txn-table tbody tr td:nth-child(6),
.modal-content .txn-table tbody tr td:nth-child(5),
.modal-content .txn-table tbody tr td:nth-child(6) {
    grid-column: 1 / -1;
}

/* المعاملات: الرقم # في صف معاملات يحتاج padding-right من اليمين بسبب وضع # في اليسار */
#stockDetailsModal .txn-table tbody tr td:nth-child(2),
.modal-content .txn-table tbody tr td:nth-child(2) {
    padding-right: 0 !important;
}

/* ====================================================================
   💸 جدول التوزيعات (.div-table) — labels خاصة
   الأعمدة: 1:# | 2:التاريخ | 3:القيمة | 4:إجراءات
==================================================================== */

#stockDetailsModal .div-table tbody tr td:nth-child(2)::before,
.modal-content .div-table tbody tr td:nth-child(2)::before { content: 'التاريخ'; }

#stockDetailsModal .div-table tbody tr td:nth-child(3)::before,
.modal-content .div-table tbody tr td:nth-child(3)::before { content: 'القيمة'; }

/* القيمة بلون أخضر بارز */
#stockDetailsModal .div-table tbody tr td:nth-child(3),
.modal-content .div-table tbody tr td:nth-child(3) {
    font-weight: 700;
    color: #047857;
    font-size: 1rem;
}

/* ===== البحث الذكي المضغوط في الجوال ===== */
.quick-add-compact {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    width: 96% !important;
    padding: 12px !important;
}

.quick-add-compact .qac-title {
    font-size: 0.95rem;
}

.quick-add-compact .qac-search-wrap input {
    font-size: 0.95rem;
    padding: 10px 14px;
}

/* ===== رمز السهم في الجوال ===== */
.container > table tbody tr td:nth-child(1) .stock-symbol-sub {
    display: inline !important;
    color: #9ca3af;
    font-size: 0.7rem;
    direction: ltr;
    text-align: end;
    margin-top: 0;
}

/* في الجوال: السعر والقيمة السوقية يحتفظون بنفس البنية: الرقم فوق + النسبة تحت */
.container > table tbody tr td:nth-child(2) strong,
.container > table tbody tr td:nth-child(6) strong {
    font-weight: 700;
}

.container > table tbody tr td:nth-child(2) .day-change,
.container > table tbody tr td:nth-child(6) .day-change {
    font-size: 0.74rem;
    margin-top: 2px;
    display: block;
}

/* الإصلاح: في الجوال td:nth-child(2) كان مخفي. الحين نخليه يظهر داخل td:nth-child(1) */
/* لا بل نتركه: السعر مع النسبة يطلعون كنص بادج بجانب الاسم */

/* ====================================================================
   💰 إصلاح حجم رمز الريال في الجوال
   المشكلة: الرمز نسبي للخط (0.85em)، وفي بعض المواضع يطلع كبير
==================================================================== */

/* الحجم الافتراضي - أصغر قليلاً في الجوال */
.riyal-symbol {
    width: 0.75em !important;
    height: 0.75em !important;
    min-width: 0.75em;
    max-width: 0.75em;
    vertical-align: -0.05em;
}

/* بطاقات الداشبورد الكبيرة - الرمز أصغر */
.dl-card-num .riyal-symbol,
.ds-card strong .riyal-symbol {
    width: 0.7em !important;
    height: 0.7em !important;
    min-width: 0.7em;
    max-width: 0.7em;
}

/* بطاقات تفاصيل السهم (modal) */
.details-summary .ds-card strong .riyal-symbol {
    width: 0.7em !important;
    height: 0.7em !important;
}

/* بطاقة الهدف - تخطيط أفضل */
.goal-plan-card .riyal-symbol,
.gp-item .riyal-symbol,
.gp-item-detail .riyal-symbol,
.gp-item-total .riyal-symbol {
    width: 0.7em !important;
    height: 0.7em !important;
    min-width: 0.7em;
    max-width: 0.7em;
}

/* تقليل الـ gap بين الرمز والرقم في الجوال */
.cur-amount {
    gap: 0.1em !important;
}
