import { css, cssManager } from '@design.estate/dees-element';
import { DeesInputBase } from '../dees-input-base/dees-input-base.js';

export const richtextStyles = [
    ...DeesInputBase.baseStyles,
    cssManager.defaultStyles,
    css`
      :host {
        display: block;
        position: relative;
        font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
      }

      .input-wrapper {
        position: relative;
      }

      .label {
        display: block;
        margin-bottom: 8px;
        font-size: 14px;
        font-weight: 500;
        color: ${cssManager.bdTheme('hsl(0 0% 15%)', 'hsl(0 0% 93.9%)')};
      }

      .editor-container {
        display: flex;
        flex-direction: column;
        min-height: ${cssManager.bdTheme('200px', '200px')};
        border: 1px solid ${cssManager.bdTheme('hsl(0 0% 89.8%)', 'hsl(0 0% 14.9%)')};
        border-radius: 6px;
        background: ${cssManager.bdTheme('hsl(0 0% 100%)', 'hsl(0 0% 9%)')};
        overflow: hidden;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      }

      .editor-container:hover {
        border-color: ${cssManager.bdTheme('hsl(0 0% 79.8%)', 'hsl(0 0% 20.9%)')};
      }

      .editor-container.focused {
        border-color: ${cssManager.bdTheme('hsl(0 0% 9%)', 'hsl(0 0% 98%)')};
        box-shadow: 0 0 0 2px ${cssManager.bdTheme('hsl(0 0% 9% / 0.05)', 'hsl(0 0% 98% / 0.05)')};
      }

      .editor-toolbar {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        padding: 8px 12px;
        background: ${cssManager.bdTheme('hsl(210 40% 96.1%)', 'hsl(0 0% 14.9%)')};
        border-bottom: 1px solid ${cssManager.bdTheme('hsl(0 0% 89.8%)', 'hsl(0 0% 14.9%)')};
        align-items: center;
        position: relative;
      }

      .toolbar-button {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        border: none;
        border-radius: 4px;
        background: transparent;
        cursor: pointer;
        font-size: 14px;
        font-weight: 500;
        color: ${cssManager.bdTheme('hsl(215.4 16.3% 46.9%)', 'hsl(215 20.2% 65.1%)')};
        transition: all 0.15s ease;
        user-select: none;
      }

      .toolbar-button dees-icon {
        width: 16px;
        height: 16px;
      }

      .toolbar-button:hover {
        background: ${cssManager.bdTheme('hsl(0 0% 95.1%)', 'hsl(0 0% 14.9%)')};
        color: ${cssManager.bdTheme('hsl(0 0% 9%)', 'hsl(0 0% 95%)')};
      }

      .toolbar-button.active {
        background: ${cssManager.bdTheme('hsl(0 0% 9%)', 'hsl(0 0% 98%)')};
        color: ${cssManager.bdTheme('hsl(0 0% 100%)', 'hsl(0 0% 3.9%)')};
      }

      .toolbar-button:disabled {
        opacity: 0.5;
        cursor: not-allowed;
      }

      .toolbar-divider {
        width: 1px;
        height: 24px;
        background: ${cssManager.bdTheme('hsl(0 0% 89.8%)', 'hsl(0 0% 14.9%)')};
        margin: 0 4px;
      }

      .editor-content {
        flex: 1;
        padding: 16px;
        overflow-y: auto;
        min-height: var(--min-height, 200px);
      }

      .editor-content .ProseMirror {
        outline: none;
        line-height: 1.6;
        color: ${cssManager.bdTheme('hsl(0 0% 3.9%)', 'hsl(0 0% 98%)')};
        min-height: 100%;
      }

      .editor-content .ProseMirror p {
        margin: 0.5em 0;
      }

      .editor-content .ProseMirror p:first-child {
        margin-top: 0;
      }

      .editor-content .ProseMirror p:last-child {
        margin-bottom: 0;
      }

      .editor-content .ProseMirror h1 {
        font-size: 2em;
        font-weight: bold;
        margin: 1em 0 0.5em 0;
        line-height: 1.2;
      }

      .editor-content .ProseMirror h2 {
        font-size: 1.5em;
        font-weight: bold;
        margin: 1em 0 0.5em 0;
        line-height: 1.3;
      }

      .editor-content .ProseMirror h3 {
        font-size: 1.25em;
        font-weight: bold;
        margin: 1em 0 0.5em 0;
        line-height: 1.4;
      }

      .editor-content .ProseMirror ul,
      .editor-content .ProseMirror ol {
        padding-left: 1.5em;
        margin: 0.5em 0;
      }

      .editor-content .ProseMirror li {
        margin: 0.25em 0;
      }

      .editor-content .ProseMirror blockquote {
        border-left: 4px solid ${cssManager.bdTheme('hsl(0 0% 89.8%)', 'hsl(0 0% 14.9%)')};
        margin: 1em 0;
        padding-left: 1em;
        color: ${cssManager.bdTheme('hsl(215.4 16.3% 46.9%)', 'hsl(215 20.2% 65.1%)')};
        font-style: italic;
      }

      .editor-content .ProseMirror code {
        background: ${cssManager.bdTheme('hsl(0 0% 95.1%)', 'hsl(0 0% 14.9%)')};
        border-radius: 3px;
        padding: 0.2em 0.4em;
        font-family: 'Intel One Mono', 'Fira Code', 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
        font-size: 0.9em;
        color: ${cssManager.bdTheme('hsl(0 0% 15%)', 'hsl(0 0% 93.9%)')};
      }

      .editor-content .ProseMirror pre {
        background: ${cssManager.bdTheme('hsl(0 0% 3.9%)', 'hsl(0 0% 98%)')};
        color: ${cssManager.bdTheme('hsl(0 0% 98%)', 'hsl(0 0% 3.9%)')};
        border-radius: 6px;
        padding: 1em;
        margin: 1em 0;
        overflow-x: auto;
      }

      .editor-content .ProseMirror pre code {
        background: none;
        color: inherit;
        padding: 0;
        border-radius: 0;
      }

      .editor-content .ProseMirror a {
        color: ${cssManager.bdTheme('hsl(222.2 47.4% 51.2%)', 'hsl(217.2 91.2% 59.8%)')};
        text-decoration: underline;
        cursor: pointer;
      }

      .editor-content .ProseMirror a:hover {
        color: ${cssManager.bdTheme('hsl(222.2 47.4% 41.2%)', 'hsl(217.2 91.2% 69.8%)')};
      }

      .editor-footer {
        padding: 8px 12px;
        background: ${cssManager.bdTheme('hsl(210 40% 96.1%)', 'hsl(0 0% 14.9%)')};
        border-top: 1px solid ${cssManager.bdTheme('hsl(0 0% 89.8%)', 'hsl(0 0% 14.9%)')};
        font-size: 12px;
        color: ${cssManager.bdTheme('hsl(215.4 16.3% 46.9%)', 'hsl(215 20.2% 65.1%)')};
        display: flex;
        justify-content: space-between;
        align-items: center;
      }

      .word-count {
        font-weight: 500;
      }

      .link-input {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: ${cssManager.bdTheme('hsl(0 0% 100%)', 'hsl(0 0% 9%)')};
        border: 1px solid ${cssManager.bdTheme('hsl(0 0% 89.8%)', 'hsl(0 0% 14.9%)')};
        border-radius: 6px;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        padding: 12px;
        z-index: 1000;
      }

      .link-input.show {
        display: block;
      }

      .link-input input {
        width: 100%;
        padding: 8px 12px;
        border: 1px solid ${cssManager.bdTheme('hsl(0 0% 89.8%)', 'hsl(0 0% 14.9%)')};
        border-radius: 6px;
        outline: none;
        font-size: 14px;
        background: ${cssManager.bdTheme('hsl(0 0% 100%)', 'hsl(0 0% 9%)')};
        color: ${cssManager.bdTheme('hsl(0 0% 3.9%)', 'hsl(0 0% 98%)')};
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      }

      .link-input input:focus {
        border-color: ${cssManager.bdTheme('hsl(0 0% 9%)', 'hsl(0 0% 98%)')};
        box-shadow: 0 0 0 2px ${cssManager.bdTheme('hsl(0 0% 9% / 0.05)', 'hsl(0 0% 98% / 0.05)')};
      }

      .link-input-buttons {
        display: flex;
        gap: 8px;
        margin-top: 8px;
      }

      .link-input-buttons button {
        padding: 6px 12px;
        border: 1px solid ${cssManager.bdTheme('hsl(0 0% 89.8%)', 'hsl(0 0% 14.9%)')};
        border-radius: 4px;
        background: ${cssManager.bdTheme('hsl(0 0% 100%)', 'hsl(0 0% 9%)')};
        cursor: pointer;
        font-size: 12px;
        color: ${cssManager.bdTheme('hsl(0 0% 45.1%)', 'hsl(0 0% 63.9%)')};
        transition: all 0.15s ease;
        font-weight: 500;
      }

      .link-input-buttons button:hover {
        background: ${cssManager.bdTheme('hsl(0 0% 95.1%)', 'hsl(0 0% 14.9%)')};
        color: ${cssManager.bdTheme('hsl(0 0% 9%)', 'hsl(0 0% 95%)')};
      }

      .link-input-buttons button.primary {
        background: ${cssManager.bdTheme('hsl(0 0% 9%)', 'hsl(0 0% 98%)')};
        color: ${cssManager.bdTheme('hsl(0 0% 100%)', 'hsl(0 0% 3.9%)')};
        border-color: ${cssManager.bdTheme('hsl(0 0% 9%)', 'hsl(0 0% 98%)')};
      }

      .link-input-buttons button.primary:hover {
        background: ${cssManager.bdTheme('hsl(0 0% 15%)', 'hsl(0 0% 93.9%)')};
        border-color: ${cssManager.bdTheme('hsl(0 0% 15%)', 'hsl(0 0% 93.9%)')};
      }

      .description {
        margin-top: 8px;
        font-size: 12px;
        color: ${cssManager.bdTheme('hsl(215.4 16.3% 46.9%)', 'hsl(215 20.2% 65.1%)')};
        line-height: 1.4;
      }

      :host([disabled]) .editor-container {
        opacity: 0.6;
        cursor: not-allowed;
      }

      :host([disabled]) .toolbar-button,
      :host([disabled]) .editor-content {
        pointer-events: none;
      }
    `,
  ];

