/* ==========================================================================
   Almurakib Market Hours Pro — v2.0.0
   ──────────────────────────────────────────────────────────────────────────
   الهيكل:
     1.  متغيرات الألوان والثيم (Custom Properties)
     2.  الـ Wrapper الرئيسي
     3.  الهيدر (العنوان + الساعة)
     4.  شريط الملخص العلوي (Topbar)
     5.  بطاقة السوق القادم
     6.  شريط السيولة
     7.  الشريط الزمني (Timeline)
     8.  شريط التداخل (Overlap Strip)
     9.  الـ Grid وعدد الأعمدة
     10. بطاقة السوق (Card)
     11. ألوان التمييز (Accent Colors)
     12. Responsive Breakpoints
   ========================================================================== */


/* ──────────────────────────────────────────────────────────────────────────
   1. متغيرات الألوان والثيم
   ────────────────────────────────────────────────────────────────────────── */

/* الثيم الداكن (افتراضي) */
.amh-wrap {
    --amh-bg:         #0b1220;
    --amh-card:       #111a2b;
    --amh-card-2:     #0f1726;
    --amh-border:     rgba(255, 255, 255, 0.08);
    --amh-text:       #eef4ff;
    --amh-muted:      #9fb0cb;
    --amh-success:    #1ecb81;
    --amh-danger:     #ff5d73;
    --amh-warning:    #f8c14d;
    --amh-shadow:     0 10px 30px rgba(0, 0, 0, 0.25);
    --amh-radius-lg:  24px;
    --amh-radius-md:  18px;
    --amh-radius-sm:  12px;
}

/* الثيم الفاتح */
.amh-wrap.theme-light {
    --amh-bg:      #f8fbff;
    --amh-card:    #ffffff;
    --amh-card-2:  #f4f7fb;
    --amh-border:  rgba(20, 35, 60, 0.08);
    --amh-text:    #132238;
    --amh-muted:   #5f728f;
    --amh-shadow:  0 10px 30px rgba(17, 24, 39, 0.08);
}


/* ──────────────────────────────────────────────────────────────────────────
   2. الـ Wrapper الرئيسي
   ────────────────────────────────────────────────────────────────────────── */

.amh-wrap {
    direction:        rtl;
    color:            var(--amh-text);
    background:
        radial-gradient(circle at top right,    rgba(49, 99, 255, 0.18),   transparent 30%),
        radial-gradient(circle at bottom left,  rgba(30, 203, 129, 0.10),  transparent 30%),
        linear-gradient(180deg, #0b1220 0%, #0a111d 100%);
    border:           1px solid var(--amh-border);
    border-radius:    var(--amh-radius-lg);
    padding:          22px;
    overflow:         hidden;
    box-shadow:       var(--amh-shadow);
    position:         relative;
}

.amh-wrap.theme-light {
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}


/* ──────────────────────────────────────────────────────────────────────────
   3. الهيدر (العنوان + الساعة)
   ────────────────────────────────────────────────────────────────────────── */

.amh-head {
    display:         flex;
    align-items:     flex-start;
    justify-content: space-between;
    gap:             16px;
    margin-bottom:   20px;
}

/* Kicker: النص الصغير فوق العنوان */
.amh-kicker {
    display:        inline-block;
    font-size:      11px;
    line-height:    1;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color:          var(--amh-warning);
    margin-bottom:  8px;
}

.amh-title {
    margin:      0;
    font-size:   24px;
    line-height: 1.25;
    font-weight: 800;
    color:       var(--amh-text);
}

/* ساعة الجهاز العالمية */
.amh-global-clock {
    min-width:      120px;
    text-align:     left;
    background:     rgba(255, 255, 255, 0.04);
    border:         1px solid var(--amh-border);
    border-radius:  var(--amh-radius-md);
    padding:        10px 14px;
    backdrop-filter: blur(8px);
}

.amh-global-clock-label {
    display:       block;
    font-size:     11px;
    color:         var(--amh-muted);
    margin-bottom: 5px;
}

.amh-global-clock-value {
    display:     block;
    font-size:   18px;
    font-weight: 800;
}


/* ──────────────────────────────────────────────────────────────────────────
   4. شريط الملخص العلوي (Topbar)
   ────────────────────────────────────────────────────────────────────────── */

.amh-topbar {
    display:               grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap:                   12px;
    margin-bottom:         16px;
}

.amh-topbar-card {
    background:    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
    border:        1px solid var(--amh-border);
    border-radius: var(--amh-radius-md);
    padding:       14px 16px;
}

.amh-topbar-label {
    display:       block;
    font-size:     12px;
    color:         var(--amh-muted);
    margin-bottom: 6px;
}

.amh-topbar-value {
    display:     block;
    font-size:   17px;
    font-weight: 800;
    color:       var(--amh-text);
}


/* ──────────────────────────────────────────────────────────────────────────
   5. بطاقة السوق القادم
   ────────────────────────────────────────────────────────────────────────── */

.amh-next-market-card {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    gap:             12px;
    border:          1px solid var(--amh-border);
    border-radius:   20px;
    padding:         16px 18px;
    margin-bottom:   16px;
    background:      linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
}

.amh-next-market-kicker {
    display:       block;
    font-size:     12px;
    color:         var(--amh-muted);
    margin-bottom: 6px;
}

.amh-next-market-name {
    display:     block;
    font-size:   20px;
    font-weight: 800;
    color:       var(--amh-text);
}

.amh-next-market-label {
    display:       block;
    font-size:     12px;
    color:         var(--amh-muted);
    margin-bottom: 6px;
    text-align:    left;
}

.amh-next-market-time {
    display:     block;
    font-size:   18px;
    font-weight: 800;
    color:       var(--amh-warning);
    text-align:  left;
}


/* ──────────────────────────────────────────────────────────────────────────
   6. شريط السيولة
   ────────────────────────────────────────────────────────────────────────── */

.amh-liquidity-bar {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    gap:             12px;
    border:          1px solid var(--amh-border);
    border-radius:   20px;
    padding:         16px 18px;
    margin-bottom:   16px;
    background:      linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
}

.amh-liquidity-kicker {
    display:       block;
    font-size:     12px;
    color:         var(--amh-muted);
    margin-bottom: 6px;
}

.amh-liquidity-value {
    display:     block;
    font-size:   20px;
    font-weight: 800;
    color:       var(--amh-text);
}

/* نقطة مؤشر السيولة */
.amh-liquidity-dot {
    display:      block;
    width:        14px;
    height:       14px;
    border-radius: 50%;
    background:   #6b7280;
    box-shadow:   0 0 0 0 rgba(107, 114, 128, 0.5);
    transition:   background 0.4s ease, box-shadow 0.4s ease;
}

/* ألوان نقطة السيولة بحسب المستوى */
.amh-liquidity-bar[data-liquidity-level="سيولة ضعيفة"]      .amh-liquidity-dot {
    background: var(--amh-warning);
    box-shadow: 0 0 0 8px rgba(248, 193, 77, 0.10);
}

.amh-liquidity-bar[data-liquidity-level="سيولة متوسطة"]     .amh-liquidity-dot {
    background: #36d1dc;
    box-shadow: 0 0 0 8px rgba(54, 209, 220, 0.10);
}

.amh-liquidity-bar[data-liquidity-level="سيولة مرتفعة"]     .amh-liquidity-dot {
    background: var(--amh-success);
    box-shadow: 0 0 0 8px rgba(30, 203, 129, 0.12);
}

.amh-liquidity-bar[data-liquidity-level="ذروة التداول"]     .amh-liquidity-dot {
    background: var(--amh-danger);
    box-shadow: 0 0 0 10px rgba(255, 93, 115, 0.14);
}

.amh-liquidity-bar[data-liquidity-level="خارج أوقات النشاط"] .amh-liquidity-dot {
    background: #7c8799;
    box-shadow: none;
}


/* ──────────────────────────────────────────────────────────────────────────
   7. الشريط الزمني (Timeline)
   ────────────────────────────────────────────────────────────────────────── */

.amh-timeline {
    border:        1px solid var(--amh-border);
    border-radius: 20px;
    padding:       16px 18px;
    margin-bottom: 16px;
    background:    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
}

.amh-timeline-head {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    gap:             12px;
    margin-bottom:   16px;
    font-size:       13px;
    color:           var(--amh-muted);
}

.amh-timeline-head strong {
    color:       var(--amh-text);
    font-size:   15px;
    font-weight: 800;
}

/* المسار الذي تجلس عليه النقاط */
.amh-timeline-track {
    position:              relative;
    display:               grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap:                   18px;
}

/* الخط الأفقي خلف النقاط */
.amh-timeline-line {
    position:      absolute;
    top:           18px;
    right:         8%;
    left:          8%;
    height:        3px;
    border-radius: 999px;
    background:    linear-gradient(90deg, #1ecb81, #36d1dc, #ff5d73);
    opacity:       0.8;
    pointer-events: none;
}

/* نقطة واحدة على الشريط */
.amh-timeline-point {
    position:      relative;
    z-index:       2;
    background:    var(--amh-card-2);
    border:        1px solid var(--amh-border);
    border-radius: var(--amh-radius-md);
    padding:       18px 14px 14px;
    text-align:    center;
}

/* الدائرة الملوّنة أعلى كل نقطة */
.amh-timeline-point::before {
    content:          '';
    position:         absolute;
    top:              -8px;
    left:             50%;
    transform:        translateX(-50%);
    width:            16px;
    height:           16px;
    border-radius:    50%;
    border:           3px solid var(--amh-bg);
}

.amh-timeline-point.is-opened::before { background: #1ecb81; }
.amh-timeline-point.is-overlap::before { background: #36d1dc; }
.amh-timeline-point.is-closing::before { background: #ff5d73; }

.amh-timeline-point-label {
    display:       block;
    font-size:     11px;
    color:         var(--amh-muted);
    margin-bottom: 7px;
}

.amh-timeline-point strong {
    display:     block;
    font-size:   15px;
    font-weight: 800;
    color:       var(--amh-text);
    line-height: 1.4;
}


/* ──────────────────────────────────────────────────────────────────────────
   8. شريط التداخل (Overlap Strip)
   ────────────────────────────────────────────────────────────────────────── */

.amh-overlap-strip {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    gap:             10px;
    padding:         12px 16px;
    border-radius:   var(--amh-radius-md);
    margin-bottom:   18px;
    border:          1px solid rgba(255, 255, 255, 0.09);
    background:      linear-gradient(90deg, rgba(91, 134, 229, 0.16), rgba(54, 209, 220, 0.10));
}

.amh-overlap-strip-label {
    font-size:      12px;
    color:          var(--amh-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.amh-overlap-strip-value {
    font-size:   14px;
    font-weight: 800;
    color:       var(--amh-text);
}


/* ──────────────────────────────────────────────────────────────────────────
   9. الـ Grid وعدد الأعمدة
   ────────────────────────────────────────────────────────────────────────── */

.amh-grid {
    display: grid;
    gap:     14px;
}

.amh-wrap.columns-1 .amh-grid { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.amh-wrap.columns-2 .amh-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.amh-wrap.columns-3 .amh-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.amh-wrap.columns-4 .amh-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.amh-wrap.columns-5 .amh-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.amh-wrap.columns-6 .amh-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }


/* ──────────────────────────────────────────────────────────────────────────
   10. بطاقة السوق (Card)
   ────────────────────────────────────────────────────────────────────────── */

.amh-card {
    position:      relative;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.015) 100%),
        var(--amh-card);
    border:        1px solid var(--amh-border);
    border-radius: 22px;
    padding:       16px;
    min-height:    210px;
    box-shadow:    var(--amh-shadow);
    transition:    transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
    overflow:      hidden;
    display:       flex;
    flex-direction: column;
}

.amh-card:hover {
    transform:    translateY(-2px);
    border-color: rgba(255, 255, 255, 0.16);
    box-shadow:   0 16px 40px rgba(0, 0, 0, 0.3);
}

/* شريط اللون في الأسفل */
.amh-card::before {
    content:  '';
    position: absolute;
    inset:    auto auto 0 0;
    width:    100%;
    height:   3px;
    opacity:  0.95;
}

/* ── رأس البطاقة ── */
.amh-card-top {
    display:         flex;
    align-items:     flex-start;
    justify-content: space-between;
    gap:             12px;
    margin-bottom:   14px;
}

.amh-market-main {
    display:     flex;
    align-items: flex-start;
    gap:         10px;
    min-width:   0;
}

/* ── نقطة الحالة (مفتوح = أخضر نابض / مغلق = أحمر) ── */
.amh-dot {
    width:         10px;
    height:        10px;
    border-radius: 50%;
    background:    #6b7280;
    margin-top:    7px;
    flex-shrink:   0;
    transition:    background 0.3s ease;
}

.amh-card.is-open .amh-dot {
    background: var(--amh-success);
    animation:  amhPulse 1.8s infinite;
}

.amh-card.is-closed .amh-dot {
    background: var(--amh-danger);
}

@keyframes amhPulse {
    0%   { box-shadow: 0 0 0 0   rgba(30, 203, 129, 0.65); }
    70%  { box-shadow: 0 0 0 10px rgba(30, 203, 129, 0);   }
    100% { box-shadow: 0 0 0 0   rgba(30, 203, 129, 0);   }
}

/* ── أيقونة العلم ── */
.amh-market-icon-wrap {
    width:         38px;
    height:        38px;
    border-radius: var(--amh-radius-sm);
    display:       flex;
    align-items:   center;
    justify-content: center;
    background:    rgba(255, 255, 255, 0.05);
    border:        1px solid var(--amh-border);
    flex:          0 0 38px;
}

.amh-market-flag {
    font-size:   18px;
    line-height: 1;
}

/* ── اسم السوق والمدينة ── */
.amh-market-name {
    margin:      0 0 4px;
    font-size:   19px;
    font-weight: 800;
    line-height: 1.2;
    color:       var(--amh-text);
}

.amh-market-city {
    font-size: 13px;
    color:     var(--amh-muted);
}

/* ── شارة الحالة (مفتوح / مغلق) ── */
.amh-badge {
    white-space:  nowrap;
    font-size:    12px;
    font-weight:  700;
    padding:      8px 12px;
    border-radius: 999px;
    border:       1px solid var(--amh-border);
    background:   rgba(255, 255, 255, 0.04);
    color:        var(--amh-text);
    transition:   background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.amh-card.is-open .amh-badge {
    background:   rgba(30, 203, 129, 0.12);
    color:        #7ef0b6;
    border-color: rgba(30, 203, 129, 0.28);
}

.amh-card.is-closed .amh-badge {
    background:   rgba(255, 93, 115, 0.10);
    color:        #ffb2bc;
    border-color: rgba(255, 93, 115, 0.22);
}

/* ── شريحة الـ LIVE / رقم الترتيب ── */
.amh-rank-badge {
    position:      absolute;
    top:           12px;
    left:          12px;
    font-size:     11px;
    line-height:   1;
    padding:       6px 10px;
    border-radius: 999px;
    background:    rgba(255, 255, 255, 0.06);
    border:        1px solid var(--amh-border);
    color:         var(--amh-muted);
    font-weight:   800;
    z-index:       2;
    transition:    background 0.3s ease, color 0.3s ease;
}

.amh-card.is-open .amh-rank-badge {
    background:   rgba(30, 203, 129, 0.14);
    color:        #83f2bb;
    border-color: rgba(30, 203, 129, 0.30);
}

/* ── صف الشرائح (الجلسة + الأيقونة + النشاط) ── */
.amh-meta-row {
    display:     flex;
    flex-wrap:   wrap;
    gap:         8px;
    margin-bottom: 14px;
}

.amh-chip {
    display:       inline-flex;
    align-items:   center;
    justify-content: center;
    gap:           6px;
    padding:       6px 10px;
    border-radius: 999px;
    font-size:     11px;
    font-weight:   700;
    background:    rgba(255, 255, 255, 0.05);
    border:        1px solid var(--amh-border);
    color:         var(--amh-text);
}

/* ── أوقات الافتتاح والإغلاق ── */
.amh-price-line {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    gap:             10px;
    background:      linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
    border:          1px solid var(--amh-border);
    border-radius:   var(--amh-radius-md);
    padding:         14px;
    margin-bottom:   12px;
}

.amh-time-block {
    flex:      1 1 0;
    min-width: 0;
}

.amh-label {
    display:       block;
    font-size:     12px;
    color:         var(--amh-muted);
    margin-bottom: 6px;
}

.amh-time-block strong {
    display:     block;
    font-size:   18px;
    font-weight: 800;
    color:       var(--amh-text);
}

.amh-sep {
    width:       1px;
    align-self:  stretch;
    background:  var(--amh-border);
    flex-shrink: 0;
}

/* ── صفوف المعلومات (الوقت المحلي + التفاصيل) ── */
.amh-info-row {
    display:               grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap:                   10px;
    margin-bottom:         12px;
}

.amh-info-box {
    background:    var(--amh-card-2);
    border:        1px solid var(--amh-border);
    border-radius: var(--amh-radius-sm);
    padding:       12px;
}

.amh-info-label {
    display:       block;
    font-size:     11px;
    color:         var(--amh-muted);
    margin-bottom: 5px;
}

.amh-info-value {
    display:    block;
    font-size:  14px;
    line-height: 1.4;
    font-weight: 700;
    color:       var(--amh-text);
    word-break:  break-word;
}

/* ── الفوتر: العد التنازلي ── */
.amh-footer {
    margin-top: auto;
    padding-top: 4px;
}

.amh-countdown {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    gap:             10px;
    background:      rgba(255, 255, 255, 0.03);
    border:          1px solid var(--amh-border);
    border-radius:   var(--amh-radius-sm);
    padding:         12px 14px;
}

.amh-countdown-label {
    font-size: 12px;
    color:     var(--amh-muted);
}

.amh-countdown-value {
    font-size:   16px;
    font-weight: 800;
    color:       var(--amh-text);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}


/* ──────────────────────────────────────────────────────────────────────────
   11. ألوان التمييز (Accent Colors)
       الشريط الملوّن في أسفل كل بطاقة
   ────────────────────────────────────────────────────────────────────────── */

.amh-card.accent-gold::before   { background: linear-gradient(90deg, #f3b33e, #ffd877); }
.amh-card.accent-blue::before   { background: linear-gradient(90deg, #3ea0ff, #76c7ff); }
.amh-card.accent-purple::before { background: linear-gradient(90deg, #9168ff, #c090ff); }
.amh-card.accent-green::before  { background: linear-gradient(90deg, #21c98b, #7fffd4); }
.amh-card.accent-cyan::before   { background: linear-gradient(90deg, #36d1dc, #5b86e5); }
.amh-card.accent-red::before    { background: linear-gradient(90deg, #ff5d73, #ff8a65); }


/* ──────────────────────────────────────────────────────────────────────────
   Compact Mode — يُصغِّر الـ padding والـ font-sizes
   ────────────────────────────────────────────────────────────────────────── */

.amh-wrap.compact-yes .amh-card {
    min-height: auto;
    padding:    12px;
}

.amh-wrap.compact-yes .amh-market-name       { font-size: 17px; }
.amh-wrap.compact-yes .amh-time-block strong { font-size: 16px; }
.amh-wrap.compact-yes .amh-price-line        { padding: 10px 12px; }
.amh-wrap.compact-yes .amh-meta-row          { margin-bottom: 10px; }


/* ──────────────────────────────────────────────────────────────────────────
   12. Responsive Breakpoints
   ────────────────────────────────────────────────────────────────────────── */

/* ── 1200px: تقليل الأعمدة الكبيرة ── */
@media (max-width: 1200px) {
    .amh-wrap.columns-4 .amh-grid,
    .amh-wrap.columns-5 .amh-grid,
    .amh-wrap.columns-6 .amh-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ── 1024px: التبويل ── */
@media (max-width: 1024px) {
    .amh-head {
        flex-direction: column;
        align-items:    stretch;
    }

    .amh-global-clock {
        text-align: right;
    }

    .amh-topbar {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }

    .amh-wrap.columns-3 .amh-grid,
    .amh-wrap.columns-4 .amh-grid,
    .amh-wrap.columns-5 .amh-grid,
    .amh-wrap.columns-6 .amh-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .amh-next-market-card,
    .amh-liquidity-bar {
        flex-direction: column;
        align-items:    flex-start;
    }

    .amh-next-market-label,
    .amh-next-market-time {
        text-align: right;
    }
}

/* ── 767px: الموبايل ── */
@media (max-width: 767px) {
    .amh-wrap {
        padding:       16px;
        border-radius: var(--amh-radius-lg);
    }

    .amh-title { font-size: 21px; }

    /* كل الأعمدة تتحول لعمود واحد */
    .amh-grid,
    .amh-wrap.columns-2 .amh-grid,
    .amh-wrap.columns-3 .amh-grid,
    .amh-wrap.columns-4 .amh-grid,
    .amh-wrap.columns-5 .amh-grid,
    .amh-wrap.columns-6 .amh-grid {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }

    .amh-price-line { padding: 12px; }

    .amh-info-row {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }

    .amh-overlap-strip {
        flex-direction: column;
        align-items:    flex-start;
    }

    .amh-rank-badge {
        top:  10px;
        left: 10px;
    }

    .amh-timeline-track {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }

    .amh-timeline-line {
        display: none;
    }
}