import { css } from 'lit'

export default css`
  :host {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    max-height: 75vh;
  }

  .search {
    width: 100%;
  }

  .empty-list {
    padding: 12px 0;
  }

  .controls {
    display: flex;
    gap: 12px;
    padding-top: 12px;
    flex-direction: column;

    .filters {
      display: flex;
      gap: 8px;
      align-items: center;
      flex-wrap: wrap;
    }

    .top-row {
      display: flex;
      gap: 12px;
      align-items: center;
      flex-wrap: wrap;
    }

    .search-group {
      flex: 1;
      min-width: 300px;
    }

    .sort-group {
      display: flex;
      gap: 8px;
      align-items: center;
    }
  }

  .category-tabs {
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    padding-bottom: 8px;
  }

  .templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 20px 0;
  }

  .template-card {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 20px;
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-medium);
  }

  .template-description {
    color: var(--md-sys-color-on-surface-variant);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
  }

  .template-stats {
    display: flex;
    gap: 16px;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 14px;
  }

  .stat {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .template-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex: 1;
    align-items: flex-end;
  }

  .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 60px 20px;
    text-align: center;
  }

  .empty-icon {
    font-size: 64px;
    color: var(--md-sys-color-outline);
    opacity: 0.6;
    width: 64px;
    height: 64px;
  }

  .empty-title {
    color: var(--md-sys-color-on-surface);
    margin: 0;
  }

  .empty-description {
    color: var(--md-sys-color-on-surface-variant);
    margin: 0;
    max-width: 400px;
  }

  /* Preview Mode Styles */
  .preview-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
    height: 100%;
  }

  .preview-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--md-sys-color-surface-variant);
    border-radius: var(--md-sys-shape-corner-large);
    padding: 20px;
  }

  .preview-header {
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    padding-bottom: 16px;
  }

  .compact-template-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--md-sys-shape-corner-medium);
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;

    &:hover {
      background: var(--md-sys-color-surface);
    }

    &.selected {
      background: var(--md-sys-color-primary-container);
      color: var(--md-sys-color-on-primary-container);
    }
  }

  .compact-icon {
    font-size: 20px;
  }

  .compact-info {
    flex: 1;
    min-width: 0;
  }

  .compact-title {
    font-weight: 500;
    font-size: 14px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .compact-category {
    font-size: 12px;
    opacity: 0.7;
  }

  .preview-main {
    background: var(--md-sys-color-surface);
    border-radius: var(--md-sys-shape-corner-large);
    overflow-y: auto;
  }

  .template-details {
    padding: 24px;
    color: var(--md-sys-color-on-surface);
  }

  .template-details-header {
    display: flex;
    gap: 20px;
    margin-bottom: 32px;
  }

  .template-details-info {
    flex: 1;
    min-width: 0;
  }

  .template-details-title {
    margin: 0 0 8px 0;
    color: var(--md-sys-color-on-surface);
  }

  .template-details-description {
    margin: 0 0 16px 0;
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.5;
  }

  .template-metadata {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
  }

  .metadata-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .metadata-label {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    text-transform: uppercase;
    font-weight: 500;
  }

  .metadata-value {
    color: var(--md-sys-color-on-surface);
  }

  .template-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }

  .template-tag {
    padding: 4px 8px;
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    border-radius: var(--md-sys-shape-corner-small);
    font-size: 12px;
  }

  .template-details-actions {
    display: flex;
    align-items: flex-start;
  }

  .namespace-item {
    margin-top: 12px;
  }

  .namespace-description {
    margin: 0;
  }

  .structure-title {
    margin: 0 0 24px 0;
    color: var(--md-sys-color-on-surface);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    padding-bottom: 8px;
  }

  .domain-overview {
    margin-bottom: 32px;
    padding: 20px;
    background: var(--md-sys-color-surface-variant);
    border-radius: var(--md-sys-shape-corner-medium);
  }

  .domain-name {
    margin: 0 0 8px 0;
    color: var(--md-sys-color-on-surface);
  }

  .domain-description {
    margin: 0 0 16px 0;
    color: var(--md-sys-color-on-surface-variant);
  }

  .domain-stats {
    display: flex;
    gap: 24px;
  }

  .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
  }

  .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--md-sys-color-primary);
  }

  .models-section {
    margin-top: 24px;
    padding-left: 20px;
    border-left: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    flex-direction: column;
    gap: 40px;
  }

  .domain-model-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
  }

  .model-description {
    margin: 0;
  }

  .model-entities {
    margin-top: 20px;
    padding-left: 20px;
    border-left: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    flex-direction: column;
    gap: 40px;
  }

  .domain-entity {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }

  .domain-entity:not(:last-child) {
    border-bottom: 1px solid var(--md-sys-color-outline);
    padding-bottom: 20px;
  }

  .entity-header {
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .entity-title {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .entity-name {
    margin: 0;
    flex: 1;
  }

  .deprecated-badge {
    padding: 2px 6px;
    background: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
    border-radius: var(--md-sys-shape-corner-small);
    font-size: 10px;
    text-transform: uppercase;
  }

  .entity-description {
    margin: 0;
  }

  .entity-semantics {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .semantics-label {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 500;
  }

  .semantic-tag {
    padding: 2px 6px;
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border-radius: var(--md-sys-shape-corner-small);
    font-size: 10px;
  }

  .section-title {
    margin: 0;
    padding: 12px 0;
  }

  .properties-list,
  .associations-list {
    display: flex;
    flex-direction: column;
  }

  .property-item,
  .association-item {
    padding: 20px 0;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    flex-direction: column;
    gap: 8px;

    &:last-child {
      border-bottom: none;
    }

    &.deprecated {
      opacity: 0.6;
      background: var(--md-sys-color-error-container);
    }
  }

  .property-header,
  .association-header {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .property-type {
    padding: 4px 8px;
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    border-radius: var(--md-sys-shape-corner-small);
  }

  .association-targets,
  .association-cardinality {
    padding: 2px 6px;
    background: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
    border-radius: var(--md-sys-shape-corner-small);
    font-size: 12px;
  }

  .property-description,
  .association-description {
    margin: 0;
    color: var(--md-sys-color-on-surface-variant);
  }

  .property-badges,
  .association-badges {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    flex-wrap: wrap;
  }

  .property-badge,
  .association-badge {
    padding: 2px 6px;
    background: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
    border-radius: var(--md-sys-shape-corner-small);
  }

  .property-default,
  .property-enum {
    margin-top: 4px;
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
  }

  .property-default code,
  .property-enum code {
    background: var(--md-sys-color-surface-variant);
    padding: 2px 4px;
    border-radius: var(--md-sys-shape-corner-small);
    margin-right: 8px;
  }

  .property-semantics,
  .association-semantics {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    flex-wrap: wrap;
  }

  .namespace-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0px;
  }

  @media (max-width: 768px) {
    .templates-grid {
      grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
      gap: 16px;
    }

    .controls .top-row {
      flex-direction: column;
      align-items: stretch;
    }

    .controls .search-group {
      min-width: unset;
    }

    .preview-layout {
      grid-template-columns: 1fr;
      gap: 16px;
    }

    .preview-sidebar {
      order: 2;
    }

    .template-details-header {
      flex-direction: column;
      gap: 16px;
    }

    .domain-stats {
      flex-direction: column;
      gap: 12px;
    }
  }
`
