
/* ============================================================
   AppxSoft — Layout: header, sidebar, drawer, main, footer
   Logical properties only (RTL/LTR via [dir]).
   ============================================================ */

/* ---------- Header ---------- */
.appx-header {
    position: fixed;
    inset-block-start: 0;
    inset-inline: 0;
    z-index: 1030;
    height: var(--appx-header-h);
    background: var(--appx-surface);
    border-block-end: 1px solid var(--appx-border);
    box-shadow: var(--appx-shadow-xs);
}

.appx-header-inner {
    height: 100%;
    display: flex;
    align-items: center;
    gap: var(--appx-space-3);
    padding-inline: var(--appx-space-4);
}

.appx-logo {
    display: inline-flex;
    align-items: center;
    max-height: 42px;
    width: auto;
}

.appx-logo img {
    max-height: 42px;
    width: auto;
}

.appx-header-spacer {
    flex: 1;
}

/* Burger (mobile drawer / desktop collapse) */
.appx-burger {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: var(--appx-touch);
    height: var(--appx-touch);
    padding: 10px;
    border: 0;
    background: transparent;
    border-radius: var(--appx-radius-sm);
    cursor: pointer;
    flex-shrink: 0;
}

.appx-burger span {
    display: block;
    height: 2px;
    width: 100%;
    background: var(--appx-text);
    border-radius: 2px;
    transition: transform var(--appx-transition), opacity var(--appx-transition);
}

.appx-burger:hover {
    background: var(--appx-surface-alt);
}

/* ---------- Header actions (announcements + profile) ---------- */
.appx-header-actions {
    display: flex;
    align-items: center;
    gap: var(--appx-space-2);
    margin-inline-start: auto;
}

.appx-icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--appx-touch);
    height: var(--appx-touch);
    border: 0;
    background: transparent;
    color: var(--appx-text-muted);
    border-radius: var(--appx-radius-sm);
    font-size: 17px;
    cursor: pointer;
    text-decoration: none;
}

.appx-icon-btn:hover,
.appx-icon-btn:focus {
    background: var(--appx-surface-alt);
    color: var(--appx-text);
    text-decoration: none;
}

.appx-badge-dot {
    position: absolute;
    inset-block-start: 6px;
    inset-inline-end: 6px;
    min-width: 18px;
    height: 18px;
    padding-inline: 4px;
    border-radius: 999px;
    background: var(--appx-danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

/* Profile */
.appx-profile {
    position: relative;
}

.appx-profile-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    color: var(--appx-text);
    min-height: var(--appx-touch);
    text-decoration: none;
}

.appx-profile-toggle:hover,
.appx-profile-toggle:focus {
    background: var(--appx-surface-alt);
    border-color: var(--appx-border);
    text-decoration: none;
}

.appx-avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    object-fit: cover;
    background: var(--appx-primary-soft);
}

.appx-profile-name {
    font-weight: 600;
    font-size: var(--appx-text-sm);
    max-inline-size: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.appx-profile-caret {
    color: var(--appx-text-muted);
    font-size: 11px;
}
/* Profile dropdown (Bootstrap 3 dropdown markup kept) */
.appx-profile .dropdown-menu {
    /* Physical fallbacks first: Bootstrap 3 sets left:0/top:100% itself */
    right: 0;
    left: auto;
    top: calc(100% + 8px);
    inset-inline: auto;
    inset-inline-end: 0;
    inset-block-start: calc(100% + 8px);
    border: 1px solid var(--appx-border);
    border-radius: var(--appx-radius);
    box-shadow: var(--appx-shadow-sm);
    padding: 6px 0;
    min-inline-size: 240px;
    max-inline-size: calc(100vw - 24px);
}

/* Bootstrap 3 uses .divider (not .dropdown-divider) for separators.
   Theme markup uses .dropdown-divider for BS5-readiness — support both. */
.appx-profile .dropdown-menu > li > a,
.appx-profile .dropdown-menu .dropdown-section {
    padding: 10px 18px;
    color: var(--appx-text);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--appx-text-sm);
    overflow-wrap: anywhere;
}

.appx-profile .dropdown-menu > li > a:hover,
.appx-profile .dropdown-menu > li > a:focus {
    background: var(--appx-surface-alt);
    color: var(--appx-text);
}

.appx-profile .dropdown-menu > li > a i {
    width: 20px;
    text-align: center;
    color: var(--appx-text-muted);
}

.appx-profile .dropdown-menu > li > a span {
    flex: 1;
}

.appx-profile .logout-btn,
.appx-profile .logout-btn i {
    color: var(--appx-danger);
}

.appx-profile .dropdown-header {
    border-block-end: 1px solid var(--appx-border);
    padding: 12px 18px;
    margin-block-end: 4px;
}

.appx-profile .dropdown-header h4 {
    margin: 0;
    font-size: var(--appx-text-base);
    overflow-wrap: anywhere;
}

.appx-profile .dropdown-header p {
    margin: 0;
    color: var(--appx-text-muted);
    font-size: var(--appx-text-xs);
    overflow-wrap: anywhere;
}

.appx-profile .dropdown-divider,
.appx-profile .dropdown-menu .divider {
    height: 1px;
    margin: 6px 0;
    overflow: hidden;
    background: var(--appx-border);
}

.appx-profile .dropdown-submenu > .dropdown-menu {
    left: 100%;
    right: auto;
    top: -6px;
    inset-inline-start: 100%;
    inset-inline-end: auto;
    inset-block-start: -6px;
    margin: 0;
}

/* ---------- Shell / sidebar ---------- */
.appx-shell {
    min-height: 100vh;
    padding-block-start: var(--appx-header-h);
}
.appx-nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: var(--appx-touch);
    padding: 8px 12px;
    border-radius: var(--appx-radius-sm);
    color: var(--appx-text);
    font-weight: 600;
    font-size: var(--appx-text-base);
    text-decoration: none;
    white-space: nowrap;
    transition: background var(--appx-transition), color var(--appx-transition);
}

.appx-nav-link i {
    inline-size: 22px;
    text-align: center;
    font-size: 15px;
    color: var(--appx-text-muted);
    transition: color var(--appx-transition);
}

.appx-nav-link:hover,
.appx-nav-link:focus {
    background: var(--appx-surface-alt);
    color: var(--appx-text);
    text-decoration: none;
}

.appx-nav-link:hover i,
.appx-nav-link:focus i {
    color: var(--appx-primary);
}

.appx-nav-link.active {
    background: var(--appx-primary-soft);
    color: var(--appx-primary);
}

.appx-nav-link.active i {
    color: var(--appx-primary);
}

.appx-nav-link.active::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    inset-block-start: 50%;
    transform: translateY(-50%);
    inline-size: 3px;
    border-radius: 4px;
    height: 22px;
    background: var(--appx-primary);
}

.appx-nav-count {
    margin-inline-start: auto;
    background: var(--appx-danger);
    color: #fff;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    padding-inline: 4px;
}

/* Collapsed (desktop) — scoped to the persistent-sidebar layout only.
   On <992px the sidebar is a drawer (margin 0), so the collapsed margin
   must NOT leak into the drawer media query. */
@media (min-width: 992px) {
    body.appx-sidebar-collapsed .appx-sidebar {
        inline-size: var(--appx-sidebar-w-collapsed);
        width: var(--appx-sidebar-w-collapsed);
    }

    body.appx-sidebar-collapsed .appx-nav-group-title,
    body.appx-sidebar-collapsed .appx-nav-text {
        display: none;
    }

    body.appx-sidebar-collapsed .appx-nav-link {
        justify-content: center;
        padding: 8px;
    }

    body.appx-sidebar-collapsed .appx-main {
        margin-inline-start: var(--appx-sidebar-w-collapsed);
        margin-left: var(--appx-sidebar-w-collapsed);
    }

    [dir="rtl"] body.appx-sidebar-collapsed .appx-main,
    body.appx-sidebar-collapsed[dir="rtl"] .appx-main {
        margin-left: 0;
        margin-right: var(--appx-sidebar-w-collapsed);
    }
}

/* Tooltip on collapsed items */
.appx-collapsed-tip {
    position: absolute;
    left: calc(100% + 10px);
    inset-inline-start: calc(100% + 10px);
    inset-block-start: 50%;
    transform: translateY(-50%);
    background: var(--appx-text);
    color: #fff;
    font-size: var(--appx-text-xs);
    padding: 5px 10px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--appx-transition);
    z-index: 1100;
}

[dir="rtl"] .appx-collapsed-tip {
    left: auto;
    right: calc(100% + 10px);
}

body.appx-sidebar-collapsed .appx-nav-link:hover .appx-collapsed-tip {
    opacity: 1;
}


.appx-sidebar {
    position: fixed;
    top: var(--appx-header-h);
    bottom: 0;
    left: 0;
    right: auto;
    inset-block-start: var(--appx-header-h);
    inset-block-end: 0;
    inset-inline-start: 0;
    z-index: 1020;
    inline-size: var(--appx-sidebar-w);
    width: var(--appx-sidebar-w);
    max-inline-size: calc(100vw - 48px);
    background: var(--appx-surface);
    border-inline-end: 1px solid var(--appx-border);
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: inline-size var(--appx-transition), transform var(--appx-transition);
}

[dir="rtl"] .appx-sidebar {
    left: auto;
    right: 0;
}

.appx-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--appx-space-4) var(--appx-space-3);
}

.appx-nav {
    list-style: none;
    margin: 0;
    padding: 0;
}

.appx-nav-group-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--appx-text-muted);
    padding: 14px 10px 6px;
    white-space: nowrap;
}

.appx-nav-item {
    margin: 2px 0;
}

/* Sidebar footer (collapse button on desktop) */
.appx-sidebar-footer {
    padding: var(--appx-space-3);
    border-block-start: 1px solid var(--appx-border);
    display: flex;
    justify-content: flex-end;
}

.appx-collapse-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--appx-touch);
    height: var(--appx-touch);
    border: 1px solid var(--appx-border);
    background: var(--appx-surface);
    color: var(--appx-text-muted);
    border-radius: var(--appx-radius-sm);
    cursor: pointer;
}

.appx-collapse-btn:hover {
    background: var(--appx-surface-alt);
    color: var(--appx-text);
}

/* ---------- Main content ---------- */
.appx-main {
    margin-inline-start: var(--appx-sidebar-w);
    margin-left: var(--appx-sidebar-w);
    min-height: calc(100vh - var(--appx-header-h));
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin var(--appx-transition);
}

[dir="rtl"] .appx-main {
    margin-left: 0;
}

.appx-content {
    flex: 1;
    padding-block: var(--appx-space-5) var(--appx-space-8);
    inline-size: 100%;
    min-width: 0;
}

/* Long content safety: headings, titles and small meta text wrap
   instead of forcing overflow (emails, invoice numbers, Arabic
   sentences, long company names). Applied per-element — never a
   blanket rule on .appx-content, so buttons/CTAs keep their shape. */
.appx-page-title,
.appx-page-subtitle,
.appx-card-title,
.appx-stat-label,
.appx-stat-value,
.appx-stat-hint,
.panel_s .panel-heading,
.appx-empty-title,
.appx-empty-desc,
.alert,
.breadcrumb,
.dropdown-header h4,
.dropdown-header p {
    overflow-wrap: break-word;
    word-break: break-word;
}

.appx-page-title,
.appx-card-title,
.appx-stat-value {
    max-inline-size: 100%;
}

/* Long table cells: wrap but preserve grid readability */
.appx-content .table > tbody > tr > td,
.appx-content .table > thead > tr > th {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Pagination never overflows on 360px viewports */
.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-inline-start: 0;
}

.pagination > li {
    display: inline-flex;
}

/* Media + tables must never force horizontal page scroll */
.appx-content img,
.appx-content canvas,
.appx-content video,
.appx-card-body img {
    max-width: 100%;
    height: auto;
}

.appx-content .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.appx-content .table {
    min-width: 0;
}

.appx-card-body {
    min-width: 0;
}

/* Page header */
.appx-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--appx-space-3);
    margin-block-end: var(--appx-space-5);
}

.appx-page-title {
    font-size: var(--appx-text-2xl);
    font-weight: 700;
    margin: 0;
}

.appx-page-subtitle {
    color: var(--appx-text-muted);
    font-size: var(--appx-text-sm);
    margin: 2px 0 0;
}

/* Top submenu (Files / Calendar) */
.customer-top-submenu {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: var(--appx-space-2);
    padding: 0;
    margin: 0 0 var(--appx-space-5);
}

.customer-top-submenu > li > a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 6px 16px;
    border: 1px solid var(--appx-border);
    border-radius: 999px;
    background: var(--appx-surface);
    color: var(--appx-text);
    font-weight: 600;
    font-size: var(--appx-text-sm);
    text-decoration: none;
}

.customer-top-submenu > li > a:hover,
.customer-top-submenu > li > a:focus {
    border-color: var(--appx-primary);
    color: var(--appx-primary);
    text-decoration: none;
}

.customer-top-submenu svg {
    width: 18px;
    height: 18px;
    color: var(--appx-text-muted);
}

/* ---------- Auth / no-navigation pages ---------- */
.appx-noshell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-block: var(--appx-space-8) var(--appx-space-6);
}

.appx-noshell .container {
    max-inline-size: 520px;
}

.appx-noshell-brand {
    display: flex;
    justify-content: center;
    margin-block-end: var(--appx-space-5);
}

/* ---------- Footer ---------- */
.footer {
    background: transparent;
    border-block-start: 1px solid var(--appx-border);
    margin-block-start: var(--appx-space-6);
    padding: var(--appx-space-4) 0;
    color: var(--appx-text-muted);
    font-size: var(--appx-text-sm);
}

.footer a {
    color: var(--appx-text-muted);
}

.footer a:hover {
    color: var(--appx-primary);
}

/* ---------- Overlay (mobile drawer) ---------- */
.appx-overlay {
    position: fixed;
    inset: 0;
    z-index: 1015;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--appx-transition), visibility var(--appx-transition);
}

body.appx-drawer-open .appx-overlay {
    opacity: 1;
    visibility: visible;
}

/* ============================================================
   Responsive: desktop layout switches down to drawer < 992px
   ============================================================ */
@media (max-width: 991px) {
    .appx-sidebar {
        transform: translateX(-110%);
    }

    html[dir="rtl"] .appx-sidebar,
    [dir="rtl"] .appx-sidebar {
        transform: translateX(110%);
    }

    body.appx-drawer-open .appx-sidebar {
        transform: translateX(0);
        box-shadow: 0 10px 40px rgba(15, 23, 42, 0.18);
    }

    body.appx-drawer-open[dir="rtl"] .appx-sidebar {
        transform: translateX(0);
    }

    body.appx-sidebar-collapsed .appx-main,
    .appx-main {
        margin-inline-start: 0;
        margin-left: 0;
    }

    .appx-sidebar-footer,
    .appx-collapse-btn,
    .appx-collapsed-tip {
        display: none;
    }

    .appx-profile-name,
    .appx-profile-caret {
        display: none;
    }

    /* Profile dropdown must stay inside small viewports */
    .appx-profile .dropdown-menu {
        position: fixed;
        top: var(--appx-header-h);
        right: 8px;
        left: 8px;
        inset-inline: 8px;
        inset-block-start: var(--appx-header-h);
        min-inline-size: 0;
        max-inline-size: calc(100vw - 16px);
    }

    [dir="rtl"] .appx-profile .dropdown-menu {
        right: 8px;
        left: 8px;
    }
}

@media (min-width: 992px) {
    .appx-burger {
        display: none;
    }
}

