/* Reset & Base */
:root {
  --bg-dark: #1e1e1e;
  --bg-darker: #121212;
  --bg-sidebar: #252526;
  --bg-input: #1e1e1e; /* Changed to match editor bg for cleaner look */
  --accent-blue: #007acc;
  --accent-hover: #0098ff;
  --secondary: #3e3e42;
  --text-primary: #cccccc;
  --text-header: #ffffff;
  --border-color: #333333;
  --code-font: 'JetBrains Mono', 'Fira Code', monospace;
  --ui-font: 'Inter', system-ui, sans-serif;
  --success-color: #4caf50;
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--ui-font);
  margin: 0;
  padding: 0;
  background-color: var(--bg-darker);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Auth Overlay */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.auth-box {
    background: var(--bg-sidebar);
    padding: 30px;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    text-align: center;
}

.auth-box h2 {
    color: var(--text-header);
    margin-top: 0;
}

.auth-form .input-group {
    text-align: left;
    margin-bottom: 15px;
}

.auth-form label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9em;
    color: #aaa;
}

.auth-form input {
    width: 100%;
    padding: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: white;
    border-radius: 4px;
}

.auth-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

/* Sidebar */
.sidebar {
  width: 250px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 15px 20px;
  background-color: var(--bg-darker);
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header h1 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--text-header);
  font-weight: 600;
  cursor: pointer;
}

.sidebar-actions {
  padding: 15px 20px;
}

.scripts-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px;
}

.scripts-list-container h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: #666;
  margin: 10px 10px;
  letter-spacing: 0.5px;
}

.script-item {
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 4px;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s;
  margin-bottom: 2px;
  gap: 8px; /* Space between items */
}

.script-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    opacity: 0.4;
    transition: opacity 0.2s, transform 0.2s, color 0.2s;
    font-size: 0.95rem;
    padding: 2px;
}

.icon-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.edit-icon:hover {
    color: var(--accent-blue);
}

.star-icon {
    /* existing styles... */
    font-size: 1.1rem;
    color: #4d4d4d;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s, transform 0.2s;
}

.star-icon:hover {
    color: #666;
    transform: scale(1.1);
}

.star-icon.favorited {
    color: #ffaa00; /* Gold/Orange */
    text-shadow: 0 0 2px rgba(255, 170, 0, 0.4);
}

.script-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-dark);
}

/* Top Navigation */
.top-nav {
  height: 50px;
  background-color: var(--bg-darker);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.file-info span {
  font-weight: 500;
  color: var(--text-header);
}

.mode-tabs {
  display: flex;
  gap: 2px;
  background-color: var(--bg-dark);
  padding: 3px;
  border-radius: 6px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: #888;
  padding: 6px 16px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.tab-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tab-btn.active {
  background-color: var(--secondary);
  color: var(--text-header);
}

.tab-btn:not(:disabled):hover {
  color: var(--text-header);
}



/* Chips */
.chips-container {
    padding: 5px 0;
}

.var-chip {
    background-color: var(--secondary);
    color: var(--text-header);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
    user-select: none;
}

.var-chip:hover {
    background-color: var(--accent-blue);
    color: white;
    transform: translateY(-1px);
}

.generator-section input[type="text"] {
    width: 100%;
    padding: 10px;
    background-color: var(--bg-input);
    border: 1px solid #3c3c3c;
    color: #d4d4d4;
    border-radius: 4px;
}
.generator-section {
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 6px;
    border: 1px dashed #444;
}

/* Common View Sections */
.view-section {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-dark);
    overflow: hidden; /* Prevent body scroll */
}

/* Editor View (Top - Compact) */
#view-editor {
    flex: 1; /* Full screen height */
    max-height: none;
    overflow-y: auto;
    border-bottom: none;
}

/* Template Designer */
.template-designer {
    padding: 20px;
    background-color: var(--bg-dark);
    display: block; /* Align top-left, normal flow */
}

.designer-container {
    width: 100%;
    max-width: none; /* Full width */
    padding: 0;
}

/* Compact Forms */
.row-flex {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
}

.col-half {
    flex: 1;
}

.mode-selector {
    padding: 8px; /* Compact padding */
    display: flex;
    align-items: center;
    height: 42px; /* Match input height roughly */
}

.form-group {
    margin-bottom: 10px; /* Reduce gap */
    padding: 12px;
}

.input-hint {
    margin-bottom: 6px;
    font-size: 0.8rem;
}

.template-designer input[type="text"] {
    padding: 8px 12px; /* More compact input */
}

.form-actions {
    margin-top: 10px;
}

.form-actions .btn {
    padding: 6px 20px;
}

/* IO View (Bottom - Expands) */
#view-io {
    flex: 1;
    min-height: 0; /* Important for flex child with overflow */
}



/* Container to limit width and hold form elements */
.designer-container {
    width: 100%;
    /* max-width: 800px; Removed to allow full width */
}

.designer-header-info {
    margin-bottom: 20px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.designer-header-info h2 {
    font-size: 1.1rem; /* Smaller title */
    margin: 0;
}

.designer-header-info p {
    font-size: 0.8rem;
    display: none; /* Hide description for compactness */
}

/* Radio Mode Selector */
.mode-selector {
    display: flex;
    gap: 20px;
    background: var(--bg-input);
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #3c3c3c;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-primary);
}

.radio-label input[type="radio"] {
    accent-color: var(--accent-blue);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.radio-label span {
    font-size: 0.95rem;
}

.form-group {
    margin-bottom: 15px;
    background-color: var(--bg-sidebar); /* Card-like background */
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--accent-blue); /* Highlight label */
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}

.input-hint {
    font-size: 0.85rem;
    color: #999;
    margin-bottom: 12px;
    line-height: 1.4;
}

.input-hint code {
    background-color: rgba(255,255,255,0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--code-font);
    color: #ce9178; /* VS Code String color */
}

/* Inputs styling */
.template-designer input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    background-color: var(--bg-input); /* Darker input bg */
    border: 1px solid #3c3c3c;
    color: #d4d4d4;
    font-family: var(--code-font);
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.template-designer input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.2);
}

.template-designer input[type="text"]::placeholder {
    color: #555;
}

.form-actions {
    margin-top: 30px;
    display: flex;
    justify-content: flex-end;
}

.form-actions .btn {
    padding: 10px 24px;
    font-size: 1rem;
    font-weight: 600;
}

.designer-form input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 30px;
}

.editor-wrapper {
  flex: 1;
  padding: 0;
  display: flex;
}

#code-editor {
  flex: 1;
  background-color: var(--bg-dark);
  color: #d4d4d4;
  border: none;
  resize: none;
  font-family: var(--code-font);
  font-size: 14px;
  line-height: 1.5;
  padding: 20px; /* More padding for cleaner look */
  outline: none;
}

/* IO View Layout */
.io-container-vertical {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.io-top-split {
  flex: 1; /* Takes full available space since terminal is removed/hidden */
  display: flex;
  border-bottom: 1px solid var(--border-color);
  min-height: 200px;
}

.io-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
}

.io-panel:last-child {
  border-right: none;
}

/* Terminal Panel (Bottom) */
.terminal-panel {
  flex: 1; /* Takes less space */
  display: flex;
  flex-direction: column;
  background-color: #000; /* Distinctive black background for terminal */
  min-height: 150px;
}

.small-header {
  height: 32px;
  background-color: #252526;
  border-bottom: 1px solid #333;
}

.small-header h3 {
  font-size: 0.75rem;
}

.terminal-content {
  flex: 1;
  padding: 10px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 13px;
  color: #cccccc;
  overflow-y: auto;
  white-space: pre-wrap;
}

.output-content {
    /* Existing style override if needed */
    background-color: #1e1e1e;
}

.panel-header {
  height: 48px; /* Slightly taller for controls */
  padding: 0 15px;
  background-color: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.script-select {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  border: 1px solid #444;
  padding: 4px 8px;
  border-radius: 4px;
  outline: none;
  font-family: var(--ui-font);
  font-size: 0.85rem;
}

.script-select:focus {
  border-color: var(--accent-blue);
}

.panel-header h3 {
  font-size: 0.85rem;
  margin: 0;
  text-transform: uppercase;
  color: #aaa;
}

.input-panel textarea {
  flex: 1;
  background-color: var(--bg-dark); /* Same as editor for consistency */
  color: var(--text-primary);
  border: none;
  resize: none;
  padding: 15px;
  font-family: var(--code-font);
  font-size: 14px;
  outline: none;
}

.output-content {
  flex: 1;
  background-color: var(--bg-darker);
  color: var(--text-primary);
  padding: 15px;
  font-family: var(--code-font);
  font-size: 14px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.terminal-input-area {
  display: flex;
  align-items: center;
  background-color: var(--bg-sidebar);
  border-top: 1px solid var(--border-color);
  padding: 8px 15px;
}

.prompt {
  color: var(--accent-blue);
  margin-right: 10px;
  font-family: var(--code-font);
  font-weight: bold;
}

#terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  color: white;
  font-family: var(--code-font);
  font-size: 14px;
  outline: none;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  border: none;
  font-size: 0.9rem;
  font-family: var(--ui-font);
  font-weight: 500;
  transition: all 0.2s;
}

.primary-btn {
  background-color: var(--accent-blue);
  color: white;
  width: 100%;
}

.primary-btn:hover {
  background-color: var(--accent-hover);
}

.success-btn {
  background-color: var(--success-color); /* Green play button */
  color: white;
  padding: 4px 12px;
  font-size: 0.8rem;
}

.success-btn:hover {
  filter: brightness(1.1);
}

.secondary-btn {
  background-color: transparent;
  color: #aaa;
  border: 1px solid #555;
  padding: 4px 10px;
  font-size: 0.8rem;
}

.secondary-btn:hover {
  background-color: rgba(255,255,255,0.1);
  color: white;
}