/* AI Prompt Editor Styles */

/* !important on display needed to override inline style="display:block" set by openCity() */
#PromptEditor[style*="block"] {
    display: flex !important;
    flex-direction: column;
    padding: 0 !important;
    overflow: hidden !important;
}

#prompt-editor-tab-placeholder {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#promptEditorLayout {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: #fff;
}

/* Menu Bar */
.prompt-menu-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
    min-height: 48px;
    flex-shrink: 0;
}

.prompt-menu-left,
.prompt-menu-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* File Dropdown */
.prompt-dropdown {
    position: relative;
}

.prompt-menu-btn {
    background: none;
    border: 1px solid #ddd;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
}

.prompt-menu-btn:hover {
    background: #e9ecef;
}

.prompt-dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 100;
    min-width: 140px;
}

.prompt-dropdown-content.show {
    display: block;
}

.prompt-dropdown-content a {
    display: block;
    padding: 8px 16px;
    color: #333;
    text-decoration: none;
    font-size: 13px;
}

.prompt-dropdown-content a:hover {
    background: #f0f0f0;
}

/* Prompt Name */
.prompt-name-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: #f0f0f0;
    border-radius: 4px;
}

.prompt-name-icon {
    color: #6c5ce7;
    font-size: 14px;
}

.prompt-name-text {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.prompt-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.prompt-status-dot.saved { background: #28a745; }
.prompt-status-dot.unsaved { background: #ffc107; }

/* Model Selector */
.prompt-model-selector {
    display: flex;
    align-items: center;
    gap: 6px;
}

.prompt-model-selector label {
    font-size: 12px;
    color: #666;
    margin: 0;
}

.prompt-model-selector select {
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    background: #fff;
    color: #333;
}

/* Buttons */
.prompt-btn {
    padding: 6px 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    color: #333;
    transition: all 0.15s;
}

.prompt-btn:hover { background: #e9ecef; }

.prompt-btn-save { color: #28a745; border-color: #28a745; }
.prompt-btn-save:hover { background: #28a745; color: #fff; }

.prompt-btn-run { color: #fff; background: #007bff; border-color: #007bff; }
.prompt-btn-run:hover { background: #0056b3; }
.prompt-btn-run:disabled { opacity: 0.5; cursor: not-allowed; }

.prompt-btn-chat { position: relative; }

.prompt-chat-badge {
    background: #6c5ce7;
    color: #fff;
    border-radius: 10px;
    padding: 1px 6px;
    font-size: 10px;
    margin-left: 4px;
}

/* System Prompt Info Strip */
.prompt-system-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: var(--surface, #f8fafc);
    border-bottom: 1px solid var(--border, #e2e8f0);
    font-size: 0.78rem;
    color: var(--text-secondary, #64748b);
}

.prompt-system-info i {
    color: #8b5cf6;
    font-size: 11px;
}

.prompt-system-info a {
    color: #8b5cf6;
    text-decoration: none;
    font-weight: 600;
}

.prompt-system-info a:hover {
    text-decoration: underline;
}

.dark-mode .prompt-system-info {
    background: #0d1117;
    border-bottom-color: #30363d;
}

/* Content Area */
.prompt-content-area {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* Prompt Editor Pane */
.prompt-editor-pane {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

#prompt-textarea {
    width: 100%;
    height: 100%;
    border: none;
    padding: 24px 32px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1.7;
    color: #333;
    background: #fff;
    resize: none;
    outline: none;
}

#prompt-textarea::placeholder {
    color: #aaa;
    font-style: italic;
}

/* Variable Reference Panel */
.prompt-variable-panel {
    width: 300px;
    border-left: 1px solid #e0e0e0;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
    flex-shrink: 0;
}

.prompt-var-header h4 {
    margin: 0 0 4px 0;
    font-size: 14px;
    color: #333;
}

.prompt-var-header p {
    margin: 0 0 12px 0;
    font-size: 11px;
    color: #666;
}

.prompt-var-section {
    margin-bottom: 16px;
}

.prompt-var-section h5 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    margin: 0 0 6px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid #e0e0e0;
}

.prompt-var-item {
    font-size: 12px;
    padding: 3px 0;
    color: #333;
}

.prompt-var-item code {
    background: #e9ecef;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 11px;
    color: #6c5ce7;
}

/* Chat Sidebar */
/* Chat Resizer */
#prompt-chat-resizer {
    width: 5px;
    cursor: col-resize;
    background: #ddd;
    border-left: 1px solid #ccc;
    border-right: 1px solid #ccc;
    flex-shrink: 0;
    transition: background 0.2s;
}

#prompt-chat-resizer:hover {
    background: #bbb;
}

#prompt-chat-resizer.prompt-chat-hidden {
    display: none;
}

#promptChatContainer {
    width: 420px;
    min-width: 280px;
    max-width: 700px;
    border-left: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    background: #fff;
    flex-shrink: 0;
}

#promptChatContainer.prompt-chat-hidden {
    display: none;
}

.prompt-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid #e0e0e0;
    font-weight: 600;
    font-size: 13px;
}

.prompt-chat-remaining {
    font-size: 11px;
    color: #888;
    font-weight: 400;
}

.prompt-chat-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #888;
    font-size: 14px;
}

.prompt-chat-disclaimer {
    padding: 8px 14px;
    font-size: 11px;
    color: #888;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.prompt-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.prompt-chat-msg-user,
.prompt-chat-msg-ai {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
}

.prompt-chat-msg-user {
    background: #007bff;
    color: #fff;
    margin-left: 40px;
    border-bottom-right-radius: 2px;
}

.prompt-chat-msg-ai {
    background: #f0f0f0;
    color: #333;
    margin-right: 40px;
    border-bottom-left-radius: 2px;
}

.prompt-chat-msg-content {
    word-wrap: break-word;
}

.prompt-chat-input-area {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e0e0e0;
}

.prompt-chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    outline: none;
    background: #fff;
    color: #333;
}

.prompt-chat-input:focus {
    border-color: #007bff;
}

.prompt-chat-send {
    background: #007bff;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13px;
}

.prompt-chat-send:hover {
    background: #0056b3;
}

/* ==========================================
   DARK MODE OVERRIDES
   ========================================== */

.dark-mode #PromptEditor,
.dark-mode #PromptEditor[style*="block"] {
    background-color: #0d1117 !important;
}

.dark-mode #promptEditorLayout {
    background: #0d1117;
}

.dark-mode .prompt-menu-bar {
    background: #161b22;
    border-bottom-color: #30363d;
}

.dark-mode .prompt-menu-btn {
    color: #c9d1d9;
    border-color: #30363d;
}

.dark-mode .prompt-menu-btn:hover {
    background: #21262d;
}

.dark-mode .prompt-dropdown-content {
    background: #161b22;
    border-color: #30363d;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.dark-mode .prompt-dropdown-content a {
    color: #c9d1d9;
}

.dark-mode .prompt-dropdown-content a:hover {
    background: #21262d;
}

.dark-mode .prompt-name-container {
    background: #21262d;
}

.dark-mode .prompt-name-text {
    color: #c9d1d9;
}

.dark-mode .prompt-model-selector label {
    color: #8b949e;
}

.dark-mode .prompt-model-selector select {
    background: #0d1117;
    color: #c9d1d9;
    border-color: #30363d;
}

.dark-mode .prompt-btn {
    background: #21262d;
    color: #c9d1d9;
    border-color: #30363d;
}

.dark-mode .prompt-btn:hover {
    background: #30363d;
}

.dark-mode .prompt-btn-save {
    color: #3fb950;
    border-color: #3fb950;
}

.dark-mode .prompt-btn-save:hover {
    background: #3fb950;
    color: #fff;
}

.dark-mode #prompt-textarea {
    background: #0d1117;
    color: #c9d1d9;
}

.dark-mode #prompt-textarea::placeholder {
    color: #6e7681;
}

.dark-mode .prompt-variable-panel {
    background: #161b22;
    border-left-color: #30363d;
}

.dark-mode .prompt-var-header h4 {
    color: #c9d1d9;
}

.dark-mode .prompt-var-header p {
    color: #8b949e;
}

.dark-mode .prompt-var-section h5 {
    color: #8b949e;
    border-bottom-color: #30363d;
}

.dark-mode .prompt-var-item {
    color: #c9d1d9;
}

.dark-mode .prompt-var-item code {
    background: #21262d;
    color: #bc8cff;
}

.dark-mode #prompt-chat-resizer {
    background: #30363d;
    border-left-color: #21262d;
    border-right-color: #21262d;
}

.dark-mode #prompt-chat-resizer:hover {
    background: #484f58;
}

.dark-mode #promptChatContainer {
    background: #0d1117;
    border-left-color: #30363d;
}

.dark-mode .prompt-chat-header {
    border-bottom-color: #30363d;
    color: #c9d1d9;
}

.dark-mode .prompt-chat-remaining {
    color: #8b949e;
}

.dark-mode .prompt-chat-close {
    color: #8b949e;
}

.dark-mode .prompt-chat-disclaimer {
    background: #161b22;
    color: #8b949e;
    border-bottom-color: #30363d;
}

.dark-mode .prompt-chat-msg-ai {
    background: #161b22;
    color: #c9d1d9;
}

.dark-mode .prompt-chat-input-area {
    border-top-color: #30363d;
}

.dark-mode .prompt-chat-input {
    background: #0d1117;
    color: #c9d1d9;
    border-color: #30363d;
}

.dark-mode .prompt-chat-input:focus {
    border-color: #58a6ff;
}
