/* Mobile-specific styles - Only affects screens below 768px */
/* لا يؤثر على التصميم الأساسي للموقع */

/* إخفاء عناصر الموبايل على الديسكتوب */
@media only screen and (min-width: 769px) {

    .mobile-bottom-sheet,
    .mobile-menu-overlay,
    .mobile-app-bar {
        display: none !important;
    }
}


/* تحسينات الأداء للموبايل */
@media only screen and (max-width: 768px) {

    /* تسريع الرسم */
    * {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    /* تقليل استخدام GPU */
    img,
    video {
        will-change: auto !important;
    }

    /* تحسين التمرير */
    body {
        -webkit-overflow-scrolling: touch;
    }

    /* إلغاء الحاوية الذهبية للجداول */
    .custom-table-container {
        border: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        margin: 0 !important;
    }

    /* إخفاء الحاوية الخلفية للجدول */
    .prices-section {
        background: transparent !important;
        border: none !important;
        padding: 10px 0 !important;
    }

    /* توسيع الجدول لعرض الشاشة الكامل */
    .single-table-container,
    .table-content {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow-x: hidden !important;
    }

    /* تغيير لون نص التنبيه إلى أبيض للوضع المظلم */
    .price-disclaimer {
        color: #ffffff !important;
    }

    .price-disclaimer strong {
        color: #ffd700 !important;
        /* ذهبي للتأكيد */
    }

    /* تصغير الجدول والخطوط */
    .currency-table {
        font-size: 12px !important;
        width: 100% !important;
    }

    .currency-table th,
    .currency-table td {
        padding: 8px 4px !important;
        font-size: 12px !important;
    }

    .currency-table th {
        font-size: 11px !important;
    }

    /* تصغير شعار الجدول */
    .header-logo {
        max-width: 25px !important;
        height: auto !important;
    }

    .table-header {
        font-size: 13px !important;
        padding: 8px !important;
    }

    /* أزرار التبويب بجانب بعض */
    .price-tabs {
        display: flex !important;
        flex-direction: row !important;
        gap: 5px !important;
        justify-content: space-between !important;
        margin-bottom: 15px !important;
    }

    .tab-btn {
        flex: 1 !important;
        padding: 8px 5px !important;
        font-size: 12px !important;
        white-space: nowrap !important;
    }

    /* إلغاء الحاوية الذهبية للشارت */
    .chart-section {
        border: none !important;
        border-radius: 0 !important;
        padding: 15px 0 !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    /* توسيع الشارت لعرض الشاشة */
    .chart-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        height: 220px !important;
        padding: 10px !important;
        border: none !important;
        overflow: hidden !important;
    }

    /* تحسين مربعات اختيار العملات */
    .currency-selector {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 5px !important;
        margin-bottom: 10px !important;
    }

    .currency-box {
        padding: 8px 5px !important;
        font-size: 11px !important;
    }

    .currency-icon {
        font-size: 16px !important;
    }

    .currency-name {
        font-size: 10px !important;
    }

    /* أزرار نوع السعر بجانب بعض */
    .price-type-selector {
        display: flex !important;
        flex-direction: row !important;
        gap: 5px !important;
        margin-bottom: 10px !important;
    }

    .price-type-btn {
        flex: 1 !important;
        padding: 6px 5px !important;
        font-size: 11px !important;
    }

    /* أزرار المدة الزمنية */
    .chart-duration-selector {
        display: flex !important;
        gap: 5px !important;
        margin-bottom: 10px !important;
    }

    .duration-btn {
        flex: 1 !important;
        padding: 6px 5px !important;
        font-size: 10px !important;
    }

    /* APP HEADER IMPLEMENTATION - BOTTOM NAVIGATION STYLE */

    .desktop-only {
        display: none !important;
    }

    /* Add padding to body so content isn't hidden behind bottom bar */
    body {
        padding-bottom: 65px !important;
    }


    /* Unified Dark Mobile App Bar (App-like Feel) */
    .mobile-app-bar {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 65px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-around !important;
        z-index: 2000 !important;
        background: rgba(10, 25, 41, 0.95) !important;
        /* Always Dark Blue/Black */
        border-top: 1px solid rgba(255, 215, 0, 0.2) !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4) !important;
    }

    /* Force Dark Style even in Light Mode */
    body.light-theme .mobile-app-bar {
        background: rgba(10, 25, 41, 0.95) !important;
        border-top: 1px solid rgba(255, 215, 0, 0.2) !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4) !important;
    }

    /* Algeria Mode */
    body:not(.light-theme) .algeria-home .mobile-app-bar,
    body:not(.light-theme) .algeria-converter .mobile-app-bar,
    body.light-theme .algeria-home .mobile-app-bar,
    body.light-theme .algeria-converter .mobile-app-bar {
        background: rgba(0, 20, 10, 0.95) !important;
        /* Dark Greenish for Algeria */
        border-top-color: rgba(0, 150, 57, 0.4) !important;
    }

    /* iOS-Style App Bar Item - Minimal & Clean */
    .app-bar-item {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        background: transparent;
        border: none;
        color: rgba(255, 255, 255, 0.7) !important;
        /* White-ish always */
        text-decoration: none;
        flex: 1;
        min-height: 48px;
        cursor: pointer;
        transition: all 0.2s ease;
        gap: 2px;
        padding: 4px 8px;
        position: relative;
        -webkit-tap-highlight-color: transparent;
    }

    /* Light Mode Item Override - Keep White */
    body.light-theme .app-bar-item {
        color: rgba(255, 255, 255, 0.7) !important;
    }

    /* Icon Styling - Smaller as requested */
    .app-bar-item .icon {
        font-size: 20px !important;
        /* Reduced from 26px */
        line-height: 1;
        transition: transform 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
        filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
        margin-bottom: 4px;
    }

    /* Label Styling */
    .app-bar-item .label {
        font-size: 10px;
        font-weight: 500;
        letter-spacing: 0.2px;
        margin-top: 2px;
        opacity: 0.9;
    }

    /* Active State - Gold */
    .app-bar-item.active {
        color: #FFD700 !important;
        opacity: 1;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 8px;
    }

    body.light-theme .app-bar-item.active {
        color: #FFD700 !important;
        background: rgba(255, 255, 255, 0.05);
    }

    /* Algeria Active State */
    body.light-theme .algeria-home .app-bar-item.active,
    body.light-theme .algeria-converter .app-bar-item.active {
        color: #009639;
    }

    /* Active Icon Animation */
    .app-bar-item.active .icon {
        transform: scale(1.08);
    }

    /* Touch Feedback - iOS Style */
    .app-bar-item:active {
        transform: scale(0.92);
        opacity: 0.7;
    }

    .app-bar-item:active .icon {
        transform: scale(0.88);
    }

    /* Remove old specific button styles if they conflict */
    .mobile-menu-toggle {
        width: auto;
        height: auto;
        display: flex;
        /* Keep flex properties for bars */
        flex-direction: column;
        justify-content: center;
        align-items: center;
        background: transparent;
        border: none;
        padding: 0;
        cursor: pointer;
        gap: 5px;
    }

    .mobile-menu-toggle .bar {
        width: 25px;
        height: 3px;
        background-color: #ffd700;
        /* Gold */
        border-radius: 2px;
        transition: all 0.3s ease;
    }

    /* App Bar Actions (Right Side) */
    /* .app-bar-actions and .app-bar-icon styles are replaced by .app-bar-item */
    /*
    .app-bar-actions {
        display: flex;
        align-items: center;
        gap: 20px;
    }

    .app-bar-icon {
        font-size: 24px;
        color: #fff;
        background: transparent;
        border: none;
        text-decoration: none;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        transition: all 0.2s;
    }

    .app-bar-icon:active {
        background-color: rgba(255, 215, 0, 0.2);
        color: #ffd700;
        transform: scale(0.9);
    }
    */

    /* MOBILE BOTTOM SHEET (Fresh Class) */
    .mobile-bottom-sheet {
        position: fixed !important;
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        /* Force bottom anchor */

        transform: translateY(110%);
        /* Start hidden below */

        width: 100% !important;
        height: auto !important;
        max-height: 85vh;
        /* 85% of screen height max */

        background-color: #ffffff;
        z-index: 2001 !important;
        /* Topmost */

        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);

        display: flex;
        flex-direction: column;

        box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.2);
        border-radius: 20px 20px 0 0;
        border-top: 1px solid rgba(0, 0, 0, 0.05);

        overflow: hidden;
        padding-bottom: 20px;
    }

    /* Dark Mode */
    body.dark-theme .mobile-bottom-sheet {
        background-color: #0a1929;
        border: 1px solid #1a2f45;
        box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.5);
    }

    .mobile-bottom-sheet.active {
        transform: translateY(0);
        /* Slide Up */
    }



    /* =========================================
       BASE STYLES (DEFAULT = DARK MODE)
       ========================================= */

    /* Drawer Header - Always #002244 for Identity */
    .mobile-menu-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 25px 20px;
        background: linear-gradient(135deg, #000000 0%, #1a1a1a 100%);
        color: #fff;
        border-bottom: 3px solid #FFD700;
        height: 80px;
        flex-shrink: 0;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }

    /* Light Mode Override */
    body.light-theme .mobile-menu-header {
        background: linear-gradient(135deg, #002244 0%, #003366 100%);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }

    .menu-title {
        font-size: 20px;
        font-weight: 700;
        color: #FFD700;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    }

    .mobile-menu-close {
        background: rgba(255, 215, 0, 0.1);
        border: 2px solid #FFD700;
        color: #FFD700;
        font-size: 18px;
        width: 35px;
        height: 35px;
        border-radius: 50%;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s ease;
        box-shadow: 0 2px 8px rgba(255, 215, 0, 0.2);
    }

    .mobile-menu-close:active {
        background-color: #FFD700;
        color: #002244;
        transform: scale(0.95);
    }

    /* Drawer Container (Dark Default) */
    .mobile-bottom-sheet {
        background-color: #0a1929;
        /* Dark Blue */
        border-top: 1px solid #1a2f45;
    }

    /* Drawer Content (Dark Default) */
    .mobile-nav-list {
        flex: 1;
        overflow-y: auto;
        padding: 10px 0;
        background-color: #05101a;
        /* Very Dark */
    }

    .mobile-nav-list ul {
        list-style: none;
        padding: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .mobile-nav-list li {
        padding: 0 15px;
    }

    /* Link Cards (Dark Default) */
    .mobile-nav-list li a {
        display: flex;
        align-items: center;
        padding: 16px 18px;
        color: #e2e8f0;
        text-decoration: none;
        font-size: 16px;
        font-weight: 600;
        background: linear-gradient(135deg, #0f2438 0%, #1a2f45 100%);
        border-radius: 15px;
        border: 1px solid rgba(255, 215, 0, 0.1);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
        position: relative;
        overflow: hidden;
    }

    .mobile-nav-list li a::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.1), transparent);
        transition: left 0.5s ease;
    }

    .mobile-nav-list li a:active::before {
        left: 100%;
    }

    .mobile-nav-list li a:active {
        background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
        color: #002244;
        border-color: #FFD700;
        transform: translateY(-2px);
        box-shadow: 0 6px 15px rgba(255, 215, 0, 0.3);
    }

    .mobile-nav-list .nav-icon {
        margin-left: 15px;
        font-size: 22px;
        width: 28px;
        text-align: center;
        transition: transform 0.3s ease;
    }

    .mobile-nav-list li a:active .nav-icon {
        transform: scale(1.2);
    }

    /* Drawer Footer (Dark Default) */
    .mobile-menu-footer {
        padding: 15px 20px;
        background-color: #0a1929;
        border-top: 1px solid #1e3a5f;
        display: flex;
        flex-direction: column;
        gap: 15px;
        flex-shrink: 0;
    }

    .menu-socials {
        display: flex;
        justify-content: center;
        gap: 25px;
        margin-bottom: 10px;
    }

    .social-icon {
        font-size: 28px;
        text-decoration: none;
        color: #ffd700;
    }

    .menu-theme-toggle {
        display: flex;
        justify-content: space-between;
        align-items: center;
        background-color: #002244;
        color: #fff;
        padding: 12px 20px;
        border-radius: 12px;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }

    /* =========================================
       LIGHT MODE OVERRIDES (.light-theme)
       ========================================= */

    /* Nav Bar Light Mode */
    body.light-theme .mobile-app-bar {
        border-top-color: #ffd700;
        background-color: #002244;
        /* Keep Nav Dark for identity */
    }

    body.light-theme .mobile-bottom-sheet {
        background-color: #ffffff;
        border-top: 1px solid #e0e0e0;
    }

    body.light-theme .mobile-nav-list {
        background-color: #f4f6f8;
        /* Light Grey */
    }

    body.light-theme .mobile-nav-list li a {
        background: #ffffff !important;
        /* Override gradient */
        color: #002244;
        /* Deep Blue Text */
        border: 1px solid #e0e0e0;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    body.light-theme .mobile-nav-list li a:active {
        background-color: #fffbeb;
        border-color: #ffd700;
    }

    body.light-theme .mobile-menu-footer {
        background-color: #ffffff;
        border-top: 1px solid #e0e0e0;
    }

    body.light-theme .social-icon {
        color: #002244;
        /* Blue in Light */
    }

    body.light-theme .menu-theme-toggle {
        background-color: #002244;
        /* Keep toggle dark for contrast? Or make it light? */
        /* Let's keep it consistent */
        color: #fff;
    }

    .menu-theme-toggle {
        display: flex;
        justify-content: space-between;
        align-items: center;
        background-color: #002244;
        color: #fff;
        padding: 12px 20px;
        border-radius: 12px;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }

    body.dark-theme .menu-theme-toggle {
        background-color: #ffd700;
        color: #002244;
    }

    .menu-theme-toggle span {
        font-weight: bold;
    }

    .theme-toggle-switch {
        background: transparent;
        border: none;
        font-size: 22px;
        cursor: pointer;
        padding: 0;
        line-height: 1;
    }

    /* Overlay */
    .mobile-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 34, 68, 0.6);
        /* Blue tint */
        z-index: 1500;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s;
        backdrop-filter: blur(4px);
    }

    .mobile-menu-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* تحسين الصور */
    img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* للشاشات الصغيرة جداً (أقل من 480px) */
@media only screen and (max-width: 480px) {

    .currency-table {
        font-size: 12px;
    }

    .currency-table th,
    .currency-table td {
        padding: 8px 3px;
    }

    .header-logo {
        max-width: 30px;
    }

    .chart-container {
        height: 200px;
    }

    .currency-selector {
        grid-template-columns: repeat(2, 1fr);
    }

    .currency-box {
        padding: 10px 5px;
        font-size: 12px;
    }
}