/* STB Responsive Foundation - Header Icons + Sidebar Toggle Fix */

@media (max-width: 991.98px) {
    /* Keep the header compact without hiding useful controls */
    .stb-header-shell {
        position: relative !important;
        top: auto !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    .stb-header-inner {
        padding: .5rem .7rem !important;
    }

    .stb-header-row {
        align-items: center !important;
        justify-content: space-between !important;
        flex-wrap: nowrap !important;
        gap: .5rem !important;
    }

    .stb-header-row > * {
        min-width: 0;
    }

    .stb-header-actions {
        width: auto !important;
        max-width: calc(100vw - 82px);
        flex: 0 1 auto !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        flex-wrap: nowrap !important;
        gap: .45rem !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        padding-bottom: 0 !important;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .stb-header-actions::-webkit-scrollbar {
        display: none;
    }

    /* Restore controls that were hidden too aggressively */
    .stb-header-actions > *,
    .stb-header-actions details,
    .stb-header-actions .btn,
    .stb-header-actions .tw-dw-btn,
    .stb-header-actions a,
    .stb-header-actions button,
    .stb-header-actions .dropdown,
    .stb-header-actions .notifications-menu,
    .stb-header-actions .user-menu {
        display: inline-flex !important;
        align-items: center !important;
        flex: 0 0 auto !important;
        margin: 0 !important;
    }

    .small-view-button,
    .side-bar-collapse,
    .stb-header-actions summary,
    .stb-header-actions .btn,
    .stb-header-actions .btn-modal,
    .stb-header-actions .dropdown-toggle,
    .stb-header-actions a,
    .stb-header-actions button {
        min-width: 40px !important;
        min-height: 40px !important;
        padding: .5rem !important;
        border-radius: 12px !important;
    }

    /* Make icon controls compact while keeping icons visible */
    .stb-header-actions .btn,
    .stb-header-actions .tw-dw-btn,
    .stb-header-actions .dropdown-toggle,
    .stb-header-actions a,
    .stb-header-actions button,
    .stb-header-actions summary {
        white-space: nowrap;
    }

    .stb-header-actions .btn i,
    .stb-header-actions .btn svg,
    .stb-header-actions .tw-dw-btn i,
    .stb-header-actions .tw-dw-btn svg,
    .stb-header-actions a i,
    .stb-header-actions a svg,
    .stb-header-actions button i,
    .stb-header-actions button svg,
    .stb-header-actions summary i,
    .stb-header-actions summary svg {
        font-size: 1rem !important;
        width: 1rem;
        height: 1rem;
        flex: 0 0 auto;
    }

    /* If an element has both icon and text, keep it compact by trimming only long labels */
    .stb-header-actions .btn span:not(.badge):not(.label):not(.sr-only):not(.tw-sr-only),
    .stb-header-actions .tw-dw-btn span:not(.badge):not(.label):not(.sr-only):not(.tw-sr-only),
    .stb-header-actions a span:not(.badge):not(.label):not(.sr-only):not(.tw-sr-only),
    .stb-header-actions button span:not(.badge):not(.label):not(.sr-only):not(.tw-sr-only),
    .stb-header-actions summary span:not(.badge):not(.label):not(.sr-only):not(.tw-sr-only) {
        max-width: 0;
        overflow: hidden;
        display: inline-block;
    }

    /* Sidebar offcanvas behavior */
    .side-bar,
    .stb-sidebar {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        width: min(88vw, 320px) !important;
        max-width: 320px !important;
        transform: translateX(-104%) !important;
        transition: transform .28s ease, box-shadow .28s ease !important;
        z-index: 1050 !important;
        visibility: hidden;
        opacity: 1;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        box-shadow: 0 24px 54px rgba(15, 23, 42, 0.28) !important;
    }

    [dir="rtl"] .side-bar,
    [dir="rtl"] .stb-sidebar {
        left: auto !important;
        right: 0 !important;
        transform: translateX(104%) !important;
    }

    body.stb-sidebar-open .side-bar,
    body.stb-sidebar-open .stb-sidebar,
    .side-bar.small-view-side-active,
    .stb-sidebar.small-view-side-active {
        transform: translateX(0) !important;
        visibility: visible !important;
    }

    body.stb-sidebar-open {
        overflow: hidden !important;
        touch-action: none;
    }

    .stb-mobile-overlay {
        display: none;
        position: fixed !important;
        inset: 0 !important;
        background: rgba(15, 23, 42, 0.42) !important;
        z-index: 1040 !important;
    }

    body.stb-sidebar-open .stb-mobile-overlay {
        display: block !important;
    }

    .small-view-button {
        position: relative;
        z-index: 1061;
        display: inline-flex !important;
    }

    .content-wrapper,
    .right-side,
    .content,
    .container-fluid {
        padding-top: 0 !important;
    }
}

@media (max-width: 575.98px) {
    .stb-header-inner {
        padding: .45rem .6rem !important;
    }

    .stb-header-actions {
        max-width: calc(100vw - 74px);
        gap: .35rem !important;
    }

    .small-view-button,
    .stb-header-actions summary,
    .stb-header-actions .btn,
    .stb-header-actions .dropdown-toggle,
    .stb-header-actions a,
    .stb-header-actions button {
        min-width: 38px !important;
        min-height: 38px !important;
        padding: .45rem !important;
    }
}

/* Durrat City Pro V1.0.0 - Desktop navigation polish + full RTL/LTR alignment */
:root {
    --stb-sidebar-width: 272px;
    --stb-sidebar-bg: #ffffff;
    --stb-sidebar-border: #e6edf5;
    --stb-nav-text: #334155;
    --stb-nav-muted: #8a99ad;
    --stb-nav-active: #0b4cc8;
    --stb-nav-active-bg: #eef5ff;
    --stb-nav-hover-bg: #f7faff;
}

.stb-app-shell {
    min-height: 100vh;
    width: 100%;
    align-items: stretch;
}

.stb-sidebar {
    display: flex;
    flex-direction: column;
    width: var(--stb-sidebar-width) !important;
    min-width: var(--stb-sidebar-width) !important;
    max-width: var(--stb-sidebar-width) !important;
    background: var(--stb-sidebar-bg) !important;
    border-inline-end: 1px solid var(--stb-sidebar-border) !important;
    box-shadow: 8px 0 28px rgba(15, 23, 42, .035);
    position: relative;
    z-index: 30;
    color: var(--stb-nav-text);
    overflow: hidden;
}

[dir="rtl"] .stb-sidebar {
    border-inline-end: 1px solid var(--stb-sidebar-border) !important;
    box-shadow: -8px 0 28px rgba(15, 23, 42, .035);
}

.stb-sidebar-brand-wrap {
    position: relative;
    flex: 0 0 auto;
    padding: 14px 14px 10px;
    background: linear-gradient(145deg, #0a3fa9 0%, #0b4cc8 55%, #1463d8 100%);
}

.stb-sidebar-brand {
    min-height: 62px;
    width: 100%;
    display: flex !important;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 16px;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .13);
}

.stb-brand-mark {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: #fff;
    color: #0b4cc8;
    font-size: 18px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .11);
}

.stb-brand-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    text-align: start;
}

.stb-brand-copy strong {
    font-size: 16px;
    font-weight: 900;
    letter-spacing: -.2px;
    color: #fff;
    white-space: nowrap;
}

.stb-brand-copy small {
    margin-top: 4px;
    color: rgba(255, 255, 255, .73);
    font-size: 10.5px;
    font-weight: 600;
    white-space: nowrap;
}

.stb-sidebar-close {
    position: absolute;
    inset-block-start: 21px;
    inset-inline-end: 20px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: rgba(255,255,255,.14);
    color: #fff;
}

.stb-sidebar-context {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 14px 8px;
    padding: 11px 12px;
    border: 1px solid #e6edf5;
    border-radius: 14px;
    background: linear-gradient(180deg, #fbfdff 0%, #f5f9ff 100%);
}

.stb-context-icon {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    background: #eaf2ff;
    color: #0b4cc8;
}

.stb-context-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    text-align: start;
}

.stb-context-copy > span {
    color: #64748b;
    font-size: 10.5px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stb-context-copy > strong {
    margin-top: 2px;
    color: #13233b;
    font-size: 12.5px;
    font-weight: 900;
    line-height: 1.35;
}

.stb-context-copy > small {
    margin-top: 3px;
    color: #8491a3;
    font-size: 10px;
    line-height: 1.3;
}

.stb-sidebar-scroll {
    flex: 1 1 auto;
    min-height: 0;
    padding: 3px 10px 14px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #cfd9e7 transparent;
}

.stb-sidebar-scroll::-webkit-scrollbar { width: 5px; }
.stb-sidebar-scroll::-webkit-scrollbar-thumb { background: #cfd9e7; border-radius: 20px; }

.stb-menu-section-label {
    padding: 13px 11px 6px;
    color: #8a99ad;
    font-size: 10px;
    line-height: 1;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .9px;
    text-align: start;
}

[dir="rtl"] .stb-menu-section-label {
    letter-spacing: 0;
    font-size: 11px;
}

.stb-menu-list,
.stb-menu-list.sidebar-menu {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

.stb-menu-list > li {
    margin: 3px 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
}

.stb-menu-list > li > a {
    position: relative;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    min-height: 46px;
    padding: 6px 9px !important;
    border: 1px solid transparent !important;
    border-radius: 13px !important;
    color: var(--stb-nav-text) !important;
    background: transparent !important;
    text-decoration: none !important;
    transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
    text-align: start !important;
    font-size: 12.5px !important;
    font-weight: 700 !important;
    overflow: hidden;
}

.stb-menu-list > li > a:hover {
    background: var(--stb-nav-hover-bg) !important;
    border-color: #edf2f8 !important;
    color: #0b4cc8 !important;
    transform: translateY(-1px);
}

.stb-menu-list > li.active > a {
    background: var(--stb-nav-active-bg) !important;
    border-color: #d9e7ff !important;
    color: var(--stb-nav-active) !important;
    font-weight: 900 !important;
    box-shadow: inset 3px 0 0 #0b4cc8, 0 5px 16px rgba(11, 76, 200, .055);
}

[dir="rtl"] .stb-menu-list > li.active > a {
    box-shadow: inset -3px 0 0 #0b4cc8, 0 5px 16px rgba(11, 76, 200, .055);
}

.stb-nav-icon {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: #f1f5f9;
    color: #60748e;
    font-size: 13px;
    transition: inherit;
}

.stb-menu-list > li > a:hover .stb-nav-icon,
.stb-menu-list > li.active > a .stb-nav-icon {
    background: #dceaff;
    color: #0b4cc8;
}

.stb-nav-label {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.25;
}

.stb-nav-arrow {
    flex: 0 0 auto;
    color: #b2bece;
    font-size: 9px;
    opacity: .7;
}

[dir="rtl"] .stb-nav-arrow { transform: rotate(180deg); }

.stb-sidebar-footer {
    flex: 0 0 auto;
    min-height: 48px;
    margin: 0 12px 12px;
    padding: 9px 11px;
    display: flex;
    align-items: center;
    gap: 7px;
    border: 1px solid #edf1f6;
    border-radius: 12px;
    background: #f8fafc;
    color: #64748b;
    font-size: 10.5px;
    font-weight: 700;
}

.stb-sidebar-footer small { margin-inline-start: auto; color: #94a3b8; font-size: 9px; }
.stb-sidebar-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px #dcfce7; }

.stb-main-shell { min-width: 0; }

.stb-header-shell {
    min-height: 64px;
    box-shadow: 0 4px 20px rgba(6, 49, 120, .08);
}

.stb-header-inner { min-height: 64px; display: flex; align-items: center; }
.stb-header-row { width: 100%; }
.stb-header-clinic-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.12); }
.stb-header-date { gap: 7px; }
.stb-user-menu summary { list-style: none; }
.stb-user-menu summary::-webkit-details-marker { display: none; }
.stb-user-chevron { font-size: 8px; opacity: .65; }

[dir="rtl"] .stb-header-row,
[dir="rtl"] .stb-header-identity,
[dir="rtl"] .stb-header-actions,
[dir="rtl"] .stb-language-switch {
    direction: rtl;
}

[dir="rtl"] .stb-user-menu > ul {
    right: auto !important;
    left: 0 !important;
    text-align: right;
}

/* Patients directory: professional search bar and RTL-safe cards */
.clinicpro-patient-searchbar {
    display: flex;
    align-items: stretch;
    gap: 8px;
    flex: 1 1 620px;
    max-width: 820px;
}

.clinicpro-patient-searchbox {
    position: relative;
    min-width: 260px;
    flex: 1 1 auto;
}

.clinicpro-patient-searchbox > i {
    position: absolute;
    top: 50%;
    inset-inline-start: 14px;
    transform: translateY(-50%);
    color: #91a0b4;
    pointer-events: none;
}

.clinicpro-patient-searchbox .form-control {
    width: 100%;
    min-height: 42px;
    padding-inline-start: 40px !important;
    border-radius: 12px !important;
    border: 1px solid #d9e2ec !important;
    box-shadow: none !important;
}

.clinicpro-patient-searchbox .form-control:focus {
    border-color: #7cadff !important;
    box-shadow: 0 0 0 3px rgba(11,76,200,.09) !important;
}

.clinicpro-patient-searchbar .btn {
    min-height: 42px;
    border-radius: 12px !important;
    padding: 9px 16px !important;
    font-weight: 800;
}

.clinicpro-patient-search-hint {
    width: 100%;
    margin-top: 6px;
    color: rgba(255,255,255,.72);
    font-size: 11px;
    text-align: start;
}

.clinicpro-patient-card { text-align: start; }
.clinicpro-patient-card .top { align-items: flex-start; }
.clinicpro-patient-card .meta { text-align: start; }

@media (max-width: 1199.98px) and (min-width: 992px) {
    :root { --stb-sidebar-width: 248px; }
    .stb-brand-copy small { display: none; }
    .stb-context-copy > small { display: none; }
}

@media (max-width: 991.98px) {
    .stb-sidebar {
        min-width: 0 !important;
        max-width: 320px !important;
        border-inline-end: 0 !important;
    }
    .stb-sidebar-context { margin-top: 10px; }
    .stb-sidebar-scroll { padding-bottom: 24px; }
    .stb-header-shell { min-height: 56px; }
    .stb-header-inner { min-height: 56px; }
    .clinicpro-patient-searchbar { flex-basis: 100%; max-width: none; }
}

@media (max-width: 575.98px) {
    .clinicpro-patient-searchbar { flex-wrap: wrap; gap: 7px; }
    .clinicpro-patient-searchbox { min-width: 100%; flex-basis: 100%; }
    .clinicpro-patient-searchbar .btn { flex: 1 1 calc(50% - 4px); }
}

/* Durrat City Pro V1.0.0 — unified professional controls */
.stb-main-shell .btn:not(.btn-link),
.stb-main-shell .tw-dw-btn:not(.tw-dw-btn-ghost),
.stb-main-shell button[type="submit"]:not(.close):not(.btn-link),
.stb-main-shell a.btn:not(.btn-link) {
    min-height: 38px;
    padding: 8px 15px !important;
    border-radius: 10px !important;
    border-width: 1px !important;
    font-size: 12.5px !important;
    font-weight: 800 !important;
    line-height: 1.2 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    white-space: nowrap;
    text-decoration: none !important;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease !important;
    box-shadow: 0 3px 9px rgba(15, 23, 42, .055);
}

.stb-main-shell .btn:not(.btn-link):hover,
.stb-main-shell .tw-dw-btn:not(.tw-dw-btn-ghost):hover,
.stb-main-shell button[type="submit"]:not(.close):not(.btn-link):hover,
.stb-main-shell a.btn:not(.btn-link):hover {
    transform: translateY(-1px);
    box-shadow: 0 7px 16px rgba(15, 23, 42, .10);
}

.stb-main-shell .btn:focus,
.stb-main-shell .tw-dw-btn:focus,
.stb-main-shell button[type="submit"]:focus {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .14), 0 6px 15px rgba(15, 23, 42, .08) !important;
}

.stb-main-shell .btn-primary,
.stb-main-shell .tw-dw-btn-primary,
.stb-main-shell button.btn-primary[type="submit"] {
    color: #fff !important;
    background: linear-gradient(135deg, #0b4cc8 0%, #2563eb 100%) !important;
    border-color: #1554d1 !important;
}

.stb-main-shell .btn-success,
.stb-main-shell .tw-dw-btn-success {
    color: #fff !important;
    background: linear-gradient(135deg, #0f9f6e 0%, #22c55e 100%) !important;
    border-color: #159a68 !important;
}

.stb-main-shell .btn-danger,
.stb-main-shell .tw-dw-btn-error,
.stb-main-shell .tw-dw-btn-danger {
    color: #fff !important;
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%) !important;
    border-color: #dc2626 !important;
}

.stb-main-shell .btn-warning,
.stb-main-shell .tw-dw-btn-warning {
    color: #653a00 !important;
    background: linear-gradient(135deg, #fbbf24 0%, #fcd34d 100%) !important;
    border-color: #f2b31b !important;
}

.stb-main-shell .btn-info,
.stb-main-shell .tw-dw-btn-info {
    color: #fff !important;
    background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%) !important;
    border-color: #0284c7 !important;
}

.stb-main-shell .btn-default,
.stb-main-shell .tw-dw-btn-outline:not(.tw-dw-btn-primary):not(.tw-dw-btn-error):not(.tw-dw-btn-success):not(.tw-dw-btn-warning) {
    color: #334155 !important;
    background: #fff !important;
    border-color: #dbe4ee !important;
}

.stb-main-shell .btn-default:hover {
    color: #0b4cc8 !important;
    background: #f7faff !important;
    border-color: #bfd4f8 !important;
}

.stb-main-shell .btn-xs,
.stb-main-shell .tw-dw-btn-xs {
    min-height: 29px !important;
    padding: 5px 9px !important;
    border-radius: 8px !important;
    font-size: 10.5px !important;
    gap: 5px !important;
}

.stb-main-shell .btn-sm,
.stb-main-shell .tw-dw-btn-sm {
    min-height: 33px !important;
    padding: 6px 11px !important;
    border-radius: 9px !important;
    font-size: 11.5px !important;
}

/* Keep DataTables export controls compact but visually consistent. */
.stb-main-shell .dataTables_wrapper .dt-buttons .btn,
.stb-main-shell .dataTables_wrapper .dt-buttons .dt-button {
    min-height: 31px !important;
    padding: 5px 10px !important;
    margin: 2px !important;
    border-radius: 8px !important;
    border: 1px solid #dbe4ee !important;
    background: #fff !important;
    color: #334155 !important;
    box-shadow: none !important;
    font-size: 10.5px !important;
    font-weight: 750 !important;
}

.stb-main-shell .dataTables_wrapper .dt-buttons .btn:hover,
.stb-main-shell .dataTables_wrapper .dt-buttons .dt-button:hover {
    background: #eef5ff !important;
    border-color: #bfd4f8 !important;
    color: #0b4cc8 !important;
    transform: none !important;
}

/* Form controls: softer corners and clearer focus to match the new buttons. */
.stb-main-shell .form-control,
.stb-main-shell .select2-container .select2-selection--single,
.stb-main-shell .select2-container .select2-selection--multiple {
    border-radius: 10px !important;
    border-color: #d9e2ec !important;
    box-shadow: none !important;
}

.stb-main-shell .form-control:focus,
.stb-main-shell .select2-container--focus .select2-selection,
.stb-main-shell .select2-container--open .select2-selection {
    border-color: #78a8f5 !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .09) !important;
}

/* Prevent visually awkward full-width action buttons unless the page explicitly asks for them. */
.stb-main-shell .box-footer .btn,
.stb-main-shell .modal-footer .btn {
    margin-inline: 3px;
}

[dir="rtl"] .stb-main-shell .btn i,
[dir="rtl"] .stb-main-shell .tw-dw-btn i {
    margin-left: 0 !important;
    margin-right: 0 !important;
}
