/* Shared surface shape, depth and comfortable content spacing. */
.app-shell,
.auth-shell {
    --oxi-glass-radius: 22px;
    --oxi-glass-widget-radius: 18px;
    --oxi-glass-control-radius: 12px;
    --oxi-glass-edge: rgba(255, 255, 255, .85);
    --oxi-glass-lower-edge: rgba(0, 0, 0, .04);
    --oxi-glass-shadow: 0 2px 4px rgba(0, 0, 0, .035), 0 12px 28px rgba(0, 0, 0, .075);
    --oxi-glass-small-shadow: 0 3px 8px rgba(0, 0, 0, .06);
}

html[data-theme="dark"] .app-shell {
    --oxi-glass-edge: rgba(255, 255, 255, .15);
    --oxi-glass-lower-edge: rgba(0, 0, 0, .22);
    --oxi-glass-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 14px 30px rgba(0, 0, 0, .22);
    --oxi-glass-small-shadow: 0 3px 8px rgba(0, 0, 0, .18);
}

/* Neutral inset highlights create the beveled edge without recoloring a surface. */
.app-shell :is(.card, .surface-card, .hero-panel, .dashboard-panel, .dashboard-welcome,
    .settings-form-card, .settings-backup-card, .settings-audit-card,
    .clinical-workspace-hero, .guidance-hero, .pharmacy-hero, .modal-content),
.auth-shell .auth-card {
    border-radius: var(--oxi-glass-radius) !important;
    box-shadow:
        inset 0 1px 0 var(--oxi-glass-edge),
        inset 0 -1px 0 var(--oxi-glass-lower-edge),
        var(--oxi-glass-shadow) !important;
}

.app-shell :is(.dashboard-metric, .dashboard-operations, .metric-card, .alert-card,
    .timeline-card, .clinical-alert, .clinical-form-panel, .patient-action-card,
    .care-plan-card, .clinical-history-card, .clinical-summary-grid article) {
    border-radius: var(--oxi-glass-widget-radius);
    box-shadow:
        inset 0 1px 0 var(--oxi-glass-edge),
        inset 0 -1px 0 var(--oxi-glass-lower-edge),
        var(--oxi-glass-shadow);
}

/* Colored banners keep their existing gradients; only the rim catches the light. */
.app-shell :is(.dashboard-welcome, .clinical-workspace-hero, .guidance-hero, .pharmacy-hero) {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .3),
        inset 0 0 0 1px rgba(255, 255, 255, .12),
        var(--oxi-glass-shadow) !important;
}

.app-shell .app-sidebar {
    border-radius: 0 var(--oxi-glass-radius) var(--oxi-glass-radius) 0;
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, .2), 6px 0 22px rgba(0, 0, 0, .1);
}

.app-shell .topbar {
    border-radius: 0 0 var(--oxi-glass-widget-radius) var(--oxi-glass-widget-radius);
    box-shadow: inset 0 -1px 0 var(--oxi-glass-edge), 0 4px 16px rgba(0, 0, 0, .035);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
}

.app-shell .topbar > .d-flex:first-child > div {
    min-width: 0;
}

.app-shell .topbar-icon {
    flex-shrink: 0;
}

.app-shell .sidebar-link {
    border-radius: var(--oxi-glass-control-radius);
}

.app-shell .sidebar-link.active,
.app-shell .sidebar-footer {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 4px 10px rgba(0, 0, 0, .06);
}

.app-shell .sidebar-portal-link {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    margin-top: .9rem;
    padding: .8rem .85rem;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: var(--oxi-glass-control-radius);
    background: rgba(255, 255, 255, .1);
    color: #fff;
    font-size: .75rem;
    font-weight: 700;
    line-height: 1.5;
    text-decoration: none;
}

.app-shell .sidebar-portal-link > i {
    flex: 0 0 auto;
    color: #8addf3;
}

.app-shell .sidebar-portal-link > span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.app-shell .sidebar-portal-link:hover {
    background: rgba(255, 255, 255, .18);
    border-color: rgba(255, 255, 255, .4);
}

.app-shell .sidebar-portal-link:focus-visible {
    outline-color: #8addf3;
}

.app-shell :is(.user-pill, .sidebar-footer, .table-responsive, .clinical-accordion) {
    border-radius: var(--oxi-glass-widget-radius);
}

.app-shell .btn:not(.rounded-circle):not(.input-group > *):not(.btn-group > *),
.app-shell .dashboard-primary-action,
.app-shell .oxi-assistant-fab,
.auth-shell .auth-submit {
    border-radius: var(--oxi-glass-control-radius) !important;
}

.app-shell .btn:not(:disabled):not(.disabled):not(:focus-visible),
.app-shell .dashboard-primary-action,
.auth-shell .auth-submit:not(:focus-visible) {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .24), var(--oxi-glass-small-shadow);
}

.app-shell :is(.dashboard-metric-icon, .metric-icon, .dashboard-empty-icon, .clinical-alert-icon) {
    border-radius: 14px;
    box-shadow: inset 0 1px 0 var(--oxi-glass-edge), 0 2px 4px rgba(0, 0, 0, .025);
}

.app-shell :is(.form-control, .form-select):not(:focus) {
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, .035);
}

/* Keep Bootstrap's joined input groups and keyboard focus treatment intact. */
.app-shell :is(.form-control, .form-select):not(.input-group > *) {
    border-radius: var(--oxi-glass-control-radius);
}

.app-shell .dashboard-alert {
    border-radius: 0 var(--oxi-glass-control-radius) var(--oxi-glass-control-radius) 0;
}

.app-shell :is(.card-header, .settings-form-topbar) {
    border-top-left-radius: var(--oxi-glass-radius);
    border-top-right-radius: var(--oxi-glass-radius);
}

/* The controls belong to the panel; only its records scroll horizontally. */
.app-shell .oxi-table-panel {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--oxi-border);
    border-radius: var(--oxi-glass-widget-radius);
    background: var(--oxi-surface);
}

.app-shell .oxi-table-panel .dataTables_wrapper {
    min-width: 0;
}

.app-shell :is(.oxi-table-toolbar, .oxi-table-footer) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem 1.25rem;
}

.app-shell .oxi-table-toolbar {
    border-bottom: 1px solid var(--oxi-border);
    background: var(--oxi-surface);
}

.app-shell .oxi-table-footer {
    border-top: 1px solid var(--oxi-border);
    background: var(--oxi-surface);
}

.app-shell .oxi-table-scroll {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
}

.app-shell .oxi-table-scroll:focus-visible {
    outline-offset: -3px;
}

.app-shell .dataTables_wrapper :is(.dataTables_length, .dataTables_filter, .dataTables_info, .dataTables_paginate) {
    margin: 0;
    padding: 0;
    float: none;
    color: var(--oxi-muted);
    font-size: .8rem;
    line-height: 1.5;
}

.app-shell .dataTables_wrapper :is(.dataTables_length, .dataTables_filter) label {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin: 0;
    text-align: left;
    white-space: normal;
}

.app-shell .dataTables_wrapper .dataTables_filter input {
    width: clamp(150px, 16vw, 240px);
    max-width: 100%;
    margin: 0;
    padding: .6rem .85rem;
    font-size: .82rem;
}

.app-shell .dataTables_wrapper .dataTables_length select {
    width: 78px;
    margin: 0;
    padding-left: .8rem;
    font-size: .82rem;
}

.app-shell .oxi-table-footer .pagination {
    flex-wrap: wrap;
    gap: .35rem;
    margin: 0;
}

.app-shell .oxi-table-footer .page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    min-height: 38px;
    margin: 0;
    padding: .45rem .75rem;
    border: 1px solid var(--oxi-border);
    border-radius: 10px;
    background: var(--oxi-surface);
    color: var(--oxi-primary);
    font-size: .8rem;
}

.app-shell .oxi-table-footer .page-item.active .page-link {
    border-color: var(--oxi-primary);
    background: var(--oxi-primary);
    color: #fff;
}

.app-shell .oxi-table-footer .page-item.disabled .page-link {
    background: var(--oxi-surface-soft);
    color: var(--oxi-muted);
    opacity: .72;
}

.app-shell .oxi-table-footer .page-link:hover {
    border-color: var(--oxi-primary);
}

.app-shell :is(.table-responsive, .oxi-table-scroll) > table {
    margin-bottom: 0;
}

.app-shell .oxi-table-scroll > .oxi-datatable {
    width: 100% !important;
    margin: 0 !important;
    border-collapse: collapse !important;
}

.app-shell :is(.table-responsive, .oxi-table-scroll) > .table > :not(caption) > * > :first-child {
    padding-left: 1.25rem;
}

.app-shell :is(.table-responsive, .oxi-table-scroll) > .table > :not(caption) > * > :last-child {
    padding-right: 1.25rem;
}

.app-shell .module-table tbody td {
    line-height: 1.65;
    overflow-wrap: break-word;
}

.app-shell .module-table .badge {
    padding: .48rem .75rem;
    font-size: .7rem;
    font-weight: 700;
    white-space: nowrap;
}

.app-shell .oxi-table-scroll .dataTables_empty {
    padding: 2.25rem 1.25rem !important;
    color: var(--oxi-muted);
}

/* Give nested clinical information and messages room inside their outlines. */
.app-shell .surface-card {
    padding: 1.15rem 1.25rem;
}

.app-shell .patient-summary-list > div {
    padding: .95rem 1.1rem;
}

.app-shell :is(.surface-card, .chat-bubble, .patient-summary-list, .timeline-item) :is(p, small, strong) {
    overflow-wrap: anywhere;
}

.app-shell .chat-panel {
    padding: 1rem;
    scroll-padding: .75rem;
}

.app-shell .chat-bubble {
    padding: 1.1rem 1.25rem;
    line-height: 1.6;
}

html[data-theme="dark"] .app-shell .oxi-table-footer .page-link {
    color: #8addf3;
}

html[data-theme="dark"] .app-shell .oxi-table-footer .page-item.active .page-link {
    color: #fff;
}

html[data-theme="dark"] .app-shell .oxi-table-footer .page-item.disabled .page-link {
    color: var(--oxi-muted);
}

@media (max-width: 767.98px) {
    .app-shell,
    .auth-shell {
        --oxi-glass-radius: 18px;
        --oxi-glass-widget-radius: 16px;
    }

    .app-shell :is(.oxi-table-toolbar, .oxi-table-footer) {
        align-items: flex-start;
        gap: .9rem;
        padding: 1rem;
    }

    .app-shell .oxi-table-toolbar .dataTables_filter {
        width: 100%;
    }

    .app-shell .oxi-table-toolbar .dataTables_filter input {
        flex: 1 1 auto;
        width: 0;
        min-width: 0;
    }

    .app-shell .oxi-table-footer .dataTables_paginate {
        max-width: 100%;
    }

    .app-shell .oxi-table-footer .pagination {
        justify-content: flex-start;
    }

    .app-shell :is(.table-responsive, .oxi-table-scroll) > .table > :not(caption) > * > :first-child {
        padding-left: 1rem;
    }

    .app-shell :is(.table-responsive, .oxi-table-scroll) > .table > :not(caption) > * > :last-child {
        padding-right: 1rem;
    }

    .app-shell .surface-card,
    .app-shell .chat-bubble {
        padding: 1rem;
    }
}

@media (prefers-reduced-transparency: reduce) {
    .app-shell .topbar {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

@media print {
    .app-shell :is(.card, .dashboard-panel, .dashboard-metric, .dashboard-welcome, .dashboard-operations, .topbar) {
        box-shadow: none !important;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}
