/* ============================================
   تحسينات واجهة لوحات التحكم على الجوالات
   Mobile Dashboard Improvements - All Roles
   (Admin, Seller, Delivery)
   ============================================ */

/* ===== التحسينات الأساسية للجوالات ===== */
@media (max-width: 768px) {

    /* ----- Container الرئيسي ----- */
    .admin-dashboard-container {
        padding: 0;
        gap: 0;
        grid-template-columns: 1fr;
        display: flex;
        flex-direction: column;
    }

    /* ----- Sidebar - شريط التنقل ----- */
    .admin-sidebar {
        position: sticky;
        top: 70px;
        z-index: 100;
        margin: 0 8px 12px;
        padding: 8px;
        border-radius: 16px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
    }

    .sidebar-header {
        display: none;
    }

    .sidebar-menu {
        flex-direction: row !important;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 4px;
        gap: 6px;
        display: flex !important;

        /* Hide scrollbars - Cross-browser Support */
        -ms-overflow-style: none;
        /* IE and Edge */
        scrollbar-width: none;
        /* Firefox and Chrome 121+ */
    }

    /* Hide scrollbar for Chrome, Safari, Opera, and Samsung Internet */
    .sidebar-menu::-webkit-scrollbar {
        display: none;
    }

    .sidebar-item {
        flex: 0 0 auto;
        padding: 10px 14px;
        flex-direction: column;
        gap: 4px;
        font-size: 0.7rem;
        min-width: 75px;
        text-align: center;
        background: rgba(var(--primary-rgb, 255, 107, 53), 0.05);
        border-radius: 12px;
        white-space: nowrap;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .sidebar-item i {
        font-size: 1.1rem;
        margin: 0;
    }

    .sidebar-item.active {
        background: var(--primary-color);
        color: white;
        box-shadow: 0 3px 12px rgba(var(--primary-rgb, 255, 107, 53), 0.3);
    }

    .sidebar-item:hover {
        transform: translateY(-2px);
    }

    /* ----- Main Content ----- */
    .admin-main-content {
        gap: 15px;
        padding: 0 10px 20px;
        width: 100%;
    }

    /* ----- Header الصفحة ----- */
    .dashboard-page-header {
        padding: 25px 18px;
        border-radius: 18px;
        margin-bottom: 15px;
        text-align: center;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    }

    .dashboard-page-header::before {
        width: 300px;
        height: 300px;
    }

    .header-content h1 {
        font-size: 1.5rem;
        line-height: 1.3;
        margin-bottom: 8px;
    }

    .header-content p {
        font-size: 0.88rem;
        opacity: 0.95;
        line-height: 1.5;
        margin-bottom: 15px;
    }

    .header-actions {
        justify-content: center;
        margin-top: 15px;
        gap: 8px;
        flex-wrap: wrap;
        display: flex;
    }

    .header-actions .btn {
        padding: 11px 18px;
        font-size: 0.88rem;
        min-height: 42px;
        border-radius: 11px;
        flex: 1;
        min-width: 140px;
    }

    /* ----- بطاقات الإحصائيات - عمودي ----- */
    .admin-stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        margin-bottom: 15px;
        display: grid;
    }

    .admin-stat-card {
        padding: 16px 14px;
        flex-direction: row;
        align-items: center;
        text-align: right;
        border-radius: 16px;
        gap: 12px;
        box-shadow: 0 3px 12px rgba(0, 0, 0, 0.06);
        animation: slideInUp 0.3s ease-out;
        display: flex;
        position: relative;
        overflow: hidden;
    }

    @keyframes slideInUp {
        from {
            opacity: 0;
            transform: translateY(15px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .admin-stat-card:hover {
        transform: none;
        box-shadow: 0 3px 12px rgba(0, 0, 0, 0.06);
    }

    .stat-icon-box {
        width: 52px;
        height: 52px;
        font-size: 1.4rem;
        flex-shrink: 0;
        border-radius: 13px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .stat-info {
        flex: 1;
        text-align: right;
    }

    .stat-info h4 {
        font-size: 0.85rem;
        margin-bottom: 5px;
        font-weight: 600;
    }

    .stat-info .stat-value {
        font-size: 1.7rem;
        font-weight: 800;
        line-height: 1;
    }

    /* ----- بطاقات الإدارة - عمودي ----- */
    .management-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        display: grid;
    }

    .mgmt-card {
        padding: 18px 15px;
        border-radius: 16px;
        box-shadow: 0 3px 12px rgba(0, 0, 0, 0.06);
        animation: slideInUp 0.3s ease-out;
        animation-fill-mode: both;
        position: relative;
        overflow: hidden;
    }

    .mgmt-card:nth-child(1) {
        animation-delay: 0.05s;
    }

    .mgmt-card:nth-child(2) {
        animation-delay: 0.1s;
    }

    .mgmt-card:nth-child(3) {
        animation-delay: 0.15s;
    }

    .mgmt-card:nth-child(4) {
        animation-delay: 0.2s;
    }

    .mgmt-card:hover {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    }

    .mgmt-card-header {
        gap: 12px;
        margin-bottom: 12px;
        display: flex;
        align-items: center;
    }

    .mgmt-card-header i {
        font-size: 1.6rem;
        width: 42px;
        height: 42px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(var(--primary-rgb, 255, 107, 53), 0.1);
        border-radius: 11px;
        flex-shrink: 0;
    }

    .mgmt-card-header h3 {
        font-size: 1.12rem;
        font-weight: 700;
    }

    .mgmt-card p {
        font-size: 0.85rem;
        line-height: 1.5;
        color: var(--text-secondary);
        margin-bottom: 15px;
    }

    .mgmt-card .btn {
        width: 100%;
        min-height: 44px;
        font-size: 0.9rem;
        padding: 12px 18px;
        border-radius: 11px;
        font-weight: 600;
    }

    /* ----- تحسين الأزرار ----- */
    .mgmt-card .btn:active,
    .header-actions .btn:active {
        transform: scale(0.98);
    }

    /* ----- تحسين Glass Cards ----- */
    .glass-card {
        padding: 16px 14px;
        border-radius: 16px;
        margin-bottom: 12px;
    }

    .glass-card h3 {
        font-size: 1.08rem;
        margin-bottom: 12px;
        font-weight: 700;
    }

    .glass-card p {
        font-size: 0.85rem;
        line-height: 1.5;
    }

    /* Table styles moved to tables-mobile.css for consistency */


    /* ----- تحسين أزرار البحث ----- */
    .search-orders-container {
        display: flex;
        gap: 8px;
        align-items: center;
    }

    .search-orders-input {
        max-width: 200px;
        padding: 8px 12px;
        font-size: 0.85rem;
        border-radius: 10px;
    }

    /* ----- تحسين قسم الطلبات للبائع ----- */
    #sellerOrdersSection,
    #sellerMyProductsSection {
        margin-top: 15px;
    }

    #sellerOrdersSection h3,
    #sellerMyProductsSection h3 {
        font-size: 1.05rem;
    }

    /* ----- تحسين قسم الطلبات للمندوب ----- */
    #deliveryOrdersTableBody .btn {
        padding: 8px 14px;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    /* ----- تحسين زر الماسح العائم ----- */
    .fab-scanner {
        position: fixed;
        bottom: 20px;
        left: 20px;
        background: var(--primary-color);
        color: white;
        border: none;
        border-radius: 50px;
        padding: 12px 20px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 0.9rem;
        font-weight: 600;
        cursor: pointer;
        z-index: 1000;
        transition: all 0.3s ease;
    }

    .fab-scanner:active {
        transform: scale(0.95);
    }

    .fab-scanner i {
        font-size: 1.1rem;
    }
}

/* ===== تحسينات للشاشات الصغيرة جداً ===== */
@media (max-width: 480px) {
    .admin-sidebar {
        margin: 0 5px 10px;
        padding: 6px;
    }

    .sidebar-item {
        padding: 9px 12px;
        font-size: 0.65rem;
        min-width: 70px;
    }

    .sidebar-item i {
        font-size: 1rem;
    }

    .admin-main-content {
        padding: 0 8px 18px;
    }

    .dashboard-page-header {
        padding: 22px 15px;
        margin-bottom: 12px;
    }

    .header-content h1 {
        font-size: 1.35rem;
    }

    .header-content p {
        font-size: 0.82rem;
    }

    .header-actions .btn {
        padding: 10px 16px;
        font-size: 0.85rem;
        min-height: 40px;
        min-width: 130px;
    }

    .admin-stats-grid {
        gap: 9px;
    }

    .admin-stat-card {
        padding: 14px 12px;
        gap: 10px;
    }

    .stat-icon-box {
        width: 48px;
        height: 48px;
        font-size: 1.3rem;
    }

    .stat-info h4 {
        font-size: 0.82rem;
    }

    .stat-info .stat-value {
        font-size: 1.55rem;
    }

    .management-grid {
        gap: 10px;
    }

    .mgmt-card {
        padding: 16px 13px;
    }

    .mgmt-card-header i {
        font-size: 1.5rem;
        width: 40px;
        height: 40px;
    }

    .mgmt-card-header h3 {
        font-size: 1.05rem;
    }

    .mgmt-card p {
        font-size: 0.82rem;
    }

    .mgmt-card .btn {
        min-height: 42px;
        font-size: 0.88rem;
        padding: 11px 16px;
    }

    .glass-card {
        padding: 14px 12px;
    }

    .glass-card h3 {
        font-size: 1.02rem;
    }

    /* Table styles moved to tables-mobile.css */


    /* تحسين زر الماسح العائم */
    .fab-scanner {
        bottom: 15px;
        left: 15px;
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    .fab-scanner span {
        display: none;
    }

    .fab-scanner i {
        font-size: 1.2rem;
        margin: 0;
    }
}

/* ===== تحسينات للوضع الأفقي (Landscape) ===== */
@media (max-width: 768px) and (orientation: landscape) {
    .dashboard-page-header {
        padding: 18px 15px;
    }

    .header-content h1 {
        font-size: 1.3rem;
    }

    .header-content p {
        font-size: 0.8rem;
        margin-bottom: 10px;
    }

    .header-actions {
        margin-top: 10px;
    }

    .header-actions .btn {
        padding: 9px 15px;
        min-height: 38px;
    }

    .admin-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .admin-stat-card {
        padding: 12px 10px;
    }

    .stat-icon-box {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }

    .stat-info h4 {
        font-size: 0.75rem;
    }

    .stat-info .stat-value {
        font-size: 1.4rem;
    }

    .management-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .mgmt-card {
        padding: 14px 12px;
    }

    .mgmt-card-header h3 {
        font-size: 1rem;
    }

    .mgmt-card p {
        font-size: 0.78rem;
    }
}

/* ===== تحسينات للأجهزة باللمس ===== */
@media (hover: none) and (pointer: coarse) {

    .sidebar-item,
    .admin-stat-card,
    .mgmt-card .btn,
    .header-actions .btn,
    .fab-scanner {
        -webkit-tap-highlight-color: transparent;
    }

    .sidebar-item:active {
        transform: scale(0.95);
    }

    .mgmt-card .btn:active,
    .header-actions .btn:active {
        transform: scale(0.97);
        opacity: 0.9;
    }

    /* تحسين حجم أهداف اللمس */
    .sidebar-item {
        min-height: 44px;
    }

    .mgmt-table .btn {
        min-height: 36px;
        min-width: 60px;
    }
}

/* ===== تأثيرات بصرية إضافية ===== */
@media (max-width: 768px) {

    /* تأثير لمعان على البطاقات */
    .admin-stat-card::after,
    .mgmt-card::after {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg,
                transparent,
                rgba(255, 255, 255, 0.15),
                transparent);
        transition: left 0.5s;
        pointer-events: none;
    }

    .admin-stat-card:active::after,
    .mgmt-card:active::after {
        left: 100%;
    }

    /* تحسين الانتقالات */
    .admin-stat-card,
    .mgmt-card,
    .sidebar-item,
    .header-actions .btn,
    .fab-scanner {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* تحسين الظلال عند التفاعل */
    .admin-stat-card:active {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    .mgmt-card:active {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    /* تحسين تمرير الجداول */
    .mgmt-table-container::-webkit-scrollbar {
        height: 6px;
    }

    .mgmt-table-container::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.05);
        border-radius: 3px;
    }

    .mgmt-table-container::-webkit-scrollbar-thumb {
        background: var(--primary-color);
        border-radius: 3px;
    }
}

/* ===== تحسينات إضافية لصفحات محددة ===== */
@media (max-width: 768px) {

    /* تحسين صفحة الإعدادات */
    .settings-container {
        padding: 0;
    }

    .settings-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .settings-card {
        padding: 16px 14px;
        border-radius: 16px;
    }

    .settings-card-header {
        margin-bottom: 15px;
    }

    .settings-card-header h3 {
        font-size: 1.05rem;
    }

    .settings-form-group {
        margin-bottom: 15px;
    }

    .settings-input {
        padding: 12px 14px;
        font-size: 0.9rem;
    }

    .settings-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-top: 20px;
    }

    .settings-actions .btn {
        width: 100%;
        min-height: 44px;
    }

    /* تحسين قسم الصورة الشخصية */
    .profile-avatar-section {
        flex-direction: column;
        align-items: center;
        gap: 12px;
        margin-bottom: 20px;
    }

    .profile-avatar {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }

    .avatar-upload-btn {
        width: 100%;
        max-width: 200px;
    }

    /* تحسين صندوق المعلومات */
    .settings-info-box {
        padding: 12px;
        font-size: 0.82rem;
        border-radius: 10px;
    }

    /* تحسين مدخلات كلمة المرور */
    .password-input-wrapper {
        position: relative;
    }

    .password-toggle-btn {
        position: absolute;
        left: 10px;
        top: 50%;
        transform: translateY(-50%);
        background: none;
        border: none;
        color: var(--text-secondary);
        cursor: pointer;
        padding: 8px;
        font-size: 1rem;
    }

    .password-strength {
        margin-top: 8px;
    }

    .password-strength-bar {
        height: 4px;
        border-radius: 2px;
        transition: all 0.3s ease;
    }
}