/* pypr-gui global styles — dark theme inspired by Hyprland aesthetics */

:root {
  --bg-primary: #1a1b26;
  --bg-secondary: #24283b;
  --bg-tertiary: #2f3348;
  --bg-hover: #3b3f57;
  --text-primary: #c0caf5;
  --text-secondary: #a9b1d6;
  --text-muted: #565f89;
  --accent: #7aa2f7;
  --accent-hover: #89b4fa;
  --success: #9ece6a;
  --warning: #e0af68;
  --error: #f7768e;
  --border: #3b3f57;
  --radius: 6px;
  --radius-lg: 10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Layout */
.app-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header .header-icon {
  width: 28px;
  height: 28px;
}

.app-header .config-path {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: monospace;
}

.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 0;
}

.sidebar-section {
  padding: 0 12px;
  margin-bottom: 16px;
}

.sidebar-section h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
  padding: 0 8px;
}

.plugin-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s;
}

.plugin-item:hover {
  background: var(--bg-hover);
}

.plugin-item.active {
  background: var(--bg-tertiary);
  color: var(--accent);
}

.plugin-item.disabled {
  opacity: 0.5;
}

.plugin-item input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
}

.plugin-item .plugin-name {
  flex: 1;
}

/* Main content */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

.plugin-header {
  margin-bottom: 24px;
}

.plugin-header h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.plugin-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.docs-link {
  font-size: 0.75rem;
  font-family: monospace;
  color: var(--text-muted);
  text-decoration: none;
  margin-left: 6px;
  vertical-align: middle;
}

.docs-link:hover {
  color: var(--accent);
}

.plugin-envs {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.env-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* Category groups */
.category-group {
  margin-bottom: 24px;
}

.category-group h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* Form fields */
.field-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
}

.field-row + .field-row {
  border-top: 1px solid var(--bg-tertiary);
}

.field-label {
  width: 200px;
  min-width: 200px;
  padding-top: 6px;
}

.field-label .name {
  font-size: 0.85rem;
  font-weight: 500;
  font-family: monospace;
  color: var(--text-primary);
}

.field-label .name .required {
  color: var(--error);
  margin-left: 2px;
}

.field-label .name .recommended {
  color: var(--warning);
  margin-left: 2px;
  font-size: 0.7rem;
}

.field-label .description {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.field-label .type-badge {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: monospace;
  opacity: 0.7;
}

.field-input {
  flex: 1;
  min-width: 0;
}

/* Input styles */
input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 6px 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: monospace;
  outline: none;
  transition: border-color 0.15s;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

textarea {
  min-height: 60px;
  resize: vertical;
}

textarea.json-textarea {
  min-height: 120px;
  font-family: monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  tab-size: 2;
  white-space: pre;
}

/* Field hints (below inputs) */
.field-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.field-hint .json-error {
  color: var(--error);
  margin-left: 8px;
}

/* Child entries section titles */
.child-entries-title {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.child-entries-desc {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-bottom: 12px;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23565f89' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

/* Toggle switch */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
}

.toggle {
  position: relative;
  width: 36px;
  height: 20px;
  cursor: pointer;
}

.toggle input {
  display: none;
}

.toggle .slider {
  position: absolute;
  inset: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 20px;
  transition: all 0.2s;
}

.toggle .slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  top: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all 0.2s;
}

.toggle input:checked + .slider {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle input:checked + .slider::before {
  transform: translateX(16px);
  background: white;
}

.toggle-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg-primary);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-success {
  background: var(--success);
  color: var(--bg-primary);
}

.btn-success:hover {
  opacity: 0.9;
}

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

/* Action bar */
.action-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Status messages */
.status-message {
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: var(--radius);
}

.status-message.success {
  background: rgba(158, 206, 106, 0.15);
  color: var(--success);
}

.status-message.error {
  background: rgba(247, 118, 142, 0.15);
  color: var(--error);
}

.status-message.warning {
  background: rgba(224, 175, 104, 0.15);
  color: var(--warning);
}

/* Error list */
.error-list {
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(247, 118, 142, 0.1);
  border-radius: var(--radius);
  border: 1px solid rgba(247, 118, 142, 0.2);
  list-style: none;
}

.error-list li {
  font-size: 0.8rem;
  color: var(--error);
  margin: 4px 0;
  font-family: monospace;
}

/* Scratchpad / child entries */
.child-entries {
  margin-top: 12px;
}

/* Collapsible header — shared by child entries and dict entries */
.collapsible-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  cursor: pointer;
  user-select: none;
  font-size: 0.85rem;
}

.collapsible-header .chevron {
  color: var(--text-muted);
  transition: transform 0.2s;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.collapsible-header .chevron.open {
  transform: rotate(90deg);
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 0.85rem;
}

/* Dict editor (generic recursive) */
.dict-editor.nested {
  border-left: 2px solid var(--border);
  padding-left: 12px;
  margin-left: 4px;
}

.dict-entry {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  overflow: hidden;
}

.dict-entry-name {
  font-family: monospace;
  font-weight: 500;
  color: var(--text-primary);
}

.dict-entry-type {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: monospace;
}

.dict-entry-preview {
  flex: 1;
  min-width: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dict-entry-actions {
  margin-left: auto;
  flex-shrink: 0;
}

.dict-entry-body {
  padding: 10px 12px;
}

.dict-entry-rename {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--bg-tertiary);
}

.dict-rename-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.dict-rename-input {
  width: 200px;
  font-size: 0.8rem;
  padding: 3px 8px;
}

.dict-value-input {
  font-family: monospace;
  font-size: 0.8rem;
}

/* Array items inside dict entries */
.dict-array-editor {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dict-array-item {
  display: flex;
  flex-direction: column;
}

.dict-array-string {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dict-array-string input,
.dict-array-string textarea {
  flex: 1;
}

.dict-array-object {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
}

.dict-array-object-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.dict-array-object-field {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
}

.dict-array-field-label {
  width: 100px;
  min-width: 100px;
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding-top: 5px;
}

.dict-array-object-field input,
.dict-array-object-field textarea {
  flex: 1;
  font-size: 0.8rem;
}

/* Add row — shared by dict entries, array items, and child entries */
.add-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
}

.add-row-key {
  width: 160px;
}

.add-row-val {
  flex: 1;
}

.add-row-type {
  width: 90px;
  font-size: 0.8rem;
  padding: 4px 6px;
}

/* Tiny button variant */
.btn-xs {
  padding: 2px 8px;
  font-size: 0.75rem;
}
