:root {
  --toolbar-height: 52px;
  --left-width: 300px;
  --right-width: 340px;
}

html,
body {
  height: 100%;
}

.app-toolbar {
  min-height: var(--toolbar-height);
  position: relative;
  z-index: 3000;
}

.app-logo {
  height: 56px;
  width: auto;
  max-width: 220px;
  object-fit: contain;
}

.section-preview-frame {
  width: 100%;
  height: 130px;
  border: 1px solid #d8dee8;
  background: #fff;
}

.app-main {
  min-height: 0;
}

.app-grid {
  display: grid;
  grid-template-columns: var(--left-width) minmax(420px, 1fr) var(--right-width);
  height: 100%;
}

.panel-left,
.panel-right,
.panel-center {
  min-height: 0;
  overflow: auto;
}

.preview-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.preview-page-tabs {
  background: #f8f9fa;
}

#preview-frame {
  flex: 1 1 auto;
  min-height: 0;
}

.ai-assistant {
  background: #f8f9fa;
  display: none;
}

#ai-output {
  white-space: pre-wrap;
}

.ai-chat-log {
  min-height: 120px;
  max-height: 220px;
  overflow: auto;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  background: #fff;
  padding: 0.5rem;
}

.ai-chat-msg {
  margin-bottom: 0.5rem;
  display: flex;
}

.ai-chat-msg.user {
  justify-content: flex-end;
}

.ai-chat-msg.assistant {
  justify-content: flex-start;
}

.ai-chat-bubble {
  max-width: 85%;
  font-size: 0.8rem;
  line-height: 1.35;
  padding: 0.35rem 0.5rem;
  border-radius: 0.45rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-chat-msg.user .ai-chat-bubble {
  background: #dbeafe;
  border: 1px solid #bfdbfe;
}

.ai-chat-msg.assistant .ai-chat-bubble {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
}

.ai-webchat-frame {
  width: 100%;
  min-height: 260px;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  background: #fff;
}

.element-context-menu {
  position: fixed;
  z-index: 30;
  min-width: 0;
  width: max-content;
  max-width: min(92vw, 360px);
  padding: 0.2rem;
  background: #f8fafc;
  border: 1px solid #d8dee8;
  border-radius: 0;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(3px);
}

.element-context-menu .btn {
  font-size: 0.72rem;
  padding: 0.2rem 0.4rem;
  border-radius: 0;
  text-align: left;
  line-height: 1.2;
  border: 0 !important;
  background: transparent !important;
  color: #1f2937 !important;
  box-shadow: none !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: 100%;
  white-space: nowrap;
}

.element-context-menu .btn + .btn {
  margin-top: 0.2rem;
}

.element-context-menu .w-100 {
  width: auto !important;
}

.element-context-menu .btn:hover,
.element-context-menu .btn:focus-visible {
  background: #e8eef8 !important;
  color: #0f172a !important;
}

.element-context-menu .btn.text-danger,
.element-context-menu .btn.btn-outline-danger {
  color: #b42318 !important;
}

.element-context-menu .btn.btn-outline-primary,
.element-context-menu .btn.btn-outline-secondary {
  color: #1f2937 !important;
}

.icon-tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.1rem;
  font-size: 1rem;
  overflow: visible;
}

.icon-tab::after {
  content: "";
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  font-size: 0.72rem;
  padding: 0.18rem 0.4rem;
  border-radius: 0.28rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease-in-out;
  z-index: 2000;
  display: none;
}

.icon-tab:hover::after,
.icon-tab:focus-visible::after {
  opacity: 0;
}

.panel-left .nav,
.panel-right .nav {
  position: relative;
  z-index: 1000;
  overflow: visible;
}

.app-toolbar .dropdown-menu {
  z-index: 4000;
  width: max-content;
  min-width: 0;
  border: 1px solid #d8dee8;
  border-radius: 0;
  padding: 0.3rem;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
  background: #f8fafc;
}

.app-toolbar .dropdown-item {
  border-radius: 0;
  padding: 0.38rem 0.55rem;
  font-size: 0.82rem;
  color: #1f2937;
}

.app-toolbar .dropdown-item:hover,
.app-toolbar .dropdown-item:focus {
  background: #e8eef8;
  color: #0f172a;
}

.app-toolbar .dropdown-divider {
  margin: 0.28rem 0;
  border-top-color: #d8dee8;
}

#navbar-menu-editor-content .btn {
  border: 0 !important;
  background: #eef2f7 !important;
  color: #1f2937 !important;
  box-shadow: none !important;
}

#navbar-menu-editor-content .btn:hover,
#navbar-menu-editor-content .btn:focus-visible {
  background: #e2e8f0 !important;
}

#navbar-menu-editor-content .btn.btn-outline-danger {
  background: #fdecec !important;
  color: #b42318 !important;
}

.structure-drop-before {
  box-shadow: inset 0 3px 0 #0d6efd;
}

.structure-drop-inside {
  outline: 2px dashed #0d6efd;
  outline-offset: 1px;
}

.structure-drop-after {
  box-shadow: inset 0 -3px 0 #0d6efd;
}

#structure-tree .btn[draggable="true"] {
  cursor: grab;
}

#structure-tree.structure-drag-active .btn[draggable="true"] {
  cursor: grabbing;
}

.structure-row .structure-item-btn {
  font-size: 0.74rem;
  padding: 0.12rem 0.35rem;
  line-height: 1.2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.structure-item-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.structure-item-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1rem;
  font-size: 0.72rem;
  line-height: 1;
  opacity: 0.8;
}

.asset-dropzone {
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.asset-dropzone-active {
  border-color: #0d6efd !important;
  background: #e7f1ff;
}

.asset-icon {
  width: 32px;
  height: 32px;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #6c757d;
  background: #f8f9fa;
}

#left-assets,
#assets-list {
  min-height: 100%;
}

#assets-list {
  display: flex;
  flex-direction: column;
}

.panel-left .tab-content > .tab-pane {
  height: 100%;
}

.asset-fill {
  flex: 1 1 auto;
  min-height: 60px;
}

.template-picker-card {
  border: 1px solid #dfe3e8;
  border-radius: 0.5rem;
  background: #fff;
  padding: 0;
  overflow: hidden;
  min-height: 380px;
  height: 380px;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.template-picker-card:hover,
.template-picker-card:focus-visible {
  border-color: #b8d3ff;
  box-shadow: 0 10px 22px rgba(13, 110, 253, 0.15);
  transform: translateY(-1px);
  outline: none;
}

.template-picker-preview-wrap {
  height: 250px;
  flex: 0 0 250px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  overflow: hidden;
}

.template-picker-preview {
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
  background: #fff;
}

#template-picker-modal .modal-dialog {
  max-width: min(1480px, 96vw);
}

#template-picker-modal .modal-body {
  max-height: 80vh;
  overflow: auto;
}

@media (max-width: 1200px) {
  .app-grid {
    grid-template-columns: 260px minmax(360px, 1fr) 300px;
  }
}

@media (max-width: 992px) {
  .app-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(420px, 1fr) auto;
  }

  .panel-left,
  .panel-right {
    max-height: 32vh;
  }
}
