/* Modals */

/* Template Browser */
.modal-content.template-browser-content { width: 1100px; max-width: 95vw; max-height: 95vh; }
.template-browser-content .modal-body { overflow-y: auto; max-height: calc(95vh - 100px); }
.template-cards-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.template-card { background: var(--bg-dark); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; cursor: pointer; transition: border-color .18s, transform .18s; }
.template-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.template-card-preview { height: 420px; background: linear-gradient(135deg, var(--bg-panel) 0%, var(--bg-dark) 100%); display: flex; align-items: center; justify-content: center; border-bottom: 1px solid var(--border); overflow: hidden; }
.template-card-img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.tpl-icon { font-size: 3rem; }
.template-card-info { padding: 10px 12px; }
.template-card-name { font-size: 13px; font-weight: 600; color: var(--text-main); margin: 0; }

/* Template Font Dropdown */
.tpl-font-dropdown { position: relative; width: 100%; }
.tpl-font-dropdown-toggle { display: flex; align-items: center; gap: 8px; width: 100%; background: var(--input-bg); border: 1px solid var(--border); color: var(--text-main); font-size: 12px; border-radius: var(--radius); padding: 5px 7px; cursor: pointer; text-align: left; }
.tpl-font-dropdown-toggle:hover { border-color: var(--accent); }
.tpl-font-selected-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-font-selected-preview { font-size: 15px; line-height: 1; opacity: 0.85; flex-shrink: 0; }
.tpl-font-arrow { font-size: 10px; color: var(--text-muted); flex-shrink: 0; }
.tpl-font-dropdown-list { position: absolute; top: 100%; left: 0; right: 0; max-height: 240px; overflow-y: auto; background: var(--bg-dark); border: 1px solid var(--border); border-radius: var(--radius); margin-top: 2px; z-index: 120; box-shadow: 0 8px 24px var(--shadow-color); }
.tpl-font-dropdown-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; cursor: pointer; font-size: 12px; color: var(--text-main); }
.tpl-font-dropdown-item:hover { background: var(--accent); color: #fff; }
.tpl-font-item-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* AI Project Builder Modal */
.ai-project-modal-content { width: 520px; max-height: 90vh; overflow-y: auto; }
.ai-project-presets-row { display: flex; gap: 12px; }
.ai-project-presets-row .helper-section { flex: 1; }
.ai-project-presets-row select { width: 100%; background: var(--input-bg); border: 1px solid var(--border); color: var(--text-main); font-size: 12px; border-radius: var(--radius); padding: 5px 7px; }
.ai-project-theme-swatches { display: flex; gap: 6px; padding: 4px 0 2px; }
.theme-swatch { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.15); flex-shrink: 0; }
#ai-project-status { margin-top: 4px; }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-content { background: var(--bg-panel); width: 400px; max-width: 90%; border-radius: 6px; border: 1px solid var(--border); box-shadow: 0 20px 50px var(--shadow-color); display: flex; flex-direction: column; overflow: hidden; }
.modal-content.large-modal { width: 600px; }
.modal-header { padding: 12px 15px; background: var(--bg-dark); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h4 { font-size: 14px; margin: 0; }
.btn-close-modal { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 20px; line-height: 1; }
.modal-body { padding: 15px; display: flex; flex-direction: column; gap: 15px; }
.modal-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 5px; }
.helper-section label { display: block; font-size: 11px; color: var(--text-main); margin-bottom: 5px; font-weight: bold; }
.helper-section select { width: 100%; background: var(--input-bg); border: 1px solid var(--border); color: #ce9178; font-family: monospace; font-size: 12px; border-radius: var(--radius); padding: 5px; }
.helper-section select option { padding: 4px; }
.helper-section.h-100 { display: flex; flex-direction: column; height: 100%; }
.row-split { display: flex; gap: 15px; }
.col-half { flex: 1; display: flex; flex-direction: column; gap: 15px; }
.code-preview { background: #111; border: 1px solid var(--border); padding: 10px; font-family: monospace; font-size: 13px; color: #ce9178; border-radius: var(--radius); min-height: 40px; display: flex; align-items: center; word-break: break-all; }
.args-actions { display: flex; gap: 5px; }
.actions-col { display: flex; flex-direction: column; gap: 5px; }

#event-helper-modal select::-webkit-scrollbar { width: 8px; background: var(--bg-dark); }
#event-helper-modal select::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }

/* Image Preview Modal */
.image-modal-content {
    background: transparent;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    position: relative;
    align-items: center;
}
.image-preview-header {
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    margin-bottom: 10px;
    font-size: 13px;
    font-family: monospace;
}
.image-preview-body {
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(#333 1px, transparent 1px);
    background-size: 10px 10px;
    background-color: #222;
    padding: 20px;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    border: 1px solid #444;
}
.image-preview-body img {
    max-width: 80vw;
    max-height: 80vh;
    display: block;
    object-fit: contain;
}
.close-image-modal {
    position: absolute;
    top: -40px;
    right: -40px;
    color: #fff;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}
.close-image-modal:hover {
    color: #ccc;
}

/* Text Toolbar */
#text-toolbar { position: fixed; z-index: 1000; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 4px 20px var(--shadow-color); display: flex; gap: 8px; padding: 5px 8px; align-items: center; animation: fadeIn 0.15s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.toolbar-group { display: flex; gap: 2px; align-items: center; border-right: 1px solid var(--border); padding-right: 8px; }
.toolbar-group:last-of-type { border-right: none; padding-right: 0; }
#text-toolbar button { background: transparent; border: 1px solid transparent; border-radius: 3px; color: var(--text-main); cursor: pointer; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; font-size: 14px; }
#text-toolbar button:hover { background: var(--hover-bg-strong); }
#text-toolbar button.active { background: var(--accent); color: white; }
.color-wrap { position: relative; width: 28px; height: 28px; border: 1px solid transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 3px; }
.color-wrap:hover { background: var(--hover-bg-strong); }
.color-wrap span { font-weight: bold; font-size: 13px; }
.color-wrap input[type="color"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
#text-toolbar select { background: var(--bg-dark); border: 1px solid var(--border); color: var(--text-main); padding: 2px 4px; border-radius: 3px; font-size: 11px; height: 24px; }
.btn-close-toolbar { margin-left: 5px; color: var(--text-muted) !important; font-size: 18px !important; line-height: 1; }
.btn-close-toolbar:hover { color: #e5534b !important; }

/* Global Block Modal */
.gb-modal-overlay {
    z-index: 200;
    animation: fadeIn 0.12s ease-out;
}
.gb-modal {
    width: 380px;
    animation: gbModalIn 0.15s ease-out;
}
@keyframes gbModalIn {
    from { opacity: 0; transform: translateY(-10px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.gb-modal .modal-header h4 {
    display: flex;
    align-items: center;
    gap: 8px;
}
.gb-modal-message {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}
.gb-modal-input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    font-size: 13px;
    padding: 8px 10px;
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.15s;
}
.gb-modal-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.25);
}
.gb-modal-error {
    font-size: 12px;
    color: #e5534b;
    padding: 6px 10px;
    background: rgba(229, 83, 75, 0.1);
    border: 1px solid rgba(229, 83, 75, 0.3);
    border-radius: var(--radius);
    margin-top: 2px;
}
.gb-modal-footer {
    padding: 10px 15px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: var(--bg-dark);
}
.gb-modal-btn {
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.gb-modal-btn:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
.gb-modal-btn-secondary {
    background: transparent;
    color: var(--text-muted);
}
.gb-modal-btn-secondary:hover {
    background: var(--hover-bg-strong);
    color: var(--text-main);
}
.gb-modal-btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}
.gb-modal-btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}
.gb-modal-btn-primary:disabled {
    background: #3a3a3a;
    border-color: #3a3a3a;
    color: #666;
    cursor: not-allowed;
    opacity: 0.6;
}
.gb-modal-btn-danger {
    background: #c93c37;
    border-color: #c93c37;
    color: white;
}
.gb-modal-btn-danger:hover {
    background: #e5534b;
    border-color: #e5534b;
}
.gb-modal-btn-danger:disabled {
    background: #3a3a3a;
    border-color: #3a3a3a;
    color: #666;
    cursor: not-allowed;
}
.gb-modal-btn-success {
    background: #2ea043;
    border-color: #2ea043;
    color: white;
}
.gb-modal-btn-success:hover {
    background: #22863a;
    border-color: #22863a;
}
.gb-modal-warning {
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(229, 83, 75, 0.1);
    border: 1px solid rgba(229, 83, 75, 0.3);
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--text-main);
    line-height: 1.5;
}
.gb-modal-warning strong {
    color: #e5534b;
}
.library-import-warning-modal {
    width: 440px;
}
.library-import-warning-note {
    margin-top: 12px;
    border-left: 3px solid #e5534b;
    background: rgba(229, 83, 75, 0.12);
}
.gb-modal-page-list {
    list-style: none;
    margin: 6px 0;
    padding: 0;
}
.gb-modal-page-list li {
    padding: 3px 0 3px 16px;
    position: relative;
    font-family: monospace;
    font-size: 11px;
    color: var(--text-muted);
}
.gb-modal-page-list li::before {
    content: '•';
    position: absolute;
    left: 4px;
    color: var(--text-muted);
}

/* Delete Folder Confirmation Modal */
.delete-folder-modal-content {
    width: 420px;
    animation: gbModalIn 0.15s ease-out;
}

.delete-folder-confirm-wrap {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.delete-folder-confirm-label {
    font-size: 12px;
    color: var(--text-muted);
}

.delete-folder-confirm-label code {
    background: rgba(255,255,255,0.1);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
    color: var(--text-main);
    font-family: monospace;
}

/* Context Menu */
.context-menu { position: fixed; z-index: 2000; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 4px; box-shadow: 0 5px 15px var(--shadow-color); width: 160px; padding: 4px 0; animation: fadeIn 0.1s ease-out; }
.menu-options { list-style: none; margin: 0; padding: 0; }
.menu-item { padding: 8px 15px; font-size: 12px; color: var(--text-main); cursor: pointer; display: flex; align-items: center; gap: 8px; }
.menu-item:hover { background: var(--accent); color: white; }
.menu-item.text-danger:hover { background: #e5534b; }
.menu-item.disabled { color: var(--text-muted); pointer-events: none; opacity: 0.5; }
.menu-separator { height: 1px; background: var(--border); margin: 4px 0; }

/* Language Selection Modal */
.i18n-search-wrap {
    margin-bottom: 12px;
}

.i18n-search-wrap input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 8px 10px;
    border-radius: var(--radius);
    font-size: 13px;
}

.i18n-lang-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    background: var(--bg-dark);
}

.i18n-lang-list::-webkit-scrollbar {
    width: 8px;
    background: var(--bg-dark);
}

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

.i18n-lang-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.i18n-lang-item {
    display: flex;
    align-items: center;
    padding: 8px;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.12s;
}

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

.i18n-lang-item input[type="checkbox"] {
    margin-right: 10px;
    cursor: pointer;
}

.i18n-lang-name {
    flex: 1;
    font-size: 13px;
    color: var(--text-main);
}

.i18n-lang-native {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 8px;
}

/* Language Preview Selector */
.lang-preview-selector {
    display: flex;
    align-items: center;
    margin-left: 0;
}

.lang-preview-selector select {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-main);
    height: 30px;
    padding: 0 10px;
    border-radius: var(--radius);
    font-size: 13px;
    cursor: pointer;
}

.lang-preview-selector select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* CMS Modal */
.cms-modal-content {
    width: 900px;
    max-width: 95%;
    max-height: 90vh;
}

.cms-modal-body {
    max-height: 70vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cms-text-list::-webkit-scrollbar {
    width: 8px;
    background: var(--bg-dark);
}

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

.cms-text-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.cms-toolbar {
    display: flex;
    gap: 10px;
    padding-bottom: 15px;
    flex-shrink: 0;
}

.cms-toolbar input,
.cms-toolbar select {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 8px;
    border-radius: var(--radius);
    font-size: 12px;
}

.cms-text-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.cms-text-item {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
}

.cms-text-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.cms-text-meta {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.cms-text-location {
    font-family: monospace;
    color: var(--accent);
    font-size: 11px;
}

.cms-text-tag {
    background: rgba(255,255,255,0.1);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-family: monospace;
    color: var(--text-muted);
}

.cms-translations {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cms-translation-row {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 10px;
    align-items: start;
}

.cms-translation-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    padding-top: 6px;
}

.cms-translation-input {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 6px 8px;
    border-radius: 3px;
    font-size: 12px;
    resize: vertical;
    min-height: 32px;
    font-family: inherit;
}

.cms-translation-input:focus {
    border-color: var(--accent);
    outline: none;
}

.cms-btn-jump {
    background: var(--accent);
    border: none;
    color: white;
    padding: 5px 12px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: background 0.12s;
}

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

.cms-text-list:empty::after {
    content: 'No text elements found. Click "Scan All Pages" to find text.';
    display: block;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* HTML Code Editor Modal */
.html-editor-modal-content {
    width: 1200px;
    max-width: 95%;
    max-height: 95vh;
    height: 85vh;
}

.html-editor-modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    overflow: hidden;
}

.html-editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border);
}

.html-editor-info {
    font-size: 12px;
    color: var(--text-muted);
}

.html-editor-format-btn {
    background: var(--accent);
    border: 1px solid var(--accent);
    color: white;
    padding: 5px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.12s;
}

.html-editor-format-btn:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.html-editor-format-btn svg {
    flex-shrink: 0;
}

.html-editor-container {
    flex: 1;
    position: relative;
    min-height: 400px;
    background: #1e1e1e;
    overflow: hidden;
}

.html-code-highlight {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: 15px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-y: auto;
    overflow-x: auto;
    background: #1e1e1e;
    color: #d4d4d4;
    pointer-events: none;
    tab-size: 2;
    -moz-tab-size: 2;
}

.html-code-highlight code {
    display: block;
    min-height: 100%;
}

.html-code-editor {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    color: #d4d4d4;
    padding: 15px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: none;
    outline: none;
    tab-size: 2;
    -moz-tab-size: 2;
    white-space: pre-wrap;
    word-wrap: break-word;
    caret-color: #d4d4d4;
    -webkit-text-fill-color: transparent;
}

.html-code-editor::-webkit-scrollbar,
.html-code-highlight::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.html-code-editor::-webkit-scrollbar-track,
.html-code-highlight::-webkit-scrollbar-track {
    background: #1e1e1e;
}

.html-code-editor::-webkit-scrollbar-thumb,
.html-code-highlight::-webkit-scrollbar-thumb {
    background: #424242;
    border-radius: 5px;
}

.html-code-editor::-webkit-scrollbar-thumb:hover,
.html-code-highlight::-webkit-scrollbar-thumb:hover {
    background: #4e4e4e;
}

/* Syntax highlighting colors (VSCode dark theme) */
.html-code-highlight .hl-tag {
    color: #569cd6;
}

.html-code-highlight .hl-attr-name {
    color: #9cdcfe;
}

.html-code-highlight .hl-attr-value {
    color: #ce9178;
}

.html-code-highlight .hl-text {
    color: #d4d4d4;
}

.html-code-highlight .hl-comment {
    color: #6a9955;
    font-style: italic;
}

.html-code-highlight .hl-bracket {
    color: #808080;
}

/* Image Version Picker */
.version-picker-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 400px;
    overflow-y: auto;
}
.version-picker-list::-webkit-scrollbar { width: 8px; background: var(--bg-dark); }
.version-picker-list::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }

.version-picker-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    background: var(--bg-dark);
}
.version-picker-item:hover {
    background: rgba(0, 122, 204, 0.15);
    border-color: var(--accent);
}

.version-picker-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 3px;
    background: #111;
    flex-shrink: 0;
}

.version-picker-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.version-picker-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    font-family: monospace;
}

.version-picker-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.version-picker-size {
    font-size: 11px;
    color: var(--accent);
    font-weight: 600;
}

/* Image Group Badge */
.image-group-badge {
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 9px;
    background: var(--accent);
    color: white;
    padding: 1px 5px;
    border-radius: 3px;
    z-index: 4;
    line-height: 1.4;
    font-weight: 600;
}

/* AI Assistant Modal */
.ai-modal-content {
    width: 560px;
    max-width: 95%;
}

.ai-model-search {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    font-size: 12px;
    padding: 6px 8px;
    border-radius: var(--radius);
    outline: none;
    margin-bottom: 6px;
    transition: border-color 0.15s;
}

.ai-selected-model-input {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--ai-model-select);
    font-family: monospace;
    font-size: 12px;
    padding: 6px 8px;
    border-radius: var(--radius);
    margin-bottom: 6px;
}

.ai-selected-model-input[readonly] {
    cursor: default;
}

.ai-model-search:focus {
    border-color: var(--accent);
}

#ai-model-select {
    width: 100%;
    max-height: 180px;
    overflow-y: auto;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--ai-model-select);
    font-family: monospace;
    font-size: 12px;
    border-radius: var(--radius);
    padding: 2px;
}

#ai-model-select option {
    padding: 5px 8px;
    cursor: pointer;
}

#ai-model-select option:checked {
    background: var(--accent-light2);
    color: white;
}

#ai-model-select::-webkit-scrollbar {
    width: 8px;
    background: var(--bg-dark);
}

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

#ai-model-select::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.ai-prompt-textarea {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    font-size: 13px;
    padding: 10px;
    border-radius: var(--radius);
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.15s;
}

.ai-prompt-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.25);
}

.ai-toggles {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.ai-toggle-label {
    font-size: 13px;
    color: var(--text-main);
}

.ai-toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.ai-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.ai-toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #444;
    border-radius: 22px;
    transition: background 0.2s;
}

.ai-toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

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

.ai-toggle-switch input:checked + .ai-toggle-slider::before {
    transform: translateX(18px);
}

.ai-linked-info {
    font-size: 11px;
    color: var(--text-muted);
    padding: 6px 0;
    line-height: 1.5;
}

.ai-status-msg {
    font-size: 12px;
    padding: 8px 12px;
    border-radius: var(--radius);
    line-height: 1.5;
}

.ai-status-loading {
    background: rgba(0, 122, 204, 0.1);
    border: 1px solid rgba(0, 122, 204, 0.3);
    color: var(--accent);
}

.ai-status-success {
    background: rgba(46, 160, 67, 0.1);
    border: 1px solid rgba(46, 160, 67, 0.3);
    color: #2ea043;
}

.ai-status-error {
    background: rgba(229, 83, 75, 0.1);
    border: 1px solid rgba(229, 83, 75, 0.3);
    color: #e5534b;
}

/* CMS AI Modal */
.cms-ai-modal-content {
    width: 500px;
    max-width: 95%;
}

/* CMS toolbar AI button */
.btn-cms-ai {
    background: rgba(0, 122, 204, 0.12);
    border: 1px solid rgba(0, 122, 204, 0.45);
    color: var(--accent);
    padding: 6px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.12s, border-color 0.12s;
    flex-shrink: 0;
}

.btn-cms-ai:hover {
    background: rgba(0, 122, 204, 0.25);
    border-color: var(--accent);
}

/* CMS header actions wrapper */
.cms-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Per-element AI button in CMS list */
.cms-btn-ai {
    background: rgba(0, 122, 204, 0.1);
    border: 1px solid rgba(0, 122, 204, 0.35);
    color: var(--accent);
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: background 0.12s;
    white-space: nowrap;
}

.cms-btn-ai:hover {
    background: rgba(0, 122, 204, 0.22);
}

/* API Key section in auth popup */
.auth-apikey-status {
    font-size: 12px;
    padding: 4px 0 8px;
    color: var(--text-muted);
}

.auth-apikey-status .apikey-saved {
    color: #2ea043;
}

.auth-apikey-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}
