/**
 * responsive-screens.css - Masarat ERP Universal Display & TV Engine (Build 96)
 * Professional Adaptive Layout for 75" TVs, 4K Displays, Ultra-Wide, and Desktop Monitors.
 * Prevents stretching, overlapping, and text collisions across all system pages.
 */

/* ==========================================================================
   1. UNIVERSAL BASELINE & TV SAFETY
   ========================================================================== */
html {
    box-sizing: border-box;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

*, *::before, *::after {
    box-sizing: inherit;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

/* ==========================================================================
   2. TV & ULTRA-WIDE VIEWPORT CONTAINMENT (55" to 85" Screens, 2K & 4K)
   ========================================================================== */

/* للشاشات العريضة والشاشات الكبيرة من 1600 بكسل فما فوق */
@media (min-width: 1600px) {
    .main-wrapper {
        max-width: 1660px;
        margin-right: max(90px, calc((100vw - 1660px) / 2 + 30px)) !important;
        margin-left: auto !important;
        padding-left: 20px !important;
        padding-right: 20px !important;
    }

    .company-header {
        max-width: 100% !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .dashboard-container {
        max-width: 100% !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
}

/* لشاشات التلفزيون الضخمة 75 بوصة ودقات 4K (2100 بكسل إلى 3840 بكسل) */
@media (min-width: 2100px) {
    html {
        font-size: 17.5px; /* تكبير نسبي ذكي يتناسب مع مسافة الرؤية التلفزيونية */
    }

    .main-wrapper {
        max-width: 1980px;
        margin-right: max(100px, calc((100vw - 1980px) / 2 + 40px)) !important;
        margin-left: auto !important;
        padding-left: 30px !important;
        padding-right: 30px !important;
    }

    /* تكبير ناعم ومتناسق لأزرار وأيقونات الشريط الجانبي */
    .mini-sidebar {
        right: max(20px, calc((100vw - 1980px) / 2 - 70px)) !important;
    }
    .sidebar-icon {
        width: 62px !important;
        height: 62px !important;
    }
    .sidebar-icon i {
        width: 44px !important;
        height: 44px !important;
        font-size: 20px !important;
    }
}

/* ==========================================================================
   3. PREVENT OVERLAPPING IN UNIVERSAL HEADER (الترويسة الموحدة)
   ========================================================================== */
.company-header {
    min-height: auto !important;
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 16px !important;
}

.company-header > div {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .company-header {
        flex-direction: column !important;
        text-align: center !important;
        padding: 14px !important;
    }
    .company-header .d-flex {
        justify-content: center !important;
    }
}

/* ==========================================================================
   4. DASHBOARD APP GRID REFINEMENT FOR LARGE SCREENS (لوحة التحكم)
   ========================================================================== */
/* بطاقات لوحة التحكم: حماية أمان تمنع تراكب العناوين مع النصوص السفلية نهائياً */
.app-card {
    min-height: 235px !important;
    padding-bottom: 42px !important; /* مساحة أمان محجوزة للنصوص السفلية */
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: center !important;
}

.app-footer-text {
    position: absolute !important;
    bottom: 10px !important;
    pointer-events: none;
    z-index: 10;
}

/* تكبير وتجسيم الأيقونة عند التحويم أو النقر بحجم فخم وبارز أكبر بـ 60% بدون أي تصادم */
.app-card:hover .icon-scale-container,
.app-card:focus .icon-scale-container {
    transform: scale(2.15) translateY(-26px) !important;
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1) !important;
    z-index: 2000 !important;
}

.app-card:hover .app-icon,
.app-card:focus .app-icon {
    filter: drop-shadow(0 22px 32px rgba(0, 0, 0, 0.30)) drop-shadow(0 8px 16px rgba(2, 132, 199, 0.35)) !important;
    transition: filter 0.28s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

.app-card:hover .icon-overlay-title,
.app-card:focus .icon-overlay-title {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateX(-50%) translateY(0) scale(1) !important;
}

.app-card:active .icon-scale-container {
    transform: scale(2.0) translateY(-20px) !important;
    transition: transform 0.12s ease-out !important;
    z-index: 2000 !important;
}

.app-card:active .app-icon {
    filter: drop-shadow(0 26px 36px rgba(0,0,0,0.40)) drop-shadow(0 10px 20px rgba(2, 132, 199, 0.50)) !important;
}

.app-card:active .icon-overlay-title {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateX(-50%) translateY(0) scale(1) !important;
}

/* توزيع أعمدة لوحة التحكم على الشاشات الكبيرة لمنع التمدد المفرط والتشوه */
@media (min-width: 1400px) and (max-width: 1999px) {
    .dashboard-container .row.g-3.g-lg-4 > [class*="col-"] {
        flex: 0 0 20% !important;
        max-width: 20% !important; /* 5 بطاقات متناسقة في السطر بدلاً من 4 مفرطة الاتساع */
    }
}

@media (min-width: 2000px) {
    .dashboard-container .row.g-3.g-lg-4 > [class*="col-"] {
        flex: 0 0 16.666667% !important;
        max-width: 16.666667% !important; /* 6 بطاقات لشاشات 4K والتلفزيونات بمظهر تنفيذي فخم */
    }
}

/* ==========================================================================
   5. UNIVERSAL TABLES & CARD CONTAINERS (الجداول وبطاقات العمليات)
   ========================================================================== */
.table-responsive {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

.table th, .table td {
    vertical-align: middle !important;
}

/* منع تمدد الجداول لدرجة تشويه المسافات بين الأعمدة */
@media (min-width: 1800px) {
    .table:not(.table-condensed) th,
    .table:not(.table-condensed) td {
        padding-top: 14px !important;
        padding-bottom: 14px !important;
    }
}

/* حماية شريط التنقل العلوي وتصنيفات المسارات */
.track-nav-bar {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 8px !important;
}

/* ==========================================================================
   6. MASARAT MAIL CLIENT (MMC) RESPONSIVENESS
   ========================================================================== */
@media (min-width: 1800px) {
    .mail-app {
        max-width: 100vw;
    }
    .mail-topbar {
        padding-left: 24px !important;
        padding-right: 24px !important;
    }
    .contacts-table-pane {
        padding: 24px !important;
    }
}

/* ==========================================================================
   7. STANDALONE & TV FULLSCREEN ENHANCEMENTS
   ========================================================================== */
@media (display-mode: standalone), (display-mode: fullscreen) {
    body {
        user-select: auto;
    }
}
