/**
 * طبقة استجابة عامة — موبايل / آيباد
 * لا تعيد تصميم الصفحات؛ تضبط الهياكل المشتركة بأمان.
 */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
}

img,
svg,
video {
    max-width: 100%;
    height: auto;
}

/* ——— أشرطة علوية مشتركة ——— */
@media screen and (max-width: 900px) {
    .top-bar,
    header .header-content,
    .header-content {
        flex-wrap: wrap !important;
        gap: 8px !important;
        row-gap: 8px !important;
    }

    .top-bar h1,
    .top-bar .btn,
    header h1 {
        font-size: 0.92rem !important;
    }

    .page,
    .container,
    .main-container,
    .content-wrap {
        padding-left: 10px !important;
        padding-right: 10px !important;
        max-width: 100% !important;
    }

    .filters,
    .filter-tabs,
    .toolbar {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .btn,
    .filter-btn,
    button.btn {
        min-height: 36px;
    }
}

/* ——— جداول: تمرير أفقي أنيق ——— */
@media screen and (max-width: 900px) {
    .table-wrap,
    .tbl-wrap,
    .sal-table-wrap,
    .proj-table-wrap,
    .data-table-wrap,
    .table-responsive {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
    }

    table {
        min-width: 560px;
    }

    th, td {
        white-space: nowrap;
    }

    th {
        font-size: 0.75rem !important;
        padding: 8px 8px !important;
    }

    td {
        font-size: 0.78rem !important;
        padding: 8px 8px !important;
    }
}

/* ——— نوافذ منبثقة ——— */
@media screen and (max-width: 900px) {
    .modal-window,
    .modal-box,
    .sal-modal-box,
    .emp-wa-box,
    .wa-modal-box,
    .reject-box,
    .proj-modal,
    [class*="modal-box"],
    [class*="modal-window"] {
        width: min(96vw, 560px) !important;
        max-width: 96vw !important;
        max-height: 90vh !important;
        margin: 10px auto !important;
    }

    .modal-bg,
    .modal,
    [id$="-modal"],
    [id$="Modal"] {
        padding: 10px !important;
        align-items: flex-start !important;
    }
}

/* ——— نماذج وحقول ——— */
@media screen and (max-width: 900px) {
    input[type="text"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="email"],
    input[type="tel"],
    input[type="search"],
    select,
    textarea {
        max-width: 100% !important;
        font-size: 16px !important; /* يمنع زوم iOS */
    }

    .form-grid,
    .data-grid,
    .fields-grid,
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr !important;
    }
}

/* ——— بطاقات / مجموعات أزرار ——— */
@media screen and (max-width: 900px) {
    .flex-btn-group,
    .btn-row,
    .btn-group {
        flex-wrap: wrap !important;
        width: 100% !important;
    }

    .flex-btn-group > .btn,
    .btn-full-mobile {
        flex: 1 1 100% !important;
        min-width: 0 !important;
        justify-content: center !important;
    }
}

/* ——— تسجيل الدخول ——— */
@media screen and (max-width: 520px) {
    .login-card,
    .login-box,
    .auth-card {
        width: min(94vw, 400px) !important;
        max-width: 94vw !important;
        margin: 16px auto !important;
        padding: 20px 16px !important;
        box-sizing: border-box !important;
    }
}

/* ——— لوحة الموظف ——— */
@media screen and (max-width: 800px) {
    .emp-grid {
        grid-template-columns: 1fr !important;
    }

    .emp-tile {
        min-height: 72px !important;
    }
}

/* ——— صفحات الطلبات / العقود المعلقة ——— */
@media screen and (max-width: 700px) {
    .emp-wa-box {
        max-width: 96vw !important;
    }

    .emp-wa-preview {
        min-height: 160px !important;
        font-size: 0.9rem !important;
    }
}

/* ——— آيباد أفقياً / عمودياً ——— */
@media screen and (max-width: 1100px) and (min-width: 701px) {
    .page {
        max-width: 100% !important;
        padding-left: 14px !important;
        padding-right: 14px !important;
    }

    .form-grid,
    .data-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

/* ——— Projects ——— */
@media screen and (max-width: 960px) {
    .proj-nav,
    .proj-topnav,
    nav.proj-nav {
        flex-wrap: wrap !important;
        gap: 6px !important;
    }

    .proj-layout,
    .proj-edit-layout {
        display: block !important;
    }

    .proj-sidebar {
        width: 100% !important;
        margin-bottom: 12px !important;
    }
}

/* ——— أمان عام ضد العرض الأفقي المكسور ——— */
@media screen and (max-width: 900px) {
    html, body {
        max-width: 100%;
        overflow-x: hidden;
    }

    .table-wrap,
    .tbl-wrap,
    .sal-table-wrap,
    .proj-table-wrap,
    .data-table-wrap,
    .table-responsive {
        max-width: 100% !important;
    }
}
