html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

.ai-chat-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  z-index: 1040;
}

.ai-chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 100vw;
  height: 100vh;
  background: #fff;
  z-index: 1050;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
}

.ai-chat-header {
  padding: 1rem;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-chat-body {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
}

.ai-chat-input {
  padding: 1rem;
  border-top: 1px solid #dee2e6;
}

.ai-message {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  margin-bottom: 0.75rem;
  max-width: 90%;
}

.ai-message-assistant {
  background: #f1f3f5;
}

.product-lines-page {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 1.25rem;
  align-items: stretch;
  min-height: calc(100vh - 180px);
}

.compatibility-page {
  display: grid;
  grid-template-columns: minmax(280px, 0.6fr) minmax(0, 1.6fr);
  gap: 1.25rem;
  align-items: stretch;
  min-height: calc(100vh - 180px);
}

.product-lines-sidebar,
.compatibility-sidebar,
.product-lines-editor,
.compatibility-editor {
  min-height: 0;
}

.product-lines-sidebar,
.compatibility-sidebar,
.product-lines-editor .card,
.compatibility-editor .card {
  border: 1px solid #dee2e6;
  border-radius: 8px;
  background: #fff;
}

.product-lines-sidebar,
.compatibility-sidebar {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 180px);
}

.product-lines-editor .card,
.compatibility-editor .card {
  height: 100%;
  max-height: calc(100vh - 180px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.product-lines-sidebar-header,
.product-lines-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  padding: 1rem 1rem 0.75rem;
}

.product-lines-list {
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  gap: 0.5rem;
  overflow: auto;
}

.product-line-list-item {
  width: 100%;
  text-align: left;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  background: #fff;
  padding: 0.85rem 0.9rem;
}

.product-line-list-item.active {
  border-color: #0d6efd;
  background: #f8fbff;
}

.product-line-list-name-row,
.product-line-list-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.product-line-list-name {
  font-weight: 600;
}

.product-line-list-meta {
  color: #6c757d;
  font-size: 0.875rem;
  margin-top: 0.35rem;
}

.product-lines-form {
  display: grid;
  gap: 1rem;
}

.compatibility-form {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 1rem;
  align-items: end;
}

.compatibility-mode-toggle {
  display: inline-flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.compatibility-tree-body {
  flex: 1;
  max-height: none;
}

.product-lines-editor .card-body,
.compatibility-editor .card-body {
  overflow: auto;
}

.product-lines-form-toggles {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.product-lines-selectors {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.product-line-tree-panel {
  border: 1px solid #dee2e6;
  border-radius: 8px;
  overflow: hidden;
}

.product-line-tree-header {
  padding: 0.85rem;
  border-bottom: 1px solid #dee2e6;
  display: grid;
  gap: 0.75rem;
}

.tree-panel-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.product-line-tree-body {
  max-height: 560px;
  overflow: auto;
  padding: 0.85rem;
}

.line-tree-node + .line-tree-node {
  margin-top: 0.35rem;
}

.line-tree-row,
.line-tree-item-row {
  display: grid;
  grid-template-columns: 20px 18px minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: center;
  min-height: 32px;
}

.line-tree-row-single {
  grid-template-columns: 20px 18px minmax(0, 1fr) auto;
}

.line-tree-children {
  padding-left: 1.5rem;
  margin-top: 0.25rem;
}

.line-tree-toggle,
.line-tree-toggle-placeholder {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.line-tree-toggle {
  border: 1px solid #ced4da;
  border-radius: 4px;
  background: #fff;
  color: #495057;
  font-size: 0.75rem;
  line-height: 1;
}

.line-tree-label,
.line-tree-item-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-tree-meta,
.line-tree-item-code {
  color: #6c757d;
  font-size: 0.8rem;
}

.compatibility-header-item {
  width: 100%;
  text-align: left;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  background: #fff;
  padding: 0.55rem 0.7rem;
}

.compatibility-header-item.active {
  border-color: #0d6efd;
  background: #f8fbff;
}

.compatibility-header-item-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compatibility-active-header {
  padding: 0.85rem 1rem;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  background: #f8f9fa;
}

@media (max-width: 992px) {
  .product-lines-page {
    grid-template-columns: 1fr;
  }

  .compatibility-page {
    grid-template-columns: 1fr;
  }

  .compatibility-form {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .product-lines-selectors {
    grid-template-columns: 1fr;
  }
}
