import {
  DeesElement,
  customElement,
  html,
  css,
  cssManager,
  property,
  type TemplateResult,
} from '@design.estate/dees-element';

declare global {
  interface HTMLElementTagNameMap {
    'sz-dns-ssl-card': SzDnsSslCard;
  }
}

@customElement('sz-dns-ssl-card')
export class SzDnsSslCard extends DeesElement {
  public static demo = () => html`
    <div style="padding: 24px; max-width: 400px;">
      <sz-dns-ssl-card
        dnsConfigured
        acmeConfigured
      ></sz-dns-ssl-card>
    </div>
  `;

  @property({ type: Boolean })
  public accessor dnsConfigured: boolean = false;

  @property({ type: Boolean })
  public accessor acmeConfigured: boolean = false;

  public static styles = [
    cssManager.defaultStyles,
    css`
      :host {
        display: block;
        height: 100%;
      }

      .card {
        background: ${cssManager.bdTheme('#ffffff', '#09090b')};
        border: 1px solid ${cssManager.bdTheme('#e4e4e7', '#27272a')};
        border-radius: 8px;
        padding: 20px;
        height: 100%;
        box-sizing: border-box;
      }

      .header {
        margin-bottom: 16px;
      }

      .title {
        font-size: 16px;
        font-weight: 600;
        color: ${cssManager.bdTheme('#18181b', '#fafafa')};
      }

      .subtitle {
        font-size: 13px;
        color: ${cssManager.bdTheme('#71717a', '#a1a1aa')};
        margin-top: 2px;
      }

      .items {
        display: flex;
        flex-direction: column;
        gap: 10px;
      }

      .item {
        display: flex;
        justify-content: space-between;
        align-items: center;
      }

      .item-label {
        font-size: 14px;
        color: ${cssManager.bdTheme('#18181b', '#fafafa')};
      }

      .badge {
        display: inline-flex;
        align-items: center;
        padding: 2px 10px;
        border-radius: 9999px;
        font-size: 12px;
        font-weight: 500;
      }

      .badge.configured {
        background: ${cssManager.bdTheme('#dbeafe', 'rgba(59, 130, 246, 0.2)')};
        color: ${cssManager.bdTheme('#2563eb', '#60a5fa')};
      }

      .badge.not-configured {
        background: ${cssManager.bdTheme('#f4f4f5', '#27272a')};
        color: ${cssManager.bdTheme('#71717a', '#a1a1aa')};
      }
    `,
  ];

  public render(): TemplateResult {
    return html`
      <div class="card">
        <div class="header">
          <div class="title">DNS & SSL</div>
          <div class="subtitle">Configuration status</div>
        </div>

        <div class="items">
          <div class="item">
            <span class="item-label">Cloudflare DNS</span>
            <span class="badge ${this.dnsConfigured ? 'configured' : 'not-configured'}">
              ${this.dnsConfigured ? 'Configured' : 'Not configured'}
            </span>
          </div>
          <div class="item">
            <span class="item-label">ACME (Let's Encrypt)</span>
            <span class="badge ${this.acmeConfigured ? 'configured' : 'not-configured'}">
              ${this.acmeConfigured ? 'Configured' : 'Not configured'}
            </span>
          </div>
        </div>
      </div>
    `;
  }
}
