/*
 * Bimmer CSS Library
 * Entry point for the isolated design-system pilot.
 *
 * This file is wired into index.html for scoped pilots. Keep production
 * migrations behind bm-scope and document each pilot before widening usage.
 */

@layer bm.tokens, bm.base, bm.layout, bm.components, bm.utilities, bm.legacy;

@import url("./00-tokens/core.css") layer(bm.tokens);
@import url("./01-base/document.css") layer(bm.base);
@import url("./02-layout/layout.css") layer(bm.layout);
@import url("./03-components/button.css") layer(bm.components);
@import url("./03-components/icon-button.css") layer(bm.components);
@import url("./03-components/badge.css") layer(bm.components);
@import url("./03-components/card.css") layer(bm.components);
@import url("./03-components/control.css") layer(bm.components);
@import url("./03-components/social-tokens.css") layer(bm.components);
@import url("./03-components/social.css") layer(bm.components);
@import url("./03-components/tabs.css") layer(bm.components);
@import url("./03-components/form-control.css") layer(bm.components);
@import url("./03-components/table.css") layer(bm.components);
@import url("./03-components/modal.css") layer(bm.components);
@import url("./03-components/feedback.css") layer(bm.components);
@import url("./05-utilities/motion.css") layer(bm.utilities);
@import url("./05-utilities/utilities.css") layer(bm.utilities);
@import url("./legacy/legacy-compat.css") layer(bm.legacy);

/*
 * Unlayered by design: production pilots must override legacy unlayered CSS
 * while the rest of the library stays inside cascade layers.
 */
@import url("./legacy/production-pilots.css?v=20260619-ribbon-dock-1");
@import url("./legacy/index-shell-bridge.css");
@import url("./04-features/analytics.css");
@import url("./04-features/workspace-focus.css");
@import url("./04-features/content-hub-gateway.css");
@import url("./04-features/content-hub-pages.css");
@import url("./04-features/gantt.css");
@import url("./04-features/ribbon-nav-integration.css");
@import url("./premium-enhancements.css");
@import url("./premium-advanced-components.css");

@media (max-width: 760px) {
  .bm-scope.main-view-nav.bm-tabs.main-view-nav--workspace.is-mobile-expanded,
  body.workspace-focus-active .bm-scope.main-view-nav.bm-tabs.main-view-nav--workspace.is-mobile-expanded {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .bm-scope.main-view-nav.bm-tabs.main-view-nav--workspace.is-mobile-expanded .workspace-nav-meta,
  .bm-scope.main-view-nav.bm-tabs.main-view-nav--workspace.is-mobile-expanded .workspace-nav-mobile-panels {
    align-self: stretch;
    width: 100%;
  }
}

@media (max-width: 768px) {
  .bm-scope.table-container .budget-close-inline-action,
  .bm-scope.table-container .budget-actions-inner .budget-delete-action {
    display: none !important;
  }
}

/* Visual polish pass: contrast, motion and tactile states.
 * Keep this late in the cascade so it can rescue legacy/pilot surfaces.
 */
:root {
  --bm-polish-ink: #111827;
  --bm-polish-ink-soft: #334155;
  --bm-polish-muted: #5b6b82;
  --bm-polish-surface: #ffffff;
  --bm-polish-surface-soft: #f6f9fc;
  --bm-polish-border: #cad7e6;
  --bm-polish-blue: #1f5fd6;
  --bm-polish-blue-strong: #1747a6;
  --bm-polish-teal: #08756f;
  --bm-polish-teal-strong: #075e59;
  --bm-polish-green: #087a3d;
  --bm-polish-green-soft: #dff8e8;
  --bm-polish-amber: #9a5a00;
  --bm-polish-amber-soft: #fff4d6;
  --bm-polish-red: #b42318;
  --bm-polish-red-soft: #ffe4e2;
  --bm-polish-focus: 0 0 0 3px rgba(31, 95, 214, 0.24);
  --bm-polish-shadow-sm: 0 2px 8px rgba(17, 24, 39, 0.08);
  --bm-polish-shadow-md: 0 10px 24px rgba(17, 24, 39, 0.12);
  --bm-polish-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

.bm-scope,
.modal-content:not(.welcome-gateway-card),
.toolbar-dropdown-panel,
.floating-rubro-list {
  color: var(--bm-polish-ink);
}

.bm-button,
.bm-icon-button,
.view-tab,
.toolbar-dropdown-item,
.mobile-project-action,
.mobile-settings-btn,
.budget-row-mobile-actions > summary,
.quantity-step-btn,
.btn-details-inline,
.btn-gantt-chart,
.btn-close-budget {
  transition:
    background-color 160ms var(--bm-polish-ease),
    background-image 160ms var(--bm-polish-ease),
    border-color 160ms var(--bm-polish-ease),
    box-shadow 160ms var(--bm-polish-ease),
    color 160ms var(--bm-polish-ease),
    transform 120ms var(--bm-polish-ease),
    filter 160ms var(--bm-polish-ease);
}

.bm-button:focus-visible,
.bm-icon-button:focus-visible,
.view-tab:focus-visible,
.toolbar-dropdown-item:focus-visible,
.mobile-project-action:focus-visible,
.mobile-settings-btn:focus-visible,
.budget-row-mobile-actions > summary:focus-visible,
.quantity-step-btn:focus-visible,
.btn-details-inline:focus-visible,
.btn-gantt-chart:focus-visible,
.btn-close-budget:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--bm-polish-focus);
}

.bm-button:hover:not(:disabled, .is-disabled),
.bm-icon-button:hover:not(:disabled, .is-disabled),
.view-tab:hover:not(:disabled, .is-disabled),
.toolbar-dropdown-item:hover:not(:disabled, .is-disabled),
.mobile-project-action:hover:not(:disabled, .is-disabled),
.budget-row-mobile-actions > summary:hover {
  filter: saturate(1.03);
  transform: translateY(-1px);
}

.bm-button:active:not(:disabled, .is-disabled),
.bm-icon-button:active:not(:disabled, .is-disabled),
.view-tab:active:not(:disabled, .is-disabled),
.toolbar-dropdown-item:active:not(:disabled, .is-disabled),
.mobile-project-action:active:not(:disabled, .is-disabled),
.budget-row-mobile-actions > summary:active {
  transform: translateY(0);
}

.bm-button--primary,
.project-toolbar-action--new,
.workspace-nav-action.bm-button--primary,
.mobile-project-action.bm-button--primary,
.pdf-export-action--detailed {
  background: linear-gradient(135deg, var(--bm-polish-blue) 0%, var(--bm-polish-blue-strong) 100%);
  border-color: rgba(23, 71, 166, 0.9);
  color: #ffffff;
  text-shadow: 0 1px 1px rgba(11, 17, 32, 0.24);
}

.bm-button--success,
.bm-button--success-quiet.is-dirty,
.workspace-nav-save.is-dirty,
.mobile-project-action.bm-button--success-quiet.is-dirty,
.pdf-export-action--executive {
  background: linear-gradient(135deg, var(--bm-polish-teal) 0%, var(--bm-polish-teal-strong) 100%);
  border-color: rgba(7, 94, 89, 0.82);
  color: #ffffff;
  text-shadow: 0 1px 1px rgba(11, 17, 32, 0.2);
}

.bm-button--danger,
.bm-button--danger-quiet.is-danger,
.toolbar-dropdown-item--danger,
.pdf-export-action--preview {
  background: linear-gradient(135deg, #d33b2f 0%, var(--bm-polish-red) 100%);
  border-color: rgba(180, 35, 24, 0.75);
  color: #ffffff;
  text-shadow: 0 1px 1px rgba(11, 17, 32, 0.22);
}

.bm-button--secondary,
.bm-button--outline,
.bm-button--quiet,
.workspace-nav-action.bm-button--quiet,
.toolbar-dropdown-item,
.view-tab,
.budget-row-mobile-actions > summary {
  color: var(--bm-polish-ink);
}

.bm-button--secondary,
.bm-button--outline,
.toolbar-dropdown-item,
.budget-row-mobile-actions > summary {
  background: linear-gradient(180deg, #ffffff 0%, #f3f7fb 100%);
  border-color: var(--bm-polish-border);
}

.bm-button--quiet,
.view-tab {
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(202, 215, 230, 0.72);
}

.bm-button--tonal,
.project-toolbar-action--ai,
.workflow-next-step button {
  background: linear-gradient(180deg, #e7f0ff 0%, #dbeafe 100%);
  border-color: #b8cdf7;
  color: #123a7a;
}

.bm-badge,
.workspace-nav-status {
  border: 1px solid rgba(148, 163, 184, 0.32);
  color: var(--bm-polish-ink);
  text-shadow: none;
}

.bm-badge--success,
.workspace-nav-status.bm-badge--success {
  background: var(--bm-polish-green-soft);
  border-color: #9fe7b8;
  color: var(--bm-polish-green);
}

.bm-badge--warning,
.workspace-nav-status.bm-badge--warning {
  background: var(--bm-polish-amber-soft);
  border-color: #f3d48a;
  color: var(--bm-polish-amber);
}

.bm-badge--danger,
.workspace-nav-status.bm-badge--danger,
.workspace-nav-status.bm-badge--error {
  background: var(--bm-polish-red-soft);
  border-color: #ffb8b2;
  color: var(--bm-polish-red);
}

.quantity-step-btn {
  background: linear-gradient(180deg, #ffffff 0%, #eef5ff 100%);
  border: 1px solid #bed0ea;
  color: #1747a6;
  box-shadow: var(--bm-polish-shadow-sm);
}

.quantity-step-btn:hover {
  background: linear-gradient(180deg, #f8fbff 0%, #dbeafe 100%);
  color: #123a7a;
}

.quantity-step-btn.is-decrease,
.quantity-step-btn.is-increase {
  border-color: transparent;
  color: #ffffff;
  text-shadow: 0 1px 1px rgba(11, 17, 32, 0.22);
}

.quantity-step-btn.is-decrease {
  background: linear-gradient(135deg, #e94b35 0%, var(--bm-polish-red) 100%);
  box-shadow: 0 8px 18px rgba(180, 35, 24, 0.2);
}

.quantity-step-btn.is-increase {
  background: linear-gradient(135deg, #0d8ecf 0%, var(--bm-polish-teal) 100%);
  box-shadow: 0 8px 18px rgba(8, 117, 111, 0.2);
}

.quantity-step-btn.is-decrease:hover,
.quantity-step-btn.is-increase:hover {
  color: #ffffff;
  filter: brightness(1.04) saturate(1.04);
}

.quantity-input-modern,
.quantity-input-compact,
.bm-input,
.login-modal-card .form-group input {
  background: #ffffff;
  border-color: #b9c8dc;
  color: var(--bm-polish-ink);
}

.quantity-input-modern::placeholder,
.quantity-input-compact::placeholder,
.bm-input::placeholder,
.login-modal-card .form-group input::placeholder {
  color: #66778f;
  opacity: 1;
}

.budget-table th,
.budget-table td,
.budget-rubro-name,
.budget-actions-inner > span {
  color: var(--bm-polish-ink);
}

.budget-table th,
.category-row td {
  background: linear-gradient(180deg, #f6f9fc 0%, #edf4fb 100%);
}

.budget-certification-chip,
.budget-flow-chip,
.budget-mobile-meta span {
  text-shadow: none;
}

.budget-flow-chip.is-linked,
.budget-certification-chip.is-approved {
  background: #e3f8ec;
  border-color: #9fe7b8;
  color: #087a3d;
}

.budget-flow-chip.is-missing {
  background: #fff1df;
  border-color: #f0be77;
  color: #9a4f00;
}

.budget-flow-chip.is-pending {
  background: #e8f1ff;
  border-color: #b8cdf7;
  color: #1747a6;
}

.budget-flow-chip.is-neutral,
.budget-mobile-meta span {
  background: #edf2f7;
  border-color: #c9d6e4;
  color: #334155;
}

.login-modal-card,
.app-dialog-card,
.project-data-editor,
.rubro-details-modal,
.modal-content:not(.welcome-gateway-card),
.toolbar-dropdown-panel,
.workspace-mobile-group-panel,
.pdf-export-buttons {
  background: rgba(255, 255, 255, 0.96);
  color: var(--bm-polish-ink);
  border-color: rgba(202, 215, 230, 0.84);
  box-shadow: var(--bm-polish-shadow-md);
}

.modal-overlay,
.login-modal-overlay,
.app-dialog-overlay {
  background: rgba(12, 20, 33, 0.72);
  backdrop-filter: blur(10px);
}

.modal-overlay .modal-content:not(.welcome-gateway-card),
.login-modal-overlay .modal-content:not(.welcome-gateway-card),
.app-dialog-overlay .modal-content:not(.welcome-gateway-card) {
  background: #ffffff;
  color: var(--bm-polish-ink);
}

.modal-content:not(.welcome-gateway-card) h1,
.modal-content:not(.welcome-gateway-card) h2,
.modal-content:not(.welcome-gateway-card) h3,
.modal-content:not(.welcome-gateway-card) h4,
.modal-content:not(.welcome-gateway-card) strong {
  color: var(--bm-polish-ink);
}

.modal-content:not(.welcome-gateway-card) p,
.modal-content:not(.welcome-gateway-card) small,
.modal-content:not(.welcome-gateway-card) li {
  color: var(--bm-polish-ink-soft);
}

.welcome-gateway-card .welcome-gateway-copy,
.welcome-gateway-card .welcome-gateway-copy h1,
.welcome-gateway-card .welcome-gateway-copy h2,
.welcome-gateway-card .welcome-gateway-copy h3,
.welcome-gateway-card .welcome-gateway-copy h4,
.welcome-gateway-card .welcome-gateway-copy strong {
  color: #fff8ee;
}

.welcome-gateway-card .welcome-gateway-copy p {
  color: rgba(255, 248, 238, 0.82);
}

.welcome-gateway-card .welcome-gateway-eyebrow {
  color: #ffd7aa;
}

.modal-content .bm-button--primary,
.modal-content .bm-button--success,
.modal-content .sample-project-card .bm-button--primary {
  color: #ffffff;
}

.login-modal-card .login-modal-header,
.app-dialog-card.app-dialog-success {
  text-shadow: none;
}

.pdf-export-buttons .pdf-export-action {
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.pdf-export-buttons .pdf-export-action--success {
  background: linear-gradient(135deg, var(--bm-polish-green) 0%, #046c38 100%);
  color: #ffffff;
}

.catalog-ribbon,
.floating-rubro-list {
  color: var(--bm-polish-ink);
}

.floating-rubro-list .result-name,
.search-result-item,
.rubro-list-table {
  color: var(--bm-polish-ink);
}

.hub-button,
.hub-button-secondary,
.hub-button-tertiary,
.hub-app-fab {
  text-shadow: none;
}

@media (prefers-reduced-motion: no-preference) {
  .budget-table tbody tr.draggable-row,
  .workspace-mobile-group,
  .toolbar-dropdown-panel,
  .floating-rubro-list,
  .app-dialog-card,
  .login-modal-card {
    animation-duration: 180ms;
    animation-timing-function: var(--bm-polish-ease);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

body.dark-mode .bm-scope,
body.dark-mode .modal-content,
body.dark-mode .toolbar-dropdown-panel,
body.dark-mode .floating-rubro-list {
  color: #f8fafc;
}

body.dark-mode .bm-button--secondary,
body.dark-mode .bm-button--outline,
body.dark-mode .bm-button--quiet,
body.dark-mode .toolbar-dropdown-item,
body.dark-mode .view-tab,
body.dark-mode .budget-row-mobile-actions > summary {
  background: linear-gradient(180deg, #172033 0%, #111827 100%);
  border-color: #334155;
  color: #e5edf7;
}

body.dark-mode .bm-button--tonal,
body.dark-mode .project-toolbar-action--ai {
  background: linear-gradient(180deg, #183b72 0%, #12305e 100%);
  border-color: #315f9f;
  color: #dbeafe;
}

body.dark-mode .bm-badge,
body.dark-mode .workspace-nav-status {
  border-color: rgba(148, 163, 184, 0.35);
}

body.dark-mode .bm-badge--success,
body.dark-mode .workspace-nav-status.bm-badge--success {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(74, 222, 128, 0.34);
  color: #bbf7d0;
}

body.dark-mode .bm-badge--warning,
body.dark-mode .workspace-nav-status.bm-badge--warning {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(251, 191, 36, 0.34);
  color: #fde68a;
}

body.dark-mode .quantity-step-btn,
body.dark-mode .quantity-input-modern,
body.dark-mode .quantity-input-compact,
body.dark-mode .bm-input,
body.dark-mode .login-modal-card .form-group input {
  background: #101827;
  border-color: #334155;
  color: #f8fafc;
}
