/* Expanders Manager Styles */
.expanders-view {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    background-color: #f8f9fa;
    overflow: hidden;
    margin-bottom: 20px;
}

#expanders-section:not(.active) .expanders-view {
    display: none;
}

.expanders-header {
    background: white;
    border-bottom: 1px solid #e1e4e8;
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.expanders-header h1 {
    font-size: 18px;
    font-weight: 600;
    color: #24292e;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    line-height: 1.2;
}

/* Ensure header icon aligns nicely with text */
.expanders-header h1 i,
.expanders-header h1 svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.expanders-header-actions {
    display: flex;
    gap: 10px;
}

.expanders-btn {
    padding: 6px 12px;
    border: 1px solid #d1d5da;
    border-radius: 6px;
    background: white;
    color: #24292e;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.expanders-btn:hover {
    background: #f6f8fa;
    border-color: #d1d5da;
}

.expanders-btn-primary {
    background: #39c0a3;
    color: white;
    border-color: #29a489;
}

.expanders-btn-primary:hover {
    background: #5FD0C0;
    border-color: #34BA9E;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 186, 158, 0.3);
}

.expanders-main-container {
    display: flex;
    height: calc(100% - 60px);
    min-height: 0;
}

.expanders-left-panel {
    background: white;
    border-right: 1px solid #e1e4e8;
    display: flex;
    flex-direction: column;
    min-width: 280px;
    /* Pre-size to Split.js default to avoid flicker before init */
    flex: 0 0 35%;
}

.expanders-search-container {
    padding: 16px;
    border-bottom: 1px solid #e1e4e8;
}

.expanders-search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5da;
    border-radius: 6px;
    font-size: 14px;
    background: #fafbfc;
}

.expanders-search-input:focus {
    outline: none;
    border-color: #0366d6;
    background: white;
}

.expanders-list {
    flex: 1;
    overflow-y: auto;
}

.expander-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.expander-item:hover {
    background: #f6f8fa;
}

.expander-item.active {
    background: #e3f2fd;
    border-right: 3px solid #0366d6;
}

.expander-title {
    font-weight: 500;
    font-size: 13px;
    color: #24292e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.expander-shortcut {
    font-family: 'Lucon', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    color: #949494;
    font-weight: 400;
    font-size: 11px;
    margin-bottom: 4px;
    background-color: #fbfbfb;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
    max-width: 100%;
}

.expander-preview {
    font-size: 11px;
    color: #6a737d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* Expander Tags Styles */
.expander-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.expander-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 6px;
    min-height: 16px;
    align-items: center;
}

.expander-tags .tag {
    font-size: 9px;
    padding: 1px 4px;
    max-width: 80px;
    border-radius: 10px;
}

.expander-tags .add-tag-btn {
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 10px;
    min-height: 12px;
}

.expander-tags .tag-remove {
    width: 8px;
    height: 8px;
    font-size: 8px;
    margin-left: 2px;
}

/* Tag Filter for Expanders */
#expandersTagFilter {
    padding: 8px 16px;
    border-bottom: 1px solid #e1e4e8;
    background: #ffffff;
}

#expandersTagFilter .filter-tag {
    font-size: 10px;
    padding: 3px 8px;
}

/* Content Panel Tags */
#contentExpanderTags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    min-height: 24px;
}

#contentExpanderTags .tag {
    font-size: 11px;
    padding: 3px 8px;
}

.expanders-right-panel {
    background: white;
    display: flex;
    flex-direction: column;
    /* Pre-size to Split.js default to avoid flicker before init */
    flex: 1 0 65%;
}

.expanders-editor-header {
    padding: 16px;
    border-bottom: 1px solid #e1e4e8;
    background: #ffffff;
}

.expanders-header-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.expanders-title-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d1d5da;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    background: white;
    box-sizing: border-box;
}

.expanders-title-input:focus {
    outline: none;
    border-color: #0366d6;
}

.expanders-shortcut-input {
    width: 30%;
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid #d1d5da;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    background: white;
    box-sizing: border-box;
}

.expanders-shortcut-input:focus {
    outline: none;
    border-color: #0366d6;
}

/* Shortcut validation tooltip */
.expanders-shortcut-tooltip {
    position: absolute;
    background-color: #ff4444;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    margin-top: 4px;
    white-space: normal;
    max-width: 280px;
    line-height: 1.4;
    animation: tooltipFadeIn 0.2s ease-in-out;
}

.expanders-shortcut-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #ff4444;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.expanders-shortcut-input.error {
    border-color: #ff4444;
    background-color: #fff5f5;
}

.expanders-shortcut-wrapper {
    position: relative;
    width: 30%;
    min-width: 200px;
}

.expanders-editor-content {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.expanders-quill-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    border: 1px solid #d1d5da;
    border-radius: 6px;
    background: white;
    min-height: 300px;
    width: 100%;
}

.expanders-quill-editor .ql-toolbar {
    border: none;
    border-bottom: 1px solid #e1e4e8;
    border-radius: 6px 6px 0 0;
    background: #fafbfc;
    flex-shrink: 0;
}

.expanders-quill-editor .ql-container {
    border: none;
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
    border-radius: 0 0 6px 6px;
    display: flex;
    flex-direction: column;
}

.expanders-quill-editor .ql-editor {
    padding: 16px;
    flex: 1;
    min-height: 200px;
    max-height: none;
    overflow-y: auto;
}

.expanders-quill-editor .ql-editor.ql-blank::before {
    color: #6a737d;
    font-style: normal;
    content: 'Enter your expander content here... (Full rich text editing supported)\A\AYou can use:\A• Headers (H1-H6)\A• Bold, italic, underline, strikethrough\A• Colors and fonts\A• Lists and alignment\A• Links and images\A• Code blocks and quotes\A• For dynamic text, use the Variables button below to insert template variables.\A\A';
    white-space: pre-line;
}

.expanders-quill-editor:focus-within {
    border-color: #0366d6;
}

.expanders-editor-footer {
    padding: 16px 16px 20px 16px;
    border-top: 1px solid #e1e4e8;
    background: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.expanders-save-status {
    font-size: 12px;
    color: #6a737d;
}

.expanders-save-status.saving {
    color: #f66a0a;
}

.expanders-save-status.saved {
    color: #28a745;
}

.expanders-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.expanders-modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.expanders-modal-header {
    padding: 20px;
    border-bottom: 1px solid #e1e4e8;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.expanders-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #24292e;
}

.expanders-close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
}

.expanders-close:hover {
    color: #000;
}

.expanders-modal-body {
    padding: 20px;
}

.expanders-import-instructions {
    margin-bottom: 16px;
    padding: 12px;
    background: #f6f8fa;
    border-radius: 6px;
    font-size: 14px;
    color: #586069;
    line-height: 1.5;
}

.expanders-paste-area {
    width: 100%;
    min-height: 200px;
    padding: 12px;
    border: 1px solid #d1d5da;
    border-radius: 6px;
    font-family: monospace;
    font-size: 12px;
    resize: vertical;
    box-sizing: border-box;
}

.expanders-paste-area:focus {
    outline: none;
    border-color: #0366d6;
    box-shadow: 0 0 0 3px rgba(3, 102, 214, 0.1);
}

.expanders-modal-footer {
    padding: 20px;
    border-top: 1px solid #e1e4e8;
    background: #fafbfc;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-radius: 0 0 8px 8px;
}

.expanders-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: #6a737d;
}

.expanders-empty-state-icon {
    margin-bottom: 16px;
    opacity: 0.5;
}

.expanders-empty-state h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: #24292e;
}

.expanders-empty-state p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

.expanders-btn i {
    margin-right: 6px;
    width: 14px;
    height: 14px;
}

.expanders-modal-header h3 i {
    margin-right: 8px;
}

/* Expanders Footer Actions */
.expanders-footer-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Mobile layout: remove viewport constraints for natural scrolling */
    .expanders-view {
        height: auto;
        overflow: visible;
    }
    
    .expanders-main-container {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }
    
    .expanders-left-panel {
        border-right: none;
        border-bottom: 1px solid #e1e4e8;
        max-height: 250px;
        min-height: 200px;
        width: 100%;
        flex: none;
        overflow-y: auto;
    }
    
    .expanders-right-panel {
        width: 100%;
        flex: none;
    }
    
    .expanders-header {
        padding: 15px 20px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .expanders-header h1 {
        margin: 0;
        text-align: left;
    }
    
    .expanders-header-actions {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 8px;
        width: 100%;
    }
    
    /* Hide Import and Export buttons on mobile */
    .expanders-header-actions button[onclick="openExpandersImportModal()"],
    .expanders-header-actions button[onclick="exportExpanders()"] {
        display: none;
    }
    
    .expanders-btn {
        justify-content: center;
        white-space: nowrap;
    }
    
    .expanders-search-container {
        padding: 12px 16px;
        width: 100%;
    }
    
    .expanders-search-input,
    .expanders-title-input {
        width: 100%;
        box-sizing: border-box;
    }
    
    .expander-item {
        padding: 10px 16px;
    }
    
    .expanders-editor-header {
        padding: 12px 16px;
        width: 100%;
        box-sizing: border-box;
    }
    
    .expanders-header-row {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }
    
    .expanders-shortcut-input {
        width: 100%;
        min-width: auto;
    }
    
    .expanders-shortcut-wrapper {
        width: 100%;
        min-width: auto;
    }
    
    .expanders-editor-content {
        padding: 12px 16px;
        overflow: visible;
    }
    
    .expanders-quill-editor {
        height: 400px;
        min-height: 400px;
    }
    
    .expanders-quill-editor .ql-container {
        flex: 1;
        min-height: 320px;
    }
    
    .expanders-quill-editor .ql-editor {
        min-height: 300px;
        max-height: none;
    }
    
    .expanders-editor-footer {
        padding: 12px 16px;
        flex-shrink: 0;
        background: #ffffff;
        border-top: 1px solid #e1e4e8;
    }
    
    .expanders-modal-content {
        width: 95%;
        margin: 10% auto;
    }
    
    .expanders-quill-editor .ql-editor {
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .expanders-header {
        padding: 12px 16px;
        gap: 10px;
    }
    
    .expanders-header h1 {
        font-size: 18px;
    }
    
    .expanders-header-actions {
        gap: 6px;
    }
    
    .expanders-search-container {
        padding: 10px 12px;
    }
    
    .expander-item {
        padding: 8px 12px;
    }
    
    .expanders-editor-header,
    .expanders-editor-content,
    .expanders-editor-footer {
        padding: 10px 12px;
    }
    
    .expanders-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .expanders-modal-content {
        width: 98%;
        margin: 5% auto;
        border-radius: 4px;
    }
    
    .expanders-quill-editor .ql-editor {
        padding: 10px;
    }
}

/* Text Expander Suggestion Menu Styles */
.expander-suggestion-menu {
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 200px;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 0;
    z-index: 1000;
}

.expander-suggestion-menu .suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f4;
    transition: background-color 0.15s;
}

.expander-suggestion-menu .suggestion-item:hover,
.expander-suggestion-menu .suggestion-item[aria-selected="true"] {
    background-color: #f8f9fa;
}

.expander-suggestion-menu .suggestion-item:last-child {
    border-bottom: none;
}

.expander-suggestion-menu .suggestion-trigger {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    color: #34BA9E;
    font-weight: 600;
    font-size: 13px;
}

.expander-suggestion-menu .suggestion-preview {
    color: #6c757d;
    font-size: 12px;
    margin-top: 4px;
    line-height: 1.3;
}

/* Private Toggle Styles */
.expanders-private-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.expanders-private-container .private-label {
    font-size: 13px;
    font-weight: 500;
    color: #656d76;
}

.expanders-private-container .checkbox-wrapper-7 .tgl {
    display: none;
}

.expanders-private-container .checkbox-wrapper-7 .tgl,
.expanders-private-container .checkbox-wrapper-7 .tgl:after,
.expanders-private-container .checkbox-wrapper-7 .tgl:before,
.expanders-private-container .checkbox-wrapper-7 .tgl *,
.expanders-private-container .checkbox-wrapper-7 .tgl *:after,
.expanders-private-container .checkbox-wrapper-7 .tgl *:before,
.expanders-private-container .checkbox-wrapper-7 .tgl + .tgl-btn {
    box-sizing: border-box;
}

.expanders-private-container .checkbox-wrapper-7 .tgl::-moz-selection,
.expanders-private-container .checkbox-wrapper-7 .tgl:after::-moz-selection,
.expanders-private-container .checkbox-wrapper-7 .tgl:before::-moz-selection,
.expanders-private-container .checkbox-wrapper-7 .tgl *::-moz-selection,
.expanders-private-container .checkbox-wrapper-7 .tgl *:after::-moz-selection,
.expanders-private-container .checkbox-wrapper-7 .tgl *:before::-moz-selection,
.expanders-private-container .checkbox-wrapper-7 .tgl + .tgl-btn::-moz-selection,
.expanders-private-container .checkbox-wrapper-7 .tgl::selection,
.expanders-private-container .checkbox-wrapper-7 .tgl:after::selection,
.expanders-private-container .checkbox-wrapper-7 .tgl:before::selection,
.expanders-private-container .checkbox-wrapper-7 .tgl *::selection,
.expanders-private-container .checkbox-wrapper-7 .tgl *:after::selection,
.expanders-private-container .checkbox-wrapper-7 .tgl *:before::selection,
.expanders-private-container .checkbox-wrapper-7 .tgl + .tgl-btn::selection {
    background: none;
}

.expanders-private-container .checkbox-wrapper-7 .tgl + .tgl-btn {
    outline: 0;
    display: block;
    width: 42px;
    height: 22px;
    position: relative;
    cursor: pointer;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.expanders-private-container .checkbox-wrapper-7 .tgl + .tgl-btn:after,
.expanders-private-container .checkbox-wrapper-7 .tgl + .tgl-btn:before {
    position: relative;
    display: block;
    content: "";
    width: 50%;
    height: 100%;
}

.expanders-private-container .checkbox-wrapper-7 .tgl + .tgl-btn:after {
    left: 0;
}

.expanders-private-container .checkbox-wrapper-7 .tgl + .tgl-btn:before {
    display: none;
}

.expanders-private-container .checkbox-wrapper-7 .tgl:checked + .tgl-btn:after {
    left: 50%;
}

.expanders-private-container .checkbox-wrapper-7 .tgl-ios + .tgl-btn {
    background: #fbfbfb;
    border-radius: 2em;
    padding: 2px;
    transition: all 0.4s ease;
    border: 1px solid #e8eae9;
}

.expanders-private-container .checkbox-wrapper-7 .tgl-ios + .tgl-btn:after {
    border-radius: 2em;
    background: #fbfbfb;
    transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), padding 0.3s ease, margin 0.3s ease;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), 0 4px 0 rgba(0, 0, 0, 0.08);
}

.expanders-private-container .checkbox-wrapper-7 .tgl-ios + .tgl-btn:hover:after {
    will-change: padding;
}

.expanders-private-container .checkbox-wrapper-7 .tgl-ios + .tgl-btn:active {
    box-shadow: inset 0 0 0 2em #e8eae9;
}

.expanders-private-container .checkbox-wrapper-7 .tgl-ios + .tgl-btn:active:after {
    padding-right: 0.8em;
}

.expanders-private-container .checkbox-wrapper-7 .tgl-ios:checked + .tgl-btn {
    background: #86d993;
}

.expanders-private-container .checkbox-wrapper-7 .tgl-ios:checked + .tgl-btn:active {
    box-shadow: none;
}

.expanders-private-container .checkbox-wrapper-7 .tgl-ios:checked + .tgl-btn:active:after {
    margin-left: -0.8em;
}