/* توحيد ارتفاع جميع الحقول في order-form-row */

.order-form-row input[type="text"],
.order-form-row select {
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    box-sizing: border-box;
}


/* تثبيت رأس الجدول للعملاء */

.table-container {
    max-width: 100vw;
    height: 70vh;
    overflow: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
    margin: 2rem auto;
    position: relative;
}

.scroll-x table {
    border-collapse: collapse;
    width: max-content;
    min-width: 100%;
}

.scroll-x thead th {
    position: sticky;
    top: 0;
    background: #2d3e50;
    color: #fff;
    z-index: 999;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    font-weight: 600;
    text-align: center;
    border-bottom: 2px solid #ffb347;
    border-right: 1px solid #e0e0e0;
    border-left: 1px solid #e0e0e0;
    height: 48px;
    min-width: 120px;
    vertical-align: middle;
    background-clip: padding-box;
    width: 120px;
}

.scroll-x thead {
    display: table-header-group;
}

.scroll-x {
    overflow-x: auto;
    max-width: 100vw;
}

th.sortable {
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: background 0.2s;
}

th.sortable:hover {
    background: #415a77;
}

.sort-arrow {
    font-size: 0.9em;
    margin-right: 2px;
    color: #ffb347;
    vertical-align: middle;
}

body {
    font-family: 'Cairo', Arial, sans-serif;
    background: #f4f6fa;
    margin: 0;
}

.navbar {
    background: #2d3e50;
    color: #fff;
    padding: 0.5rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100vw;
    box-sizing: border-box;
    position: relative;
    min-height: 60px;
}

.navbar h1 {
    margin: 0;
    font-size: 1.5rem;
    flex: 1 1 auto;
    text-align: left;
    direction: ltr;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 2rem;
    margin: 0;
    padding: 0;
    flex: 0 0 auto;
    direction: rtl;
}

.nav-links li {
    display: inline-block;
}

.nav-links a {
    color: #fff;
    text-decoration: none;
    font-size: 1.1rem;
    transition: color 0.2s;
    padding: 0.2rem 0.7rem;
    border-radius: 4px;
}

.nav-links a.active,
.nav-links a:focus {
    background: #ffb347;
    color: #2d3e50;
}

.nav-links a:hover {
    color: #ffb347;
}


/* Small icon before nav text for clarity */

.nav-icon {
    display: inline-block;
    width: 20px;
    text-align: center;
    margin-inline-start: 0.5rem;
    vertical-align: middle;
    font-size: 1.05rem;
}


/* Dropdown submenu styles */

.nav-links li {
    position: relative;
}

.nav-links .submenu,
.nav-links .subsubmenu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: #2d3e50;
    padding: 0.5rem 0;
    border-radius: 6px;
    min-width: 160px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
    z-index: 2000;
}

.nav-links .submenu li,
.nav-links .subsubmenu li {
    display: block;
    padding: 0;
}

.nav-links .submenu a,
.nav-links .subsubmenu a {
    display: block;
    padding: 0.5rem 1rem;
    color: #fff;
    white-space: nowrap;
}

.nav-links .submenu a:hover,
.nav-links .subsubmenu a:hover {
    background: #ffb347;
    color: #2d3e50;
}

.nav-links li.open>.submenu {
    display: block !important;
}

.nav-links li.open>.submenu li.open>.subsubmenu {
    display: block;
}

.nav-links li.bot-data.open>.submenu {
    display: block !important;
    visibility: visible !important;
}

.nav-links li.bot-data.open>a {
    background: #ffb347 !important;
    color: #2d3e50 !important;
}

.nav-links li.bot-data:not(.open)>a {
    background: transparent !important;
    color: #fff !important;
}

.nav-links li.bot-data:not(.open)>a:focus {
    background: transparent !important;
    color: #fff !important;
}


/* Global logo styles */

.app-logo {
    height: 44px;
    width: auto;
    display: inline-block;
    vertical-align: middle;
}

.report-header .report-logo {
    height: 64px;
    width: auto;
    position: absolute;
    left: 24px;
    top: 12px;
}


/* Print styles for PDFs */

@media print {
    .report-header .report-logo {
        display: none !important;
    }
    .controls-section,
    .back-button,
    #testApiBtn,
    .export-btn,
    #downloadPdfBtn {
        display: none !important;
    }
    .report-table th {
        position: static !important;
    }
    table {
        page-break-inside: auto;
    }
    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
    thead {
        display: table-header-group;
    }
    tfoot {
        display: table-footer-group;
    }
}


/* Mobile responsive */

@media (max-width: 768px) {
    .navbar {
        padding: 0.5rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    .nav-links {
        flex-direction: column;
        width: 100%;
        gap: 0.3rem;
    }
    .nav-links li {
        width: 100%;
        text-align: center;
    }
    .nav-links a {
        display: block;
        padding: 0.7rem 0.8rem;
        border-radius: 4px;
        background: rgba(255, 255, 255, 0.1);
    }
    .table-container {
        height: auto;
        max-height: 60vh;
        margin: 1rem 0.5rem;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }
    .scroll-x table {
        min-width: 800px;
        font-size: 0.85rem;
    }
    .scroll-x thead th {
        min-width: 100px;
        padding: 0.6rem 0.4rem;
        font-size: 0.8rem;
    }
    .scroll-x tbody td {
        padding: 0.6rem 0.4rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .navbar {
        padding: 0.3rem;
    }
    .nav-links a {
        padding: 0.6rem 0.5rem;
        font-size: 0.85rem;
    }
    .table-container {
        max-height: 50vh;
        margin: 0.5rem 0.2rem;
    }
    .scroll-x table {
        font-size: 0.75rem;
        min-width: 600px;
    }
    .scroll-x thead th {
        padding: 0.4rem 0.2rem;
        font-size: 0.7rem;
        min-width: 70px;
    }
    .scroll-x tbody td {
        padding: 0.4rem 0.2rem;
        font-size: 0.7rem;
    }
}


/* Modal overlay styles - ensure modals are fixed, centered and above the navbar */

.modal {
    display: none;
    /* hidden by default, toggled by JS */
    position: fixed;
    inset: 0;
    /* top:0; right:0; bottom:0; left:0 */
    background: rgba(0, 0, 0, 0.45);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    box-sizing: border-box;
}

.modal.open,
.modal[aria-hidden="false"] {
    display: flex;
}

.modal .modal-content {
    background: #fff;
    border-radius: 8px;
    width: 100%;
    max-width: 1100px;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
    position: relative;
    padding: 1rem 1.25rem;
}


/* Action button small styles for tables */

.action-btn {
    border: none;
    background: transparent;
    padding: 6px;
    margin: 0 2px;
    cursor: pointer;
    font-size: 1rem;
    border-radius: 6px;
    transition: background 0.15s, transform 0.08s;
}

.action-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

.action-btn:active {
    transform: translateY(0);
}


/* Modal form improvements */

.modal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
    margin-bottom: 0.75rem;
}

.modal .modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 0.5rem;
    border-top: 1px solid #eee;
    margin-top: 0.75rem;
}

.modal .form-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 0.6rem;
}

.modal .form-row label {
    min-width: 130px;
    font-weight: 600;
    color: #333;
}

.modal .modal-content input[type="text"],
.modal .modal-content select,
.modal .modal-content textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
}


/* ensure close button stays visible */

.modal .close {
    position: absolute;
    top: 0.5rem;
    left: 0.75rem;
    /* left because layout is RTL in this project */
    background: transparent;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}


/* small helper: when modal open, prevent body scrolling on some browsers */

body.modal-open {
    overflow: hidden;
}