/* Shared screen layout. Keep report/print layouts and financial data intact. */
:is(.ctd-shell, .saas-shell, .auth-ui) {
    --ui-focus: #0284c7;
    min-height: 100vh;
    min-height: 100dvh;
}
:is(.ctd-shell, .saas-shell, .auth-ui) :focus-visible {
    outline: 3px solid var(--ui-focus);
    outline-offset: 3px;
}
.ui-skip-link { position: fixed; left: 1rem; top: -10rem; z-index: 2000; padding: .8rem 1rem; background: #fff; color: #0f2744; border-radius: .5rem; }
.ui-skip-link:focus { top: 1rem; }
:is(.ctd-shell, .saas-shell, .auth-ui) main { min-width: 0; }
:is(.ctd-shell, .saas-shell, .auth-ui) main :is(.row > *, .d-flex > *, .card, .card-body, .saas-card, .dashboard-card, .special-content-area) { min-width: 0; }
:is(.ctd-shell, .saas-shell, .auth-ui) main :is(h1, h2, h3, h4, h5, h6, p, .alert, .form-text, .invalid-feedback) { overflow-wrap: anywhere; }
:is(.ctd-shell, .saas-shell, .auth-ui) main :is(img, video) { max-width: 100%; height: auto; }
:is(.ctd-shell, .saas-shell) main canvas { max-width: 100%; }
:is(.ctd-shell, .saas-shell, .auth-ui) :is(.btn, .page-link) { white-space: normal; }
:is(.ctd-shell, .saas-shell) :is(.pagination, .breadcrumb) { flex-wrap: wrap; gap: .25rem; }
:is(.ctd-shell, .saas-shell) :is(.nav-tabs, .nav-pills) { gap: .25rem; }
:is(.ctd-shell, .saas-shell) .table-responsive { max-width: 100%; scrollbar-width: thin; }
.ui-table-scroll { overflow-x: auto; }
.ui-table-scroll:focus-visible { outline-offset: -3px; }
.ui-table-hint { display: block; margin: 0; padding: .5rem .75rem; color: var(--ws-muted, #526579); background: var(--ws-bg, #f1f5f9); font-size: .78rem; }
.ui-table-hint[hidden] { display: none; }
.ui-module-toggle { display: none; }
.ui-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }
.ctd-shell { --ui-focus: var(--ws-accent); }
.ctd-shell .ctd-workspace-identity > div { min-width: 0; }
.ctd-shell .special-content-area { min-width: 0; }
.ctd-shell main .special-sidebar .sidebar-title { color: #e7edf5 !important; }
.ctd-shell main .card-header.text-white :is(h1, h2, h3, h4, h5, h6) { color: #fff !important; }
.ctd-shell .ctd-command-heading { gap: 1rem; }
.ctd-shell .ctd-command-close { flex-shrink: 0; }
.ctd-shell .navbar .nav-link { white-space: normal; overflow-wrap: anywhere; }
.ctd-shell .navbar .dropdown-menu { max-width: calc(100vw - 2rem); }
.ctd-shell .navbar .dropdown-menu-accordion { min-width: 0; }
.ctd-shell .navbar-brand { min-width: 0; white-space: normal; }
.saas-shell { background: #f4f7fb; }
.saas-shell .saas-card { box-shadow: 0 6px 24px -12px #0f27442b; }
.saas-shell main :is(.form-control, .form-select) { border-radius: .65rem; border-color: #cbd5e1; min-height: 2.75rem; }
.saas-shell main :is(.form-control, .form-select):focus { border-color: #0284c7; box-shadow: 0 0 0 .2rem #0284c71f; }
.saas-shell .navbar-collapse { min-width: 0; }
.saas-shell .saas-account-actions { flex-wrap: wrap; min-width: 0; }
.saas-shell .saas-account-actions .dropdown { max-width: 100%; }
.saas-shell .saas-account-actions .dropdown-toggle span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saas-shell .saas-navbar .nav-link.active { background: var(--saas-accent-light); border-radius: .5rem; }
.saas-shell .saas-navbar .nav-link { padding: .65rem .75rem; }
.saas-shell .saas-brand { min-width: 0; }
.saas-shell .saas-brand svg { flex-shrink: 0; }
.saas-shell .saas-footer .text-secondary { color: #a7b6c9 !important; }
.saas-shell .saas-footer .d-flex.gap-3 { flex-wrap: wrap; }
.saas-shell .max-w-700 { max-width: 700px; }
.auth-ui .auth-shell { width: 100%; }
.auth-ui .saas-nav nav { flex-wrap: wrap; }

@media screen and (min-width: 1200px) {
    .saas-shell .saas-navbar > .container-xl { display: grid; grid-template-columns: auto 1fr; gap: .5rem 1rem; }
    .saas-shell .saas-navbar .navbar-collapse { display: contents !important; }
    .saas-shell .saas-navbar .navbar-nav { grid-column: 1 / -1; grid-row: 2; margin: 0 !important; padding-top: .4rem; border-top: 1px solid var(--saas-border); flex-wrap: wrap; }
    .saas-shell .saas-account-actions { grid-column: 2; grid-row: 1; justify-self: end; }
}

@media screen and (max-width: 1199.98px) {
    .saas-shell main .row.g-5 { --bs-gutter-x: 1.5rem; }
    .saas-shell .navbar-collapse { max-height: calc(100vh - 76px); max-height: calc(100dvh - 76px); overflow-y: auto; padding: .75rem 0; }
    .saas-shell .saas-account-actions { border-top: 1px solid var(--saas-border); padding-top: .85rem; }
    /* Keep account links in the scrollable navbar flow instead of clipping an overlay. */
    .saas-shell .saas-account-actions > .dropdown { width: 100%; }
    .saas-shell .saas-account-actions .dropdown-toggle { max-width: 100%; }
    .saas-shell .saas-account-actions .dropdown-menu { position: static; width: 100%; min-width: 0 !important; }
    .saas-shell .saas-account-actions .dropdown-item { white-space: normal; overflow-wrap: anywhere; }
    .ctd-shell .navbar-collapse { overscroll-behavior-y: contain; }
    .ctd-shell .ctd-utilities > li { width: 100%; margin: 0 !important; }
    .ctd-shell .ctd-utilities :is(.nav-link, .ctd-chip) { margin: 0 !important; }
    .ctd-shell .navbar .dropdown-menu { width: 100%; max-width: 100%; box-shadow: none; }
}
@media screen and (max-width: 991.98px) {
    .ctd-shell .main-card-container { padding-inline: 1.25rem !important; }
    .ctd-shell main :is(.kpi-grid, .analytics-stats-grid) { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
}
@media screen and (max-width: 767.98px) {
    :is(.ctd-shell, .saas-shell, .auth-ui) :is(.btn, .page-link, .navbar-toggler) { min-height: 44px; }
    :is(.ctd-shell, .saas-shell, .auth-ui) :is(.form-control, .form-select, .select2-selection) { font-size: 1rem; }
    :is(.ctd-shell, .saas-shell) main .d-flex:not(.flex-column):not(.input-group):not(.progress) { flex-wrap: wrap; }
    :is(.ctd-shell, .saas-shell) main :is(.input-group, .form-control, .form-select, .select2-container) { max-width: 100%; }
    :is(.ctd-shell, .saas-shell) main .select2-container { width: 100% !important; }
    :is(.ctd-shell, .saas-shell) main :is(.card-header, .modal-footer) { gap: .65rem; }
    :is(.ctd-shell, .saas-shell) main .btn-group { flex-wrap: wrap; gap: .25rem; }
    :is(.ctd-shell, .saas-shell) .modal-dialog { margin: .75rem; }
    :is(.ctd-shell, .saas-shell) .modal-content { max-height: calc(100dvh - 1.5rem); }
    :is(.ctd-shell, .saas-shell) .modal-body { overflow-y: auto; }
    .ctd-shell .ui-module-toggle { display: flex; align-items: center; justify-content: space-between; gap: .5rem; width: 100%; margin-bottom: .75rem; text-align: left; }
    .ctd-shell main :is(.admin-sidebar, .recettes-sidebar, .pcd-sidebar, .projet-sidebar, .sidebar-matieres, .special-sidebar) { display: block !important; width: 100%; min-height: 0; margin-bottom: 1rem; }
    .ctd-shell main .ui-module-sidebar[hidden] { display: none !important; }
    .ctd-shell .special-layout-container { flex-direction: column; }
    .ctd-shell .special-content-area { padding: 1rem; }
    .ctd-shell .ui-module-sidebar .nav-link { min-height: 44px; }
    .ctd-shell .ui-module-sidebar :is(.sidebar-title, .sidebar-header) { color: #e7edf5; }
    .ctd-shell .ctd-command { max-height: 85dvh; }
    .ctd-shell .ctd-command-results { max-height: 45dvh; }
    .ctd-shell .ctd-command-footer { flex-wrap: wrap; }
    .ctd-shell .floating-ai-btn { bottom: max(1rem, env(safe-area-inset-bottom)) !important; right: 1rem !important; width: 48px; height: 48px; }
    .ctd-shell #floating-chat-panel { right: 1rem !important; bottom: calc(4.5rem + env(safe-area-inset-bottom)) !important; width: calc(100vw - 2rem); max-width: calc(100vw - 2rem); max-height: calc(100dvh - 6rem); }
    .ctd-shell #floating-chat-panel.sidebar-open :is(.chat-panel-messages, .chat-panel-form) { margin-left: 0; }
    .ctd-shell .chat-conv-sidebar { width: 100%; }
    .saas-shell .saas-card.p-4 { padding: 1.25rem !important; }
    .saas-shell .hero-wrapper { padding: 3rem 0; }
    .saas-shell .hero-title { font-size: clamp(2rem, 7vw, 3rem); }
    .saas-shell .hero-mockup-card { padding: 1rem; }
    .saas-shell :is(.section-padding, .saas-footer) { padding-block: 2.5rem; }
    .saas-shell .cta-banner { padding: 2rem 1.25rem; }
    .saas-shell .pricing-card { padding: 1.75rem 1.25rem; }
    .saas-shell .pricing-card.featured { transform: none; }
    .saas-shell .saas-alert-container { position: static; width: auto; max-width: none; margin: 1rem; }
}
@media screen and (max-width: 575.98px) {
    .ctd-shell .main-card-container { padding-inline: .75rem !important; }
    .ctd-shell .navbar-brand { font-size: .95rem; max-width: calc(100% - 60px); }
    .ctd-shell main .row.g-0 > [class*="col-"].p-4 { padding: 1rem !important; }
    .ctd-shell main .login-container { padding: 1.5rem; }
    .ctd-shell main .hero-section { padding: 2rem 1.25rem; margin-bottom: 1.5rem; }
    .ctd-shell main .hero-title { font-size: clamp(1.65rem, 6vw, 2.5rem); }
    .ui-actions > :is(.btn, form) { flex: 1 1 auto; }
    .ui-actions > form > .btn { width: 100%; }
    .saas-shell .saas-brand { font-size: 1rem; gap: .3rem; }
    .saas-shell .saas-brand-badge { display: none; }
    .saas-shell main > .container-xl.py-5 { padding-top: 2rem !important; padding-bottom: 2rem !important; }
    .saas-shell .saas-account-actions > .btn { flex: 1 1 auto; }
    .saas-shell .hero-tag { font-size: .7rem; letter-spacing: .04em; }
    .saas-shell .hero-mockup-card .col-6 { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
    :is(.ctd-shell, .saas-shell, .auth-ui) *, :is(.ctd-shell, .saas-shell, .auth-ui) *::before, :is(.ctd-shell, .saas-shell, .auth-ui) *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
    .ui-module-toggle, .ui-table-hint, .ui-skip-link { display: none !important; }
    .ui-table-scroll { overflow: visible; }
}
