/*
 * ========================================
 * داشبورد الموبايل — تصميم مستقل
 * Mobile Dashboard — Independent Styles
 * كل الاستايلات داخل @media (max-width: 767px)
 * مش هتأثر على الديسكتوب بأي شكل
 * ========================================
 */

@media (max-width: 767px) {

    /* ========================================
       شريط التنقل السفلي — Scrollable Bottom Nav
    ======================================== */
    .mob-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(15, 23, 42, 0.97);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid rgba(51, 65, 85, 0.6);
        z-index: 50;
        padding-bottom: env(safe-area-inset-bottom);
        box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.5);
    }

    .mob-bottom-nav-inner {
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding: 6px 8px;
        gap: 2px;
    }

    .mob-bottom-nav-inner::-webkit-scrollbar {
        display: none;
    }

    .mob-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 8px 14px;
        border-radius: 14px;
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        text-decoration: none;
        color: #64748b;
        min-width: 60px;
        flex-shrink: 0;
        position: relative;
    }

    .mob-nav-item.active {
        background: rgba(234, 179, 8, 0.12);
        color: #eab308;
    }

    .mob-nav-item.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 28px;
        height: 3px;
        background: #eab308;
        border-radius: 0 0 6px 6px;
        box-shadow: 0 0 10px rgba(234, 179, 8, 0.5);
    }

    .mob-nav-item:active {
        transform: scale(0.92);
        background: rgba(234, 179, 8, 0.08);
    }

    .mob-nav-icon {
        width: 22px;
        height: 22px;
        transition: transform 0.2s ease;
    }

    .mob-nav-item.active .mob-nav-icon {
        transform: scale(1.15);
    }

    .mob-nav-label {
        font-size: 10px;
        font-weight: 600;
        white-space: nowrap;
        letter-spacing: 0.01em;
    }

    .mob-nav-badge {
        position: absolute;
        top: 4px;
        right: 8px;
        min-width: 17px;
        height: 17px;
        font-size: 9px;
        font-weight: 800;
        background: linear-gradient(135deg, #22c55e, #16a34a);
        color: white;
        border-radius: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: 2px solid #0f172a;
    }

    /* ========================================
       بطاقة المحفظة الرئيسية — Hero Card
    ======================================== */
    .mob-hero-card {
        background: linear-gradient(135deg, rgba(30, 41, 59, 0.95) 0%, rgba(15, 23, 42, 0.9) 100%);
        border: 1px solid rgba(234, 179, 8, 0.2);
        border-radius: 20px;
        padding: 20px;
        margin-bottom: 16px;
        position: relative;
        overflow: hidden;
    }

    .mob-hero-card::before {
        content: '';
        position: absolute;
        top: -60px;
        right: -40px;
        width: 180px;
        height: 180px;
        background: radial-gradient(circle, rgba(234, 179, 8, 0.08) 0%, transparent 70%);
        pointer-events: none;
    }

    .mob-hero-label {
        font-size: 11px;
        color: #94a3b8;
        font-weight: 500;
        margin-bottom: 4px;
    }

    .mob-hero-value {
        font-size: 28px;
        font-weight: 800;
        color: #ffffff;
        line-height: 1.1;
        margin-bottom: 2px;
    }

    .mob-hero-currency {
        font-size: 13px;
        color: #64748b;
        font-weight: 500;
    }

    .mob-hero-stats {
        display: flex;
        gap: 12px;
        margin-top: 16px;
        padding-top: 16px;
        border-top: 1px solid rgba(51, 65, 85, 0.5);
    }

    .mob-hero-stat {
        flex: 1;
    }

    .mob-hero-stat-label {
        font-size: 9px;
        color: #64748b;
        margin-bottom: 3px;
    }

    .mob-hero-stat-value {
        font-size: 15px;
        font-weight: 700;
    }

    .mob-hero-profit-bar {
        height: 4px;
        background: rgba(51, 65, 85, 0.5);
        border-radius: 2px;
        margin-top: 12px;
        overflow: hidden;
    }

    .mob-hero-profit-bar-fill {
        height: 100%;
        border-radius: 2px;
        background: linear-gradient(90deg, #22c55e, #16a34a);
        transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* ========================================
       شريط الأسعار — Horizontal Price Strip
    ======================================== */
    .mob-price-strip {
        display: flex;
        gap: 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 4px 2px 10px;
        margin-bottom: 8px;
    }

    .mob-price-strip::-webkit-scrollbar {
        display: none;
    }

    .mob-price-card {
        flex-shrink: 0;
        background: rgba(30, 41, 59, 0.8);
        border: 1px solid rgba(51, 65, 85, 0.7);
        border-radius: 14px;
        padding: 14px 16px;
        min-width: 120px;
        transition: all 0.2s ease;
    }

    .mob-price-card:active {
        transform: scale(0.96);
        border-color: rgba(234, 179, 8, 0.4);
    }

    .mob-price-card-label {
        font-size: 10px;
        color: #94a3b8;
        margin-bottom: 6px;
    }

    .mob-price-card-value {
        font-size: 18px;
        font-weight: 800;
        color: #ffffff;
    }

    .mob-price-card-currency {
        font-size: 10px;
        color: #64748b;
        margin-right: 2px;
    }

    /* ========================================
       أزرار الإجراء السريع — Quick Actions
    ======================================== */
    .mob-quick-actions {
        display: flex;
        gap: 10px;
        margin-bottom: 20px;
    }

    .mob-action-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 16px 12px;
        border-radius: 16px;
        border: none;
        cursor: pointer;
        font-family: 'Tajawal', sans-serif;
        font-size: 14px;
        font-weight: 700;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        text-decoration: none;
    }

    .mob-action-btn:active {
        transform: scale(0.94);
    }

    .mob-action-btn-buy {
        background: linear-gradient(135deg, rgba(234, 179, 8, 0.2), rgba(234, 179, 8, 0.1));
        border: 1.5px solid rgba(234, 179, 8, 0.4);
        color: #eab308;
    }

    .mob-action-btn-sell {
        background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.08));
        border: 1.5px solid rgba(239, 68, 68, 0.3);
        color: #f87171;
    }

    .mob-action-icon {
        font-size: 22px;
        line-height: 1;
    }

    /* ========================================
       Bottom Sheet — فورم الشراء/البيع
    ======================================== */
    .mob-sheet-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(4px);
        z-index: 200;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .mob-sheet-overlay.open {
        opacity: 1;
        pointer-events: all;
    }

    .mob-sheet {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #1e293b;
        border-radius: 24px 24px 0 0;
        border-top: 1px solid rgba(51, 65, 85, 0.8);
        z-index: 201;
        padding: 0 0 calc(32px + env(safe-area-inset-bottom));
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        max-height: 90vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .mob-sheet.open {
        transform: translateY(0);
    }

    .mob-sheet-handle {
        width: 40px;
        height: 4px;
        background: rgba(100, 116, 139, 0.5);
        border-radius: 2px;
        margin: 12px auto 20px;
    }

    .mob-sheet-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 20px 16px;
        border-bottom: 1px solid rgba(51, 65, 85, 0.5);
    }

    .mob-sheet-title {
        font-size: 16px;
        font-weight: 700;
        color: #ffffff;
    }

    .mob-sheet-close {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: rgba(51, 65, 85, 0.5);
        border: none;
        color: #94a3b8;
        font-size: 18px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s;
    }

    .mob-sheet-close:active {
        background: rgba(239, 68, 68, 0.2);
        color: #f87171;
    }

    .mob-sheet-body {
        padding: 20px;
        display: flex;
        flex-direction: column;
        gap: 14px;
    }

    .mob-form-field {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .mob-form-label {
        font-size: 12px;
        color: #94a3b8;
        font-weight: 500;
    }

    .mob-form-input {
        background: rgba(15, 23, 42, 0.8);
        border: 1.5px solid rgba(51, 65, 85, 0.8);
        border-radius: 12px;
        padding: 13px 16px;
        color: #ffffff;
        font-size: 15px;
        font-family: 'Tajawal', sans-serif;
        width: 100%;
        box-sizing: border-box;
        transition: border-color 0.2s;
        -webkit-appearance: none;
    }

    .mob-form-input:focus {
        outline: none;
        border-color: rgba(234, 179, 8, 0.6);
        box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.08);
    }

    .mob-form-select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: 12px center;
        padding-left: 32px;
    }

    .mob-sheet-submit {
        background: #eab308;
        color: #0f172a;
        border: none;
        border-radius: 14px;
        padding: 16px;
        font-size: 16px;
        font-weight: 800;
        font-family: 'Tajawal', sans-serif;
        width: 100%;
        cursor: pointer;
        transition: all 0.2s;
        margin-top: 6px;
        box-shadow: 0 4px 20px rgba(234, 179, 8, 0.25);
    }

    .mob-sheet-submit:active {
        transform: scale(0.97);
        box-shadow: none;
    }

    .mob-sheet-submit.sell-mode {
        background: #ef4444;
        box-shadow: 0 4px 20px rgba(239, 68, 68, 0.25);
    }

    /* Type toggle inside sheet */
    .mob-type-toggle {
        display: flex;
        gap: 8px;
        background: rgba(15, 23, 42, 0.6);
        border-radius: 14px;
        padding: 4px;
        margin-bottom: 4px;
    }

    .mob-type-btn {
        flex: 1;
        padding: 10px;
        border-radius: 10px;
        border: none;
        font-family: 'Tajawal', sans-serif;
        font-size: 14px;
        font-weight: 700;
        cursor: pointer;
        transition: all 0.2s;
        color: #64748b;
        background: transparent;
    }

    .mob-type-btn.active-buy {
        background: #eab308;
        color: #0f172a;
        box-shadow: 0 2px 10px rgba(234, 179, 8, 0.3);
    }

    .mob-type-btn.active-sell {
        background: #ef4444;
        color: #ffffff;
        box-shadow: 0 2px 10px rgba(239, 68, 68, 0.3);
    }

    /* ========================================
       كروت العمليات — Transaction Cards
    ======================================== */
    .mob-tx-cards {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-bottom: 8px;
    }

    .mob-tx-card {
        background: rgba(30, 41, 59, 0.7);
        border: 1px solid rgba(51, 65, 85, 0.6);
        border-radius: 14px;
        padding: 14px 16px;
        display: flex;
        align-items: center;
        gap: 12px;
        position: relative;
        transition: all 0.2s;
    }

    .mob-tx-card.sell-card {
        border-right: 3px solid rgba(239, 68, 68, 0.5);
    }

    .mob-tx-card.buy-card {
        border-right: 3px solid rgba(234, 179, 8, 0.4);
    }

    .mob-tx-icon {
        width: 40px;
        height: 40px;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        flex-shrink: 0;
    }

    .mob-tx-icon.buy-icon {
        background: rgba(234, 179, 8, 0.1);
    }

    .mob-tx-icon.sell-icon {
        background: rgba(239, 68, 68, 0.1);
    }

    .mob-tx-info {
        flex: 1;
        min-width: 0;
    }

    .mob-tx-title {
        font-size: 14px;
        font-weight: 700;
        color: #e2e8f0;
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .mob-tx-badge {
        font-size: 9px;
        padding: 2px 7px;
        border-radius: 50px;
        font-weight: 700;
    }

    .mob-tx-badge.buy {
        background: rgba(234, 179, 8, 0.15);
        color: #eab308;
    }

    .mob-tx-badge.sell {
        background: rgba(239, 68, 68, 0.15);
        color: #f87171;
    }

    .mob-tx-meta {
        font-size: 11px;
        color: #64748b;
        margin-top: 3px;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .mob-tx-amount {
        text-align: left;
        flex-shrink: 0;
    }

    .mob-tx-cost {
        font-size: 13px;
        font-weight: 600;
        color: #e2e8f0;
    }

    .mob-tx-profit {
        font-size: 12px;
        font-weight: 700;
        margin-top: 2px;
    }

    .mob-tx-profit.pos { color: #22c55e; }
    .mob-tx-profit.neg { color: #ef4444; }

    .mob-tx-actions {
        display: flex;
        gap: 6px;
        flex-shrink: 0;
    }

    .mob-tx-action-btn {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        background: rgba(30, 41, 59, 0.6);
        border: 1px solid rgba(51, 65, 85, 0.5);
        color: #64748b;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s;
        text-decoration: none;
    }

    .mob-tx-action-btn:active {
        transform: scale(0.9);
    }

    .mob-tx-action-btn.edit:active {
        background: rgba(234, 179, 8, 0.15);
        border-color: rgba(234, 179, 8, 0.3);
        color: #eab308;
    }

    .mob-tx-action-btn.del:active {
        background: rgba(239, 68, 68, 0.15);
        border-color: rgba(239, 68, 68, 0.3);
        color: #ef4444;
    }

    /* ========================================
       أقسام قابلة للطي — Collapsible Sections
    ======================================== */
    .mob-collapsible-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 16px;
        cursor: pointer;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    .mob-collapsible-header:active {
        background: rgba(51, 65, 85, 0.2);
    }

    .mob-collapsible-arrow {
        width: 20px;
        height: 20px;
        color: #64748b;
        transition: transform 0.3s ease;
        flex-shrink: 0;
    }

    .mob-collapsible-arrow.open {
        transform: rotate(180deg);
    }

    .mob-collapsible-body {
        overflow: hidden;
        max-height: 0;
        transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .mob-collapsible-body.open {
        max-height: 2000px;
    }

    /* ========================================
       عرض الكل — Show More
    ======================================== */
    .mob-show-more {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 12px;
        border-radius: 12px;
        border: 1px dashed rgba(51, 65, 85, 0.6);
        color: #64748b;
        font-size: 13px;
        font-weight: 600;
        text-decoration: none;
        transition: all 0.2s;
        margin-top: 4px;
    }

    .mob-show-more:active {
        background: rgba(234, 179, 8, 0.05);
        border-color: rgba(234, 179, 8, 0.2);
        color: #eab308;
    }

    /* ========================================
       قسم المحفظة — Section Headings
    ======================================== */
    .mob-section-title {
        font-size: 15px;
        font-weight: 700;
        color: #eab308;
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 12px;
    }

    /* ========================================
       حالة فارغة — Empty State
    ======================================== */
    .mob-empty {
        text-align: center;
        padding: 32px 20px;
        color: #475569;
    }

    .mob-empty-icon {
        font-size: 40px;
        margin-bottom: 10px;
    }

    .mob-empty-text {
        font-size: 14px;
        font-weight: 500;
    }

    .mob-empty-hint {
        font-size: 12px;
        margin-top: 6px;
        color: #374151;
    }

    /* ========================================
       مخفي/ظاهر حسب الشاشة
    ======================================== */
    .mob-only { display: block !important; }
    .desk-only { display: none !important; }

    /* إخفاء الـ navbar الأصلي على الموبايل */
    #tour-navbar {
        display: none !important;
    }

    /* إخفاء الـ bottom nav القديم من navbar.php */
    nav.fixed.bottom-0 {
        display: none !important;
    }

    /* padding للبادي عشان البوتم ناف */
    body {
        padding-bottom: 80px !important;
    }

    /* تقليص padding العام */
    .max-w-4xl.mx-auto.p-4 {
        padding: 12px !important;
    }

    /* إخفاء عناصر الديسكتوب */
    #tour-alerts {
        display: none !important;
    }

    /* ========================================
       قسم السبائك — Compact Horizontal Scroll
    ======================================== */
    #tour-bullion {
        margin-right: -12px;
        margin-left: -12px;
        padding-bottom: 20px;
        background: linear-gradient(to bottom, rgba(15, 23, 42, 0) 0%, rgba(30, 41, 59, 0.1) 100%);
    }

    #tour-bullion .flex.items-center.justify-between {
        padding: 0 16px;
        margin-bottom: 12px !important;
    }

    .mob-scroll-x {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
        padding: 4px 16px 16px !important;
        gap: 12px !important;
    }

    .mob-scroll-x::-webkit-scrollbar {
        display: none;
    }

    .mob-scroll-x > a {
        flex: 0 0 180px !important;
        min-width: 180px !important;
        scroll-snap-align: start;
        background: rgba(30, 41, 59, 0.45) !important;
        border: 1px solid rgba(51, 65, 85, 0.4) !important;
        box-shadow: 0 4px 15px -5px rgba(0, 0, 0, 0.2) !important;
        padding: 12px !important;
        border-radius: 12px !important;
    }

    .mob-scroll-x .text-xs {
        font-size: 11px !important;
    }

} /* end of @media (max-width: 767px) */

/* على الديسكتوب: إخفاء عناصر الموبايل */
@media (min-width: 768px) {
    .mob-only { display: none !important; }
    .mob-sheet-overlay,
    .mob-sheet,
    .mob-bottom-nav { display: none !important; }
}
