/**
 * Artifacts System - Styles
 * Sistema de visualizaciones interactivas tipo Claude Artifacts
 */

/* Container principal */
#artifacts-container {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  width: 45%;
  height: calc(100vh - var(--topbar-h));
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  z-index: 50;
  display: none;
  overflow-y: auto;
}

#artifacts-container.active {
  display: block;
}

/* Wrapper del artifact */
.artifact-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg);
}

/* Header */
.artifact-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

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

.artifact-title-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.artifact-type-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  background: var(--bg-tertiary);
  padding: 4px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.artifact-actions {
  display: flex;
  gap: 8px;
}

.artifact-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.artifact-btn:hover {
  background: var(--surface);
  border-color: var(--border-focus);
  color: var(--text);
}

/* Content */
.artifact-content {
  flex: 1;
  overflow: auto;
  padding: 20px;
}

/* Code rendering */
.artifact-code-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.artifact-code-wrapper pre {
  margin: 0;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
}

.artifact-code-wrapper code {
  color: var(--text);
}

.artifact-run-btn {
  align-self: flex-start;
  padding: 10px 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.artifact-run-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.artifact-output {
  display: none;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 13px;
  max-height: 300px;
  overflow-y: auto;
}

.artifact-output.active {
  display: block;
}

.output-line {
  padding: 4px 0;
  line-height: 1.6;
}

.output-log {
  color: var(--text);
}

.output-error {
  color: var(--red);
}

.output-warn {
  color: var(--orange);
}

.output-success {
  color: var(--green);
}

/* HTML iframe */
.artifact-iframe {
  width: 100%;
  height: 600px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
}

/* Mermaid diagrams */
.artifact-mermaid {
  padding: 20px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  justify-content: center;
  align-items: center;
}

.artifact-mermaid svg {
  max-width: 100%;
  height: auto;
}

/* Markdown */
.artifact-markdown {
  padding: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  line-height: 1.8;
}

.artifact-markdown h1,
.artifact-markdown h2,
.artifact-markdown h3 {
  color: var(--text);
  margin-top: 24px;
  margin-bottom: 12px;
}

.artifact-markdown h1 {
  font-size: 28px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 8px;
}

.artifact-markdown h2 {
  font-size: 22px;
}

.artifact-markdown h3 {
  font-size: 18px;
}

.artifact-markdown p {
  margin-bottom: 16px;
  color: var(--text2);
}

.artifact-markdown code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
}

.artifact-markdown pre {
  background: var(--bg-tertiary);
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin-bottom: 16px;
}

.artifact-markdown pre code {
  background: none;
  padding: 0;
  color: var(--text);
}

.artifact-markdown ul,
.artifact-markdown ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

.artifact-markdown li {
  margin-bottom: 8px;
  color: var(--text2);
}

.artifact-markdown a {
  color: var(--accent);
  text-decoration: none;
}

.artifact-markdown a:hover {
  text-decoration: underline;
}

.artifact-markdown blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 16px;
  margin: 16px 0;
  color: var(--text3);
  font-style: italic;
}

.artifact-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.artifact-markdown th,
.artifact-markdown td {
  padding: 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.artifact-markdown th {
  background: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text);
}

.artifact-markdown td {
  color: var(--text2);
}

/* Toast notifications */
.artifact-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-elevated);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
}

.artifact-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Responsive */
@media (max-width: 1200px) {
  #artifacts-container {
    width: 50%;
  }
}

@media (max-width: 768px) {
  #artifacts-container {
    width: 100%;
    top: 0;
    height: 100vh;
  }

  .artifact-header {
    padding: 12px 16px;
  }

  .artifact-content {
    padding: 16px;
  }
}

/* Fullscreen mode */
.artifact-wrapper:fullscreen {
  background: var(--bg);
  padding: 20px;
}

.artifact-wrapper:fullscreen .artifact-header {
  border-radius: var(--radius);
  margin-bottom: 16px;
}

/* Syntax highlighting (Prism.js compatible) */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: var(--text3);
}

.token.punctuation {
  color: var(--text2);
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
  color: var(--red);
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: var(--green);
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
  color: var(--orange);
}

.token.atrule,
.token.attr-value,
.token.keyword {
  color: var(--purple);
}

.token.function,
.token.class-name {
  color: var(--cyan);
}

.token.regex,
.token.important,
.token.variable {
  color: var(--orange);
}
