/* Lorem Picsum UI — estetica de panel de control industrial */

:root {
  --c-bg: #0e1117;
  --c-surface: #161b22;
  --c-surface-hover: #1c2129;
  --c-border: #2a3140;
  --c-border-focus: #4a90e2;
  --c-text: #e2e8f0;
  --c-text-dim: #7b8794;
  --c-text-muted: #4a5568;
  --c-accent: #4a90e2;
  --c-accent-glow: rgba(74, 144, 226, 0.15);
  --c-success: #48bb78;
  --c-danger: #f56565;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-sans: 'DM Sans', system-ui, sans-serif;
  --radius: 6px;
  --radius-sm: 4px;
  --shadow-glow: 0 0 20px rgba(74, 144, 226, 0.08);
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 14px;
}

body {
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-sans);
  min-height: 100vh;
  line-height: 1.5;
}

/* ——— Topbar ——— */

.topbar {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar__icon {
  font-size: 1.4rem;
  filter: saturate(0.8);
}

.topbar__title {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--c-text);
}

.topbar__sub {
  font-size: 0.8rem;
  color: var(--c-text-dim);
}

/* ——— Workspace layout ——— */

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 57px);
}

/* ——— Controls sidebar ——— */

.controls {
  padding: 1rem;
  overflow-y: auto;
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.panel {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: var(--c-surface);
}

.panel__legend {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-text-dim);
  padding: 0 0.3rem;
}

/* ——— Fields ——— */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.field__label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--c-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field__label small {
  font-weight: 400;
  text-transform: none;
  color: var(--c-text-muted);
}

.field__row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.field__row--tight {
  gap: 0.35rem;
}

.field__sep {
  color: var(--c-text-muted);
  font-size: 0.85rem;
  padding-bottom: 0.35rem;
}

.field__input,
.field__select {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: var(--c-bg);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.5rem;
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
  width: 100%;
}

.field__input:focus,
.field__select:focus {
  border-color: var(--c-border-focus);
  box-shadow: 0 0 0 2px var(--c-accent-glow);
}

.field__input--num {
  width: 100%;
  -moz-appearance: textfield;
}

.field__input--num::-webkit-inner-spin-button {
  opacity: 0.4;
}

.field__input--hex {
  width: 5.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field__select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%237b8794'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  padding-right: 1.5rem;
}

/* ——— Color controls ——— */

.color-control {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.color-control__swatch {
  width: 28px;
  height: 28px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  background: none;
  flex-shrink: 0;
}

.color-control__swatch::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.color-control__swatch::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

/* ——— Buttons ——— */

.btn {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  color: var(--c-text-dim);
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  transition: all 0.15s;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

.btn--sm {
  padding: 0.35rem 0.45rem;
  font-size: 0.85rem;
  line-height: 1;
}

.btn--toggle[data-active='true'] {
  background: var(--c-accent-glow);
  border-color: var(--c-accent);
  color: var(--c-accent);
}

.btn--copy {
  font-size: 0.65rem;
  padding: 0.3rem 0.6rem;
  flex-shrink: 0;
}

.btn--copy[data-copied='true'],
.btn--copy[data-downloaded='true'] {
  border-color: var(--c-success);
  color: var(--c-success);
}

/* ——— Preview ——— */

.preview {
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  gap: 1rem;
  overflow: auto;
}

.preview__canvas {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-conic-gradient(#1a1f2a 0% 25%, #151921 0% 50%) 50% /
    16px 16px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  position: relative;
  min-height: 200px;
  overflow: auto;
}

.preview__canvas img {
  max-width: 100%;
  max-height: 100%;
  image-rendering: auto;
  transition: opacity 0.2s;
}

.preview__canvas img[src=''] {
  display: none;
}

.preview__loading {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--c-text-muted);
  display: none;
  animation: pulse 1.2s ease-in-out infinite;
}

.preview__loading.active {
  display: block;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}

/* ——— URL bar ——— */

.url-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
}

.url-bar__url {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--c-text-dim);
  overflow-x: auto;
  white-space: nowrap;
  flex: 1;
  user-select: all;
  scrollbar-width: thin;
  scrollbar-color: var(--c-border) transparent;
}

.url-bar__url::-webkit-scrollbar {
  height: 4px;
}

.url-bar__url::-webkit-scrollbar-thumb {
  background: var(--c-border);
  border-radius: 2px;
}

/* ——— Responsive ——— */

@media (max-width: 768px) {
  .workspace {
    grid-template-columns: 1fr;
    height: auto;
  }

  .controls {
    border-right: none;
    border-bottom: 1px solid var(--c-border);
  }

  .preview__canvas {
    min-height: 300px;
  }
}
