/* ========== HTML Preview App ========== */

.hp-app {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* ========== Header ========== */

.hp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.hp-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hp-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hp-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-sans);
}

.hp-auto-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-sans);
}

.hp-auto-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.hp-auto-btn.active {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}

.hp-auto-btn svg {
  flex-shrink: 0;
}

/* ========== Main Layout ========== */

.hp-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ========== Editor Panel ========== */

.hp-editor-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
  min-height: 0;
}

.hp-tabs {
  display: flex;
  align-items: center;
  padding: 0 8px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  gap: 2px;
  min-height: 40px;
}

.hp-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hp-tab-btn:hover {
  color: var(--text-secondary);
  background: var(--surface-3);
}

.hp-tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.hp-tab-btn svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.hp-tab-btn.active svg {
  opacity: 1;
}

.hp-char-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding-right: 8px;
}

.hp-editors {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.hp-editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.hp-textarea {
  width: 100%;
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: none;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  resize: none;
  outline: none;
  tab-size: 2;
  min-height: 0;
}

.hp-textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.5;
}

/* ========== Preview Panel ========== */

.hp-preview-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

.hp-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  min-height: 40px;
}

.hp-preview-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-family: var(--font-sans);
}

.hp-preview-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.hp-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  position: relative;
}

.hp-icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.hp-icon-btn.active {
  color: var(--accent);
}

.hp-console-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--accent);
  color: #080b14;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  font-family: var(--font-sans);
}

.hp-console-badge.hp-badge-error {
  background: var(--red);
  color: #fff;
}

.hp-preview-content {
  flex: 1;
  overflow: hidden;
  min-height: 0;
  background: #fff;
}

.hp-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

/* ========== Console Panel ========== */

.hp-console-panel {
  display: none;
  flex-direction: column;
  border-top: 1px solid var(--border);
  background: var(--bg);
  max-height: 200px;
  min-height: 0;
}

.hp-console-panel.hp-console-open {
  display: flex;
}

.hp-console-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  min-height: 32px;
}

.hp-console-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-family: var(--font-sans);
}

.hp-console-clear-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  font-family: var(--font-sans);
}

.hp-console-clear-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.hp-console-output {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  min-height: 60px;
  max-height: 168px;
}

.hp-console-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-mono);
  opacity: 0.5;
}

.hp-console-entry {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 3px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  border-bottom: 1px solid var(--border-light);
}

.hp-console-entry:last-child {
  border-bottom: none;
}

.hp-console-icon {
  flex-shrink: 0;
  width: 16px;
  text-align: center;
  font-size: 10px;
  line-height: 18px;
}

.hp-console-text {
  flex: 1;
  white-space: pre-wrap;
  word-break: break-all;
  min-width: 0;
}

.hp-console-time {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.6;
  line-height: 18px;
}

.hp-console-log {
  color: var(--text-secondary);
}

.hp-console-log .hp-console-icon {
  color: var(--accent);
}

.hp-console-error {
  color: var(--red);
  background: rgba(255, 59, 48, 0.06);
}

.hp-console-error .hp-console-icon {
  color: var(--red);
}

.hp-console-warn {
  color: var(--orange);
  background: rgba(255, 149, 0, 0.06);
}

.hp-console-warn .hp-console-icon {
  color: var(--orange);
}

.hp-console-info {
  color: var(--accent);
}

.hp-console-info .hp-console-icon {
  color: var(--accent);
}

/* ========== Fullscreen Mode ========== */

.hp-fullscreen-mode .hp-editor-panel {
  display: none;
}

.hp-fullscreen-mode .hp-main {
  grid-template-columns: 1fr;
}

.hp-preview-panel.hp-fullscreen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  background: var(--surface);
}

/* ========== Status Bar ========== */

.hp-status-bar {
  padding: 6px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-sans);
}

.hp-status-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.hp-status-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hp-shortcut-hint {
  font-size: 11px;
  opacity: 0.6;
}

/* ========== Responsive ========== */

@media (max-width: 768px) {
  .hp-main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .hp-editor-panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .hp-header {
    padding: 10px 14px;
  }

  .hp-header-left,
  .hp-header-right {
    flex-wrap: wrap;
    gap: 6px;
  }

  .hp-tabs {
    padding: 0 4px;
    overflow-x: auto;
  }

  .hp-tab-btn {
    padding: 6px 10px;
    font-size: 11px;
  }

  .hp-char-count {
    display: none;
  }

  .hp-textarea {
    padding: 12px;
    font-size: 12px;
  }

  .hp-console-panel.hp-console-open {
    max-height: 150px;
  }

  .hp-status-bar {
    padding: 4px 12px;
  }

  .hp-shortcut-hint {
    display: none;
  }

  .hp-fullscreen-mode .hp-editor-panel {
    display: none;
  }

  .hp-fullscreen-mode .hp-main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }
}
