/* ==========================================================================
   docker2lxc — Dark Theme with Glassmorphism
   ========================================================================== */

/* --- CSS Custom Properties --- */
:root {
  --bg-deep: #06080d;
  --bg-primary: #0a0f1a;
  --bg-secondary: #0f1520;
  --bg-panel: rgba(14, 20, 32, 0.7);
  --bg-panel-solid: #0e1420;
  --bg-input: rgba(12, 17, 28, 0.8);
  --bg-hover: rgba(255, 255, 255, 0.04);

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-medium: rgba(255, 255, 255, 0.1);
  --border-accent: rgba(0, 212, 255, 0.3);

  --text-primary: #e8ecf4;
  --text-secondary: #8892a4;
  --text-muted: #4a5568;
  --text-bright: #ffffff;

  --accent-cyan: #00d4ff;
  --accent-purple: #7c3aed;
  --accent-gradient: linear-gradient(135deg, #00d4ff, #7c3aed);
  --accent-gradient-hover: linear-gradient(135deg, #00e5ff, #8b5cf6);
  --accent-glow: rgba(0, 212, 255, 0.15);
  --accent-glow-strong: rgba(0, 212, 255, 0.3);

  --success: #22c55e;
  --success-glow: rgba(34, 197, 94, 0.2);
  --error: #ef4444;
  --error-glow: rgba(239, 68, 68, 0.2);
  --warning: #f59e0b;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px var(--accent-glow);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;

  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;

  --header-height: 56px;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Animated background gradient */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse at 15% 10%, rgba(0, 212, 255, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 20%, rgba(124, 58, 237, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(0, 212, 255, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* --- Header --- */
#app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(10, 15, 26, 0.8);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 100;
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  height: 100%;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.logo-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
  color: white;
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: -0.02em;
}

.logo-accent {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition-base);
}

.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 8px var(--success-glow);
  animation: pulse-dot 2s infinite;
}

.status-dot.error {
  background: var(--error);
  box-shadow: 0 0 8px var(--error-glow);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* --- Main Layout --- */
#app-main {
  position: relative;
  z-index: 1;
  max-width: 1600px;
  margin: 0 auto;
  padding: calc(var(--header-height) + 1.5rem) 1.5rem 2rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  min-height: 100vh;
}

/* --- Panels (Glassmorphism) --- */
.panel {
  background: var(--bg-panel);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition-base);
}

.panel:hover {
  border-color: var(--border-medium);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.2rem;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.015);
}

.panel-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.panel-title svg {
  opacity: 0.6;
}

/* --- Editor Panel --- */
.panel-editor {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--header-height) - 3rem);
}

.editor-wrap {
  flex: 1;
  min-height: 400px;
}

/* CodeMirror overrides */
.editor-wrap .CodeMirror {
  height: 100%;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.7;
  padding: 0.5rem 0;
}

.editor-wrap .CodeMirror-gutters {
  background: transparent;
  border-right: 1px solid var(--border-subtle);
}

.editor-wrap .CodeMirror-linenumber {
  color: var(--text-muted);
  padding: 0 0.5rem;
}

.editor-wrap .CodeMirror-cursor {
  border-left-color: var(--accent-cyan);
}

.editor-wrap .CodeMirror-selected {
  background: rgba(0, 212, 255, 0.1) !important;
}

.editor-wrap .CodeMirror-focused .CodeMirror-selected {
  background: rgba(0, 212, 255, 0.15) !important;
}

/* --- Panel Group (Right Column) --- */
.panel-group {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

/* --- Settings Grid --- */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1.2rem;
}

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

.field-full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.field-value {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-cyan);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

/* Inputs */
input[type="text"],
select {
  width: 100%;
  height: 38px;
  padding: 0 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input[type="text"]:focus,
select:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input[type="text"]::placeholder {
  color: var(--text-muted);
}

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 24 24' fill='none' stroke='%234a5568' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

/* Range sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  outline: none;
  margin-top: 0.3rem;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-gradient);
  cursor: pointer;
  border: 2px solid var(--bg-primary);
  box-shadow: 0 0 8px var(--accent-glow);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 0 16px var(--accent-glow-strong);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-gradient);
  cursor: pointer;
  border: 2px solid var(--bg-primary);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* IP Toggle */
.ip-toggle {
  display: flex;
  gap: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  margin-top: 0.2rem;
}

.ip-btn {
  flex: 1;
  padding: 0.5rem 1rem;
  border: none;
  background: var(--bg-input);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ip-btn:first-child {
  border-right: 1px solid var(--border-subtle);
}

.ip-btn.active {
  background: var(--accent-gradient);
  color: white;
}

.ip-btn:hover:not(.active) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.static-fields {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.static-fields.hidden {
  display: none;
}

.static-fields input {
  flex: 1;
}

/* --- Agent Cards --- */
.agent-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  padding: 1rem 1.2rem;
}

.agent-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 1rem 0.5rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  cursor: pointer;
  transition: all var(--transition-base);
  color: var(--text-secondary);
  font-family: var(--font-sans);
}

.agent-card:hover {
  border-color: var(--border-medium);
  background: var(--bg-hover);
  transform: translateY(-2px);
}

.agent-card.active {
  border-color: var(--accent-cyan);
  background: rgba(0, 212, 255, 0.06);
  box-shadow: 0 0 20px var(--accent-glow);
  color: var(--text-primary);
}

.agent-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.agent-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: inherit;
}

.agent-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* --- Action Buttons --- */
.action-row {
  display: flex;
  gap: 0.75rem;
}

.btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.5rem;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

.btn-convert {
  background: var(--bg-panel);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
}

.btn-convert:hover:not(:disabled) {
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.btn-deploy {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-deploy:hover:not(:disabled) {
  background: var(--accent-gradient-hover);
  box-shadow: 0 6px 30px var(--accent-glow-strong);
  transform: translateY(-2px);
}

.btn-ghost {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-ghost:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  background: rgba(0, 212, 255, 0.05);
}

/* --- Script Output --- */
.panel-output .script-output {
  padding: 1rem 1.2rem;
  max-height: 400px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre;
  tab-size: 2;
}

.script-output::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.script-output::-webkit-scrollbar-track {
  background: transparent;
}

.script-output::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 3px;
}



/* --- Utility --- */
.hidden {
  display: none !important;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  #app-main {
    grid-template-columns: 1fr;
  }

  .panel-editor {
    min-height: 50vh;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .agent-cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 640px) {
  html { font-size: 14px; }

  #app-main {
    padding: calc(var(--header-height) + 1rem) 0.75rem 1.5rem;
    gap: 1rem;
  }

  .agent-cards {
    grid-template-columns: 1fr;
  }

  .action-row {
    flex-direction: column;
  }

  .static-fields {
    flex-direction: column;
  }
}


.logo-icon-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.app-footer {
  text-align: center;
  padding: 2rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  opacity: 0.7;
}
