/**
 * Mobile Responsive Overrides for Snono Cloud
 * هذا الملف يضيف تحسينات للموبايل بدون تعديل الكود الأصلي
 * Created: 2026-01-28
 */

/* ===== Base Mobile Fixes ===== */
@media screen and (max-width: 768px) {

    /* Fix container padding */
    .container,
    .container-fluid {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    /* Tables - Horizontal scroll */
    .table-responsive,
    table {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
    }

    /* Fix font sizes */
    h1,
    .h1 {
        font-size: 1.75rem !important;
    }

    h2,
    .h2 {
        font-size: 1.5rem !important;
    }

    h3,
    .h3 {
        font-size: 1.25rem !important;
    }

    /* Cards */
    .card {
        margin-bottom: 1rem !important;
    }

    /* Forms */
    .form-control,
    .form-select,
    input,
    select,
    textarea {
        font-size: 16px !important;
        /* Prevents iOS zoom on focus */
        padding: 12px !important;
    }

    /* Buttons */
    .btn {
        padding: 12px 20px !important;
        font-size: 1rem !important;
        width: 100% !important;
        margin-bottom: 10px !important;
    }

    .btn-group .btn {
        width: auto !important;
    }

    /* Row stacking */
    .row>[class*="col-"] {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        margin-bottom: 1rem !important;
    }

    /* Sidebar/Navigation */
    .sidebar,
    .nav-sidebar {
        position: fixed !important;
        top: 0 !important;
        left: -100% !important;
        width: 80% !important;
        max-width: 300px !important;
        height: 100vh !important;
        z-index: 1050 !important;
        transition: left 0.3s ease !important;
        background: #fff !important;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2) !important;
    }

    .sidebar.open,
    .nav-sidebar.open {
        left: 0 !important;
    }

    /* Main content */
    .main-content,
    .content,
    main {
        margin-left: 0 !important;
        padding: 15px !important;
    }

    /* Modals */
    .modal-dialog {
        margin: 10px !important;
        max-width: calc(100% - 20px) !important;
    }

    .modal-content {
        border-radius: 10px !important;
    }

    /* Dropdowns */
    .dropdown-menu {
        width: 100% !important;
        max-height: 300px !important;
        overflow-y: auto !important;
    }

    /* Hide non-essential elements */
    .d-mobile-none,
    .hide-on-mobile {
        display: none !important;
    }

    /* Show mobile elements */
    .d-mobile-block {
        display: block !important;
    }

    /* Fix images */
    img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Pagination */
    .pagination {
        flex-wrap: wrap !important;
        justify-content: center !important;
    }

    .pagination .page-item {
        margin: 2px !important;
    }
}

/* ===== Small Mobile (under 576px) ===== */
@media screen and (max-width: 576px) {
    body {
        font-size: 14px !important;
    }

    .container {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    h1,
    .h1 {
        font-size: 1.5rem !important;
    }

    h2,
    .h2 {
        font-size: 1.25rem !important;
    }

    /* Table cells */
    td,
    th {
        padding: 8px 5px !important;
        font-size: 12px !important;
    }

    /* Buttons - Stack vertically */
    .btn-group {
        flex-direction: column !important;
        width: 100% !important;
    }

    .btn-group .btn {
        width: 100% !important;
        border-radius: 5px !important;
        margin-bottom: 5px !important;
    }

    /* Card body padding */
    .card-body {
        padding: 15px !important;
    }

    /* Alert sizing */
    .alert {
        padding: 10px 15px !important;
        font-size: 14px !important;
    }
}

/* ===== Landscape Orientation Fix ===== */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .modal-dialog {
        max-height: 90vh !important;
        overflow-y: auto !important;
    }
}

/* ===== Touch Improvements ===== */
@media (hover: none) and (pointer: coarse) {

    /* Bigger touch targets */
    .btn,
    .nav-link,
    .dropdown-item,
    a {
        min-height: 44px !important;
        display: inline-flex !important;
        align-items: center !important;
    }

    /* Remove hover effects */
    .btn:hover,
    .nav-link:hover {
        transform: none !important;
    }

    /* Active states */
    .btn:active {
        transform: scale(0.98) !important;
    }
}

/* ===== RTL Mobile Fixes ===== */
[dir="rtl"] .sidebar,
[dir="rtl"] .nav-sidebar {
    left: auto !important;
    right: -100% !important;
}

[dir="rtl"] .sidebar.open,
[dir="rtl"] .nav-sidebar.open {
    right: 0 !important;
    left: auto !important;
}

/* ===== Mobile Menu Toggle Button ===== */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    z-index: 1051;
    cursor: pointer;
    font-size: 24px;
}

[dir="rtl"] .mobile-menu-toggle {
    right: auto;
    left: 20px;
}

@media screen and (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
}

/* ===== Overlay for mobile menu ===== */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1049;
}

.mobile-overlay.active {
    display: block;
}

/* ===== Scroll fixes ===== */
@media screen and (max-width: 768px) {

    html,
    body {
        overflow-x: hidden !important;
    }

    .no-scroll {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
    }
}

/* ===== Print - Hide mobile elements ===== */
@media print {

    .mobile-menu-toggle,
    .mobile-overlay {
        display: none !important;
    }
}