/* 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-browser-content .modal-body {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--bg-dark);
}
.template-browser-content .modal-body::-webkit-scrollbar {
    width: 10px;
}
.template-browser-content .modal-body::-webkit-scrollbar-track {
    background: var(--bg-dark);
    border-left: 1px solid var(--border);
}
.template-browser-content .modal-body::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
    border: 2px solid var(--bg-dark);
}
.template-browser-content .modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}
.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: 600px; 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 */
#template-setup-modal .modal-content { overflow: visible; }
#template-setup-modal .modal-body { overflow: visible; }
.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: 1200; box-shadow: 0 8px 24px var(--shadow-color); }
.tpl-font-dropdown-list { scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) var(--bg-dark); }
.tpl-font-dropdown-list::-webkit-scrollbar { width: 8px; }
.tpl-font-dropdown-list::-webkit-scrollbar-track { background: var(--bg-dark); border-left: 1px solid var(--border); border-radius: 0 var(--radius) var(--radius) 0; }
.tpl-font-dropdown-list::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 999px; border: 2px solid var(--bg-dark); }
.tpl-font-dropdown-list::-webkit-scrollbar-thumb:hover { background: var(--accent); }
.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; }
.tpl-theme-selected-swatches { flex-shrink: 0; }
.tpl-theme-item-swatches { margin-left: auto; flex-shrink: 0; }

/* AI Project Builder Modal */
.modal-content.ai-project-modal-content { width: 660px; max-width: 94vw; max-height: 90vh; overflow-y: auto; }
.modal-content.ai-project-modal-content {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--bg-dark);
}
.modal-content.ai-project-modal-content::-webkit-scrollbar {
    width: 10px;
}
.modal-content.ai-project-modal-content::-webkit-scrollbar-track {
    background: var(--bg-dark);
    border-left: 1px solid var(--border);
}
.modal-content.ai-project-modal-content::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
    border: 2px solid var(--bg-dark);
}
.modal-content.ai-project-modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}
.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; }
.preset-swatches { display: flex; gap: 2px; }
.preset-swatch { width: 11px; height: 11px; border-radius: 2px; border: 1px solid rgba(255, 255, 255, 0.12); display: inline-block; 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: 2000; }
#text-link-modal,
#button-event-modal { z-index: 2100; }
#event-helper-modal { z-index: 2200; }
#section-content-discard-modal { z-index: 3000; }
#section-content-remove-attr-modal { z-index: 2350; }
#cms-ai-modal { z-index: 2400; }
#svg-icon-editor-modal { z-index: 2400; }
#add-custom-svg-modal { z-index: 2500; }
.modal-content { background: var(--bg-panel); width: 500px; 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; }
.btn.btn-event-helper{
    background-color: var(--accent-light);
    
}
.btn.btn-event-helper:hover{
    background-color: var(--accent);
    
}


/* 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: 2000;
    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;
}
.convert-element-dialog {
    width: 420px;
}
.convert-element-dialog__hero {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 4px 0 2px;
}
.convert-element-dialog__icon {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    background: rgba(0, 122, 204, 0.12);
    border: 1px solid rgba(0, 122, 204, 0.22);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    flex: 0 0 auto;
}
.convert-element-dialog__copy {
    min-width: 0;
}
.convert-element-dialog__eyebrow {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.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-input.input-invalid {
    border-color: #e5534b;
    box-shadow: 0 0 0 2px rgba(229, 83, 75, 0.2);
}
.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;
}

/* Remove Languages Warning Modal */
.remove-lang-warning-modal {
    width: 440px;
    animation: gbModalIn 0.15s ease-out;
}
.remove-lang-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: rgba(201, 60, 55, 0.08);
}
.remove-lang-list li {
    padding: 6px 12px;
    font-size: 12px;
    color: var(--text-main);
    border-bottom: 1px solid var(--border);
}
.remove-lang-list li:last-child {
    border-bottom: none;
}

/* Context Menu */
.context-menu { position: fixed; z-index: 2000; box-sizing: border-box; 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; overflow-x: hidden; overflow-y: auto; 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; white-space: nowrap; }
.menu-item:hover { background: var(--accent); color: white; }
.menu-item-has-flyout { justify-content: space-between; }
.menu-item-has-flyout.active { background: var(--accent); color: white; }
.menu-flyout-caret { margin-left: auto; font-size: 10px; line-height: 1; }
.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; }
.context-flyout-menu { width: 180px; }

#folder-context-menu {
    width: max-content;
    min-width: 160px;
    max-width: min(280px, calc(100vw - 16px));
}

/* Premium-gated context menu items */
.menu-item.menu-item-gated {
    color: var(--text-muted);
    opacity: 0.5;
    cursor: default;
    position: relative;
}
.menu-item.menu-item-gated:hover {
    background: transparent;
    color: var(--text-muted);
}
.ctx-gated-tooltip {
    display: none;
}
.menu-item.menu-item-gated:hover .ctx-gated-tooltip {
    display: block;
    position: absolute;
    left: calc(100% + 4px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 2001;
    pointer-events: none;
}

#context-menu {
    width: 190px;
}

#element-insert-heading-menu {
    width: 88px;
}

.element-insert-grid-config {
    min-width: 148px;
}

.element-insert-grid-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}

.element-insert-grid-apply {
    border: 0;
    border-radius: 4px;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 6px 10px;
    cursor: pointer;
}

.element-insert-grid-apply:hover {
    filter: brightness(1.06);
}

/* 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-left: 0px;
    border-bottom: 0px;
    border-top: 0px;
    border-right: 1px solid var(--border);

    color: var(--text-main);
    height: 38px;
    padding: 0 10px;
    margin-right:2px;
    /* 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;
    flex-wrap: wrap;
    align-items: center;
}

.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-toolbar #cms-search {
    flex: 1 1 260px;
    min-width: 220px;
}

.cms-toolbar #cms-filter-page {
    flex: 0 1 220px;
    min-width: 180px;
}

.cms-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-dark);
    color: var(--text-main);
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
    transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.cms-filter-toggle:hover {
    background: rgba(0, 122, 204, 0.06);
    border-color: rgba(0, 122, 204, 0.45);
}

.cms-filter-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
}

.cms-filter-toggle-check {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid rgba(0, 122, 204, 0.45);
    background: var(--input-bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.cms-filter-toggle-check::after {
    content: '';
    width: 8px;
    height: 4px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) translate(1px, -1px);
    opacity: 0;
    transition: opacity 0.12s;
}

.cms-filter-toggle input:checked + .cms-filter-toggle-check {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 122, 204, 0.16);
}

.cms-filter-toggle input:checked + .cms-filter-toggle-check::after {
    opacity: 1;
}

.cms-filter-toggle input:focus-visible + .cms-filter-toggle-check {
    box-shadow: 0 0 0 3px rgba(0, 122, 204, 0.16);
}

.cms-filter-toggle-label {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.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-item-global {
    border-color: rgba(0, 122, 204, 0.28);
    box-shadow: inset 3px 0 0 rgba(0, 122, 204, 0.5);
}

.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-text-source-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 999px;
    border: 1px solid rgba(0, 122, 204, 0.28);
    background: rgba(0, 122, 204, 0.12);
    color: var(--accent);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.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;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--input-bg);
}

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

.cms-translation-input::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.cms-translation-input::-webkit-scrollbar-track {
    background: var(--input-bg);
    border-left: 1px solid var(--border);
    border-radius: 0 3px 3px 0;
}

.cms-translation-input::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
    border: 2px solid var(--input-bg);
}

.cms-translation-input::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

.cms-translation-input::-webkit-scrollbar-button:single-button {
    display: block;
    height: 10px;
    background-color: var(--bg-dark);
    background-position: center;
    background-repeat: no-repeat;
    background-size: 6px 6px;
    border-left: 1px solid var(--border);
}

.cms-translation-input::-webkit-scrollbar-button:single-button:vertical:decrement {
    border-bottom: 1px solid var(--border);
    background-image: linear-gradient(135deg, transparent 50%, var(--text-muted) 50%), linear-gradient(225deg, transparent 50%, var(--text-muted) 50%);
    background-position: calc(50% - 2px) 55%, calc(50% + 2px) 55%;
    background-size: 5px 5px;
}

.cms-translation-input::-webkit-scrollbar-button:single-button:vertical:increment {
    border-top: 1px solid var(--border);
    background-image: linear-gradient(315deg, transparent 50%, var(--text-muted) 50%), linear-gradient(45deg, transparent 50%, var(--text-muted) 50%);
    background-position: calc(50% - 2px) 45%, calc(50% + 2px) 45%;
    background-size: 5px 5px;
}

.cms-translation-input::-webkit-scrollbar-button:single-button:hover {
    background-color: rgba(0, 122, 204, 0.12);
}

.cms-translation-input::-webkit-scrollbar-corner {
    background: var(--input-bg);
}

.cms-translation-input::-webkit-resizer {
    background:
        linear-gradient(135deg,
            transparent 0 52%,
            rgba(255, 255, 255, 0.18) 52% 60%,
            transparent 60% 70%,
            rgba(255, 255, 255, 0.18) 70% 78%,
            transparent 78% 100%);
}

.cms-btn-jump {
    background: var(--accent-light);
    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-btn-jump:disabled {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    cursor: not-allowed;
}

.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;
}

/* Section Content Editor Modal */
.section-content-modal-content {
    width: 980px;
    max-width: 96%;
    height: min(90vh, 820px);
    max-height: 90vh;
}

.section-content-modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
    overflow: hidden;
}

.section-content-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.section-content-tab {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 9px 12px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    transition: border-color 0.12s, background 0.12s, color 0.12s, transform 0.12s;
}

.section-content-tab:hover {
    border-color: rgba(91, 196, 66, 0.45);
    color: var(--text-main);
    transform: translateY(-1px);
}

.section-content-tab.active {
    background: linear-gradient(135deg, rgba(91, 196, 66, 0.2), rgba(0, 122, 204, 0.18));
    border-color: rgba(91, 196, 66, 0.55);
    color: var(--text-main);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.section-content-panels {
    flex: 1;
    min-height: 0;
    display: flex;
    overflow: hidden;
}

.section-content-panel {
    display: none;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--bg-dark);
}

.section-content-panel.active {
    display: block;
}

.section-content-panel[data-panel="texts"] {
    overflow: hidden;
}

.section-content-panel[data-panel="texts"].active {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.section-content-modal-footer {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    box-shadow: 0 -10px 24px rgba(0, 0, 0, 0.16);
}

.section-content-discard-modal-content {
    width: 460px;
    max-width: 92%;
    z-index:2800;
}

.section-content-discard-warning {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-top: 0;
}

.section-content-discard-warning svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: #f0b429;
}

.section-content-discard-warning p {
    margin: 0;
}

.section-content-panel::-webkit-scrollbar {
    width: 8px;
    background: var(--bg-dark);
}

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

.section-content-panel::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.section-content-list,
.section-content-action-list,
.section-content-source-list,
.section-content-icon-list,
.section-content-data-attr-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.section-content-panel[data-panel="texts"] .section-content-list {
    flex: 1;
    min-height: 0;
}

.section-content-text-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding-right: 4px;
}

.section-content-text-item .cms-text-header {
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.section-content-text-item .cms-text-meta {
    flex: 1 1 260px;
    min-width: 0;
    flex-wrap: wrap;
    row-gap: 6px;
}

.section-content-text-item .cms-text-meta span:last-child {
    flex: 1 1 100%;
    margin-left: 0 !important;
    word-break: break-word;
}

.section-content-text-item-actions {
    margin-left: auto;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.section-content-empty {
    padding: 34px 18px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.section-content-action-item {
    width: 100%;
    background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
    border: 1px solid var(--border);
    color: inherit;
    border-radius: calc(var(--radius) + 2px);
    padding: 14px 16px;
    text-align: left;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s, background 0.12s;
}

.section-content-action-item:hover {
    border-color: rgba(91, 196, 66, 0.45);
    background: linear-gradient(180deg, rgba(91, 196, 66, 0.11), rgba(0, 122, 204, 0.07));
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

.section-content-action-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.section-content-action-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.section-content-action-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.section-content-action-tag {
    font-family: monospace;
    font-size: 11px;
    color: #9ee37d;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.section-content-action-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    word-break: break-word;
}

.section-content-action-meta {
    font-size: 12px;
    color: var(--text-muted);
    word-break: break-word;
    line-height: 1.45;
}

.section-content-action-open {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
}

.section-content-source-item {
    background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 2px);
    padding: 14px 16px;
}

.section-content-icon-item,
.section-content-data-group {
    background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 2px);
    padding: 14px 16px;
}

.section-content-icon-item {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
}

.section-content-icon-preview {
    width: 72px;
    height: 72px;
    border-radius: calc(var(--radius) + 1px);
    border: 1px solid var(--border);
    background:
        linear-gradient(135deg, rgba(91, 196, 66, 0.08), rgba(0, 122, 204, 0.08)),
        var(--input-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.section-content-icon-preview svg {
    max-width: 42px;
    max-height: 42px;
    width: auto;
    height: auto;
}

.section-content-icon-body {
    min-width: 0;
}

.section-content-icon-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
    word-break: break-word;
}

.section-content-data-group-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.section-content-data-group-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    word-break: break-word;
}

.section-content-data-rows {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.section-content-data-row {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.02);
}

.section-content-data-row-main {
    display: grid;
    grid-template-columns: minmax(180px, 0.85fr) minmax(0, 1.15fr) auto;
    gap: 10px;
    align-items: end;
}

.section-content-data-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.section-content-data-row .input-wrap {
    margin: 0;
}

.section-content-data-row label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.section-content-data-row input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 9px 10px;
    border-radius: var(--radius);
    font-size: 12px;
}

.section-content-data-row input:focus {
    border-color: var(--accent);
    outline: none;
}

.section-content-data-remove {
    align-self: auto;
}

.section-content-data-i18n-toggle {
    min-height: 34px;
    padding: 0 8px;
}

.section-content-data-i18n {
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--input-bg);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-content-data-i18n-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.section-content-data-i18n-row {
    display: grid;
    grid-template-columns: 60px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.section-content-data-i18n-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.section-content-data-i18n-note {
    font-size: 11px;
    color: var(--text-muted);
    margin: 0;
}

.section-content-source-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.section-content-source-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
}

.section-content-source-controls .input-wrap {
    margin: 0;
}

.section-content-source-controls label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.section-content-source-controls input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 9px 10px;
    border-radius: var(--radius);
    font-size: 12px;
}

.section-content-source-controls input:focus {
    border-color: var(--accent);
    outline: none;
}

@media (max-width: 720px) {
    .section-content-modal-body {
        min-height: 420px;
    }

    .section-content-icon-item,
    .section-content-data-row-main,
    .section-content-data-i18n-row,
    .section-content-source-controls {
        grid-template-columns: 1fr;
    }

    .section-content-icon-item {
        grid-template-columns: 1fr;
    }

    .section-content-icon-preview {
        width: 64px;
        height: 64px;
    }

    .cms-translation-row {
        grid-template-columns: 1fr;
    }
}

/* HTML Code Editor Modal */
.html-editor-modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
    background: var(--bg-panel);
}

.html-editor-modal-content {
    width: 100%;
    max-width: none;
    max-height: none;
    height: 100%;
    border-radius: 0;
    border: none;
    box-shadow: none;
    flex: 1;
}

.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;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 15px;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border);
}

.html-editor-info {
    flex: 1;
    min-width: 240px;
    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: 0;
    background: #1e1e1e;
    overflow: hidden;
}

.html-code-monaco {
    position: absolute;
    inset: 0;
    display: none;
}

.html-editor-container.monaco-active .html-code-monaco {
    display: block;
}

.html-editor-container.monaco-active .html-code-highlight,
.html-editor-container.monaco-active .html-code-editor {
    display: none;
}

.html-editor-container.monaco-loading::after {
    content: 'Loading Monaco editor...';
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.88);
    color: #cbd5e1;
    font-size: 11px;
    letter-spacing: 0.02em;
}

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

.html-code-highlight code {
    display: inline-block;
    min-height: 100%;
    min-width: 100%;
    width: max-content;
}

.html-code-editor {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    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;
    word-wrap: normal;
    overflow-wrap: normal;
    overflow: auto;
    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,
#cms-ai-model-select,
#ai-project-model-select,
#enhance-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;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--bg-dark);
}

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

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

#ai-model-select::-webkit-scrollbar,
#cms-ai-model-select::-webkit-scrollbar,
#ai-project-model-select::-webkit-scrollbar,
#enhance-model-select::-webkit-scrollbar {
    width: 10px;
}

#ai-model-select::-webkit-scrollbar-track,
#cms-ai-model-select::-webkit-scrollbar-track,
#ai-project-model-select::-webkit-scrollbar-track,
#enhance-model-select::-webkit-scrollbar-track {
    background: var(--bg-dark);
    border-left: 1px solid var(--border);
    border-radius: 0 var(--radius) var(--radius) 0;
}

#ai-model-select::-webkit-scrollbar-thumb,
#cms-ai-model-select::-webkit-scrollbar-thumb,
#ai-project-model-select::-webkit-scrollbar-thumb,
#enhance-model-select::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
    border: 2px solid var(--bg-dark);
}

#ai-model-select::-webkit-scrollbar-thumb:hover,
#cms-ai-model-select::-webkit-scrollbar-thumb:hover,
#ai-project-model-select::-webkit-scrollbar-thumb:hover,
#enhance-model-select::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

.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-element-context-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ai-element-context-note {
    margin: 0;
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-muted);
    padding: 0 2px;
}

.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-helper-msg {
    margin-top: 8px;
    font-size: 11px;
}

.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;
}

.ai-status-warning {
    background: rgba(184, 134, 11, 0.12);
    border: 1px solid rgba(184, 134, 11, 0.3);
    color: #9a6700;
}

/* Enhance Prompt */
.ai-prompt-actions-row {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
}

.btn-enhance-prompt,
.btn-restore-prompt {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-dark);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    flex-shrink: 0;
}

.btn-enhance-prompt:hover:not(:disabled) {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-enhance-prompt:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.btn-restore-prompt {
    color: #e5a030;
    border-color: rgba(229, 160, 48, 0.4);
}

.btn-restore-prompt:hover {
    background: #e5a030;
    color: #fff;
    border-color: #e5a030;
}

.enhance-prompt-popup-content {
    width: 440px;
    max-width: 95%;
}

.enhance-prompt-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}

#enhance-model-select {
    max-height: 150px;
}

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

.cms-global-blocks-warning-modal {
    width: 460px;
    max-width: 95%;
}

.cms-global-blocks-warning-lead {
    margin: 0 0 12px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-main);
}

.cms-global-blocks-warning-note {
    margin: 0;
}

/* 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);
}

.btn-cms-ai:disabled,
.cms-btn-ai:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* 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;
}

@media (max-width: 640px) {
    .cms-toolbar #cms-search,
    .cms-toolbar #cms-filter-page {
        min-width: 100%;
        flex-basis: 100%;
    }

    .cms-filter-toggle {
        width: 100%;
        justify-content: flex-start;
    }

    .cms-text-header {
        flex-wrap: wrap;
        gap: 10px;
        align-items: flex-start;
    }

    .cms-text-meta {
        flex-wrap: wrap;
    }

    .cms-header-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .cms-translation-row {
        grid-template-columns: 1fr;
    }

    .cms-translation-label {
        padding-top: 0;
    }
}

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

#enhance-prompt-popup {
    z-index: 2500 !important;
}

#ai-cancel-confirm-modal {
    z-index: 2500 !important;
}

/* 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;
}

/* Cookie Consent Modal */
.cookie-consent-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}
.cookie-consent-overlay.hidden {
    display: none !important;
}
.cookie-consent-content {
    width: 480px;
    max-width: 90%;
}
.cookie-consent-content .modal-body p {
    font-size: 13px;
    color: var(--text-main);
    line-height: 1.6;
    margin: 0 0 12px;
}
.cookie-consent-content .modal-body p:last-child {
    margin-bottom: 0;
}
.cookie-consent-muted {
    color: var(--text-muted) !important;
    font-size: 12px !important;
}
.cookie-consent-content strong {
    color: var(--accent);
}

/* Custom Website Export Modal */
.custom-export-hint {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}
.custom-export-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.custom-export-full-btn {
    width: 100%;
    padding: 10px 16px !important;
    font-size: 13px !important;
}
.custom-export-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.custom-export-divider::before,
.custom-export-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.custom-export-split {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 14px;
}
.custom-export-split-hint {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}
.custom-export-prefix-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.custom-export-prefix-row .gb-modal-input {
    flex: 1;
}
.custom-export-prefix-row .gb-modal-btn {
    white-space: nowrap;
}
.custom-export-actions {
    display: flex;
    gap: 10px;
}
.custom-export-actions .gb-modal-btn {
    flex: 1;
}
.custom-export-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 4px;
    border-top: 1px solid var(--border);
}

/* Scripts in Edit Mode & Keep Changes Modals */
.modal-footer {
    padding: 10px 15px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: var(--bg-dark);
}
.modal-footer-col {
    flex-direction: column;
}
.modal-warning-box {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px;
    background: rgba(232, 167, 53, 0.08);
    border: 1px solid rgba(232, 167, 53, 0.25);
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--text-main);
    line-height: 1.6;
}
.modal-warning-box svg {
    flex-shrink: 0;
    margin-top: 1px;
}
.modal-warning-box p {
    margin: 0;
}
.btn-accent-light {
    background: var(--accent);
    border: 1px solid var(--accent);
    color: white;
}
.btn-accent-light:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}
.btn-warning {
    background: #b8860b;
    border: 1px solid #b8860b;
    color: white;
}
.btn-warning:hover {
    background: #9a7209;
    border-color: #9a7209;
}
#btn-scripts-in-edit.active-scripts svg {
    fill: var(--accent);
}
#btn-scripts-in-edit.active-scripts {
    opacity: 1;
}
#btn-force-visible.active-force-visible {
    opacity: 1;
}
#btn-force-visible.active-force-visible svg {
    fill: var(--accent);
}
.modal-info-box {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px;
    background: rgba(79, 195, 247, 0.08);
    border: 1px solid rgba(79, 195, 247, 0.25);
    border-radius: var(--radius);
    font-size: 12px;
    line-height: 1.5;
}
.modal-info-box svg {
    flex-shrink: 0;
    margin-top: 1px;
}
.modal-info-box p {
    margin: 0;
}

.iframe-theme-modal-content {
    width: 430px;
    max-width: min(92vw, 430px);
}
.iframe-theme-modal-body {
    gap: 14px;
}
.iframe-theme-modal-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.iframe-theme-option {
    appearance: none;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 13px;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.iframe-theme-option:hover {
    background: var(--hover-bg-strong);
    border-color: var(--accent);
    transform: translateY(-1px);
}
.iframe-theme-option .iframe-theme-check {
    width: 18px;
    flex-shrink: 0;
    color: var(--accent);
    font-size: 13px;
    visibility: hidden;
}
.iframe-theme-option.active {
    background: rgba(0, 122, 204, 0.12);
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px rgba(0, 122, 204, 0.18);
}
.iframe-theme-option.active .iframe-theme-check {
    visibility: visible;
}

/* Import from URL Modal */
.import-url-step {
    display: none;
}
.import-url-step.active {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.import-url-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.import-url-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-main);
    transition: border-color 0.12s;
    flex-wrap: wrap;
}
.import-url-option:hover {
    border-color: var(--accent);
}
.import-url-option.disabled {
    opacity: 0.6;
    cursor: default;
}
.import-url-option.disabled:hover {
    border-color: var(--border);
}
.import-url-option input[type="checkbox"],
.import-url-option input[type="radio"] {
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
}
.import-url-option.disabled input {
    cursor: default;
}
.import-option-hint {
    font-size: 11px;
    color: var(--text-muted);
    width: 100%;
    padding-left: 22px;
}
.import-url-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 4px 0;
}

.import-progress {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-dark);
}
.import-progress-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 12px;
}
.import-progress-label {
    color: var(--text-muted);
}
.import-progress-percent {
    color: var(--accent);
    font-weight: 600;
    min-width: 38px;
    text-align: right;
}
.import-progress-track {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
}
.import-progress-fill {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #2ea043);
    transition: width 0.15s linear;
}
.import-progress-overlay .modal-content {
    width: 460px;
    max-width: 95vw;
}
.import-progress-overlay .modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Read-Only Badge */
.readonly-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 600;
    background: #c98a1a;
    color: #fff;
    padding: 1px 6px;
    border-radius: 3px;
    vertical-align: middle;
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.readonly-badge.hidden {
    display: none;
}
