/* =============================================================================
   Page Layout System

   This file owns all flex layout rules for the page editor.
   Consolidated here to avoid conflicts with pages.css.

   Layout hierarchy:
   .page-content
     └── turbo-frame (scroll container)
           └── .content
                 └── turbo-frame (nested)
                       └── [id^="page_"][id$="_content"]
                             └── form
                                   └── .mark-editor-wrapper
                                         ├── .mark-container
                                         └── .empty-state-overlay
   ============================================================================= */

/* Page content - flex column to fill available space */
.page-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Main turbo-frame - scroll container */
.page-content > turbo-frame {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* Content wrapper */
.content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Nested turbo-frames */
.content > turbo-frame,
.page-content .content > turbo-frame {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

[id^="page_"][id$="_content"] {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

[id^="page_"][id$="_content"] > form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.mark-editor-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.mark-editor-wrapper .mark-container {
  flex: 1;
}

.empty-state-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ntabs-bg-primary, #ffffff);
  z-index: 250;
  cursor: text;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.empty-state-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  cursor: text;
}

.empty-state-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.empty-state-hint {
  font-size: 0.9rem;
  color: var(--ntabs-text-secondary, #9ca3af);
  margin: 0;
  font-weight: 400;
}

.template-grid {
  display: flex;
  gap: 0.5rem;
  cursor: default;
}

.template-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 1rem;
  min-width: 70px;
  background: transparent;
  border: 1px solid var(--ntabs-border, #e5e7eb);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  opacity: 0.7;
}

.template-card:hover {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.05);
  opacity: 1;
}

.template-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ntabs-text-secondary, #9ca3af);
}

.template-card:hover .template-icon {
  color: #3b82f6;
}

.template-name {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--ntabs-text-secondary, #6b7280);
}

.template-card:hover .template-name {
  color: var(--ntabs-text-primary, #374151);
}

.empty-state-shortcut {
  font-size: 0.65rem;
  color: var(--ntabs-text-secondary, #9ca3af);
  margin: 0;
  opacity: 0.6;
}

.empty-state-shortcut kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.25rem;
  font-family: inherit;
  font-size: 0.55rem;
  font-weight: 500;
  background: var(--ntabs-bg-tertiary, #f3f4f6);
  border: 1px solid var(--ntabs-border, #e5e7eb);
  border-radius: 3px;
  color: var(--ntabs-text-primary, #374151);
}

/* Dark mode */
.mark-dark .empty-state-overlay,
[data-theme="dark"] .empty-state-overlay {
  background: var(--mark-bg-primary, #0d1117);
}

.mark-dark .template-card,
[data-theme="dark"] .template-card {
  border-color: #3d3d4d;
}

.mark-dark .template-card:hover,
[data-theme="dark"] .template-card:hover {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
}

.mark-dark .template-name,
[data-theme="dark"] .template-name {
  color: #9ca3af;
}

.mark-dark .template-card:hover .template-name,
[data-theme="dark"] .template-card:hover .template-name {
  color: #e5e5e5;
}

.mark-dark .empty-state-shortcut kbd,
[data-theme="dark"] .empty-state-shortcut kbd {
  background: #2d2d3d;
  border-color: #3d3d4d;
  color: #e5e5e5;
}

/* Persistent shortcut hint at bottom of page */
.shortcut-hint-persistent {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: var(--ntabs-text-secondary, #9ca3af);
  z-index: 5;
  opacity: 0.5;
  transition: opacity 0.2s ease;
  cursor: pointer;
}

/* Hide persistent hint when empty state is visible */
.main-content:has(.empty-state-overlay:not(.hidden)) .shortcut-hint-persistent {
  display: none;
}

.shortcut-hint-persistent:hover {
  opacity: 1;
}

.shortcut-hint-persistent kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.25rem;
  font-family: inherit;
  font-size: 0.55rem;
  font-weight: 500;
  background: var(--ntabs-bg-tertiary, #f3f4f6);
  border: 1px solid var(--ntabs-border, #e5e7eb);
  border-radius: 3px;
  color: var(--ntabs-text-primary, #374151);
}

[data-theme="dark"] .shortcut-hint-persistent kbd {
  background: #2d2d3d;
  border-color: #3d3d4d;
  color: #e5e5e5;
}
