// App Container
.app-container {
  min-height: 100vh;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

// Print mode (EntityViewer plan, Phase F): hide interactive chrome — entity-type selector,
// print/share buttons, footer stats, any loading overlay — so what prints is just the record.
@media print {
  .app-container {
    background: none;
  }
  .entity-selector,
  .entity-header-actions,
  .app-footer,
  .loading-overlay {
    display: none !important;
  }
}

// Header
.app-header {
  background: white;
  padding: 0.5rem 2rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 17px;

  .app-title {
    margin: 0;
    font-size: 1.75rem;
    color: #2c3e50;
    font-weight: 700;
  }

  .app-subtitle {
    margin: 0.25rem 0 0;
    color: #7f8c8d;
    font-size: 0.875rem;
  }
}

.app-actions {
  display: flex;
  gap: 0.75rem;
}

.app-action-btn {
  padding: 0.5rem 1rem;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 0.375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;

  &:hover {
    background: #2980b9;
    transform: translateY(-1px);
  }

  &:active {
    transform: translateY(0);
  }
}

// Main Content
.app-main {
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 2rem;
  overflow: auto;
  height: 550px;
}

// Controls
.app-controls {
  background: white;
  padding: 1.5rem;
  border-radius: 0.75rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
}

.controls-title {
  font-size: 1rem;
  color: #2c3e50;
  font-weight: 600;
}

.entity-selector {
  .entity-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
  }
}

.theme-selector {
  .theme-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
}

.entity-btn,
.theme-btn {
  padding: 0.3rem 0.75rem;
  background: white;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid #dbe2ea;

  &:hover {
    border-color: #3498db;
    background: #f8fafc;
  }

  &.active {
    background: #3498db;
    border-color: #3498db;
    color: white;
  }
}

.entity-icon {
  font-size: 1.125rem;
}

.theme-btn {
  justify-content: center;
}

// Entity Display
.entity-display {
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.entity-header {
  flex-shrink: 0;
  padding-left: calc(var(--space-xl) *1px);
  padding-right: calc(var(--space-xl) *1px);
  padding-top: calc(var(--space-m) *1px);
  padding-bottom: calc(var(--space-m) *1px);
  background-color: var(--category-text-alpha);
  color: var(--category-bg-alpha);
}

.entity-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 1.5rem;
}

.entity-header-left {
  display: flex;
  align-items: center;
  // flex-direction: column;
  // flex: 1;
}

.entity-display-title {
  font-size: calc(var(--font-size-key) *1px);
  font-weight: var(--font-weight-semiBold);
  line-height: calc(var(--font-lineHeight-key) * 1px);
  letter-spacing: calc(var(--font-letterSpacing-sm) * 1px);
  color: var(--category-bg-alpha);
}

.entity-id {
  font-size: 0.875rem;
  background: rgba(255, 255, 255, 0.2);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-weight: normal;
}

.entity-meta {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.75rem;
  font-size: 0.875rem;
  opacity: 0.9;
  flex-wrap: wrap;
}

.entity-status {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-weight: 600;
}

// TOP ACTION BUTTONS
.entity-header-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-shrink: 0;
}

.top-action-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding-right: calc(var(--space-m) *1px);
  padding-left: calc(var(--space-m) *1px);
  gap: calc(var(--space-s) *1px);
  min-height: calc(var(--space-3xl) *1px);
  background-color: var(--button-secondary-bg-default);
  border: 1px solid var(--button-secondary-border-default);
  border-radius: calc(var(--size-radius-s) *1px);
  cursor: pointer;
  white-space: nowrap;

  &:hover {
    background-color: var(--button-secondary-bg-hover);
    color: var(--category-text-alpha);
    transition: all 0.2s ease;
  }

  &:active {
    background-color: var(--button-secondary-bg-active);
    color: var(--category-text-alpha);
  }
}


.entity-viewer-container {
  padding-bottom: 10px;
  min-height: 400px;
  position: relative;

  &.dark-theme {
    background: #1a1a1a;
  }
}

.no-entity-selected {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-state {
  .empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
  }

  h3 {
    margin: 0 0 0.5rem;
    color: #2c3e50;
  }

  p {
    margin: 0;
    color: #7f8c8d;
  }
}

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;

  .loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 3px solid #3498db;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
  }

  p {
    margin: 0;
    color: #2c3e50;
    font-weight: 600;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

// REMOVE OLD BOTTOM ACTIONS
.entity-actions {
  display: none;
}

// Footer
.app-footer {
  margin-top: 3rem;
  padding: 1.5rem 0;
  border-top: 1px solid #e0e6ed;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #7f8c8d;
  font-size: 0.875rem;
}

.footer-info {
  p {
    margin: 0.25rem 0;
  }

  .footer-hint {
    font-size: 0.75rem;
    opacity: 0.7;
  }
}

.footer-stats {
  display: flex;
  gap: 1.5rem;
}

.stat-item {
  strong {
    color: #2c3e50;
    font-weight: 700;
  }
}

// Dark Theme
.dark-theme {

  .app-header,
  .app-controls,
  .entity-display {
    background: #2c3e50;
    color: white;
  }

  .entity-header {
    background: linear-gradient(135deg, #1a237e 0%, #4a148c 100%);
  }

  .entity-btn,
  .theme-btn {
    background: #34495e;
    border-color: #4a6278;
    color: white;

    &:hover {
      border-color: #3498db;
      background: #2c3e50;
    }

    &.active {
      background: #3498db;
      border-color: #3498db;
    }
  }
}

// Responsive Design
@media (max-width: 1024px) {
  .app-controls {
    grid-template-columns: 1fr;
  }

  .entity-header-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .entity-header-actions {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .app-main {
    padding: 0 1rem;
  }

  .app-header-content {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .entity-buttons {
    flex-direction: column;
  }

  .entity-btn,
  .theme-btn {
    width: 100%;
    justify-content: center;
  }

  .entity-meta {
    flex-direction: column;
    gap: 0.5rem;
  }

  .footer-content {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .footer-stats {
    justify-content: center;
  }

  .entity-header-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .entity-header-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .action-btn {
    flex: 1;
    justify-content: center;
  }
}

@media (max-width: 480px) {

  .app-header,
  .entity-header,
  .entity-viewer-container {
    padding-bottom: 10px;
  }

  .entity-display-title {
    font-size: 1.25rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .entity-header-actions {
    flex-direction: column;
    width: 100%;
  }

  .action-btn {
    width: 100%;
  }
}

.lightbox-mode {
  min-height: auto;
  background: transparent;
}

.lightbox-mode .app-main {
  margin: 0;
  padding: 0;
  max-width: 100%;
  height: auto;
}

.lightbox-mode .entity-display {
  border-radius: 0;
  box-shadow: none;
}