/* ============================================
   MARKDOWN PREVIEW - UI COMPONENTS
   ============================================ */

/* Mode Toggle (Segmented Control) */
.mode-toggle {
    display: flex;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.mode-toggle button {
    padding: 8px 10px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6875rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.mode-toggle button:hover {
    color: var(--text-primary);
}

.mode-toggle button.active {
    background: var(--accent-it);
    color: var(--bg-primary);
}

/* Live Preview Toggle */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.toggle-switch input[type="checkbox"] {
    width: 36px;
    height: 20px;
    appearance: none;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-switch input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--text-muted);
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: all 0.2s;
}

.toggle-switch input[type="checkbox"]:checked {
    background: var(--accent-it);
    border-color: var(--accent-it);
}

.toggle-switch input[type="checkbox"]:checked::before {
    background: white;
    left: 18px;
}

/* Experimental toggle label (smaller) */
.toggle-switch span {
    font-size: 0.6875rem;
}

/* Experimental toggle alignment */
.toggle-switch.ml-auto {
    margin-left: auto;
}

/* Insert Dropdown */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    min-width: 220px;
    z-index: 100;
    display: none;
    box-shadow: var(--shadow-lg);
}

.dropdown-menu.active {
    display: block;
}

.dropdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--text-primary);
    transition: background 0.15s;
}

.dropdown-item:hover {
    background: var(--bg-secondary);
}

.dropdown-item code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6875rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 3px;
}

/* Dropdown keyboard navigation */
.dropdown-item.focused {
    background: var(--accent-it-dim);
    outline: 2px solid var(--accent-it);
    outline-offset: -2px;
}

.dropdown-item:focus {
    background: var(--accent-it-dim);
    outline: 2px solid var(--accent-it);
    outline-offset: -2px;
}

/* Find/Replace Bar */
.find-replace-bar {
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.find-replace-bar.active {
    display: flex;
}

.find-replace-bar input {
    flex: 1;
    min-width: 120px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
}

.find-replace-bar input:focus {
    outline: none;
    border-color: var(--accent-it);
}

.find-replace-bar .find-info {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 70px;
    text-align: center;
}

.find-replace-bar .find-actions {
    display: flex;
    gap: 6px;
}

.find-replace-bar .find-btn {
    padding: 6px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'JetBrains Mono', monospace;
}

.find-replace-bar .find-btn:hover:not(:disabled) {
    border-color: var(--accent-it);
    color: var(--text-primary);
}

.find-replace-bar .find-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.find-replace-bar .find-btn.primary {
    background: var(--accent-it);
    border-color: var(--accent-it);
    color: var(--bg-primary);
}

.find-replace-bar .find-btn.primary:hover:not(:disabled) {
    opacity: 0.9;
}

.find-replace-bar .close-find {
    padding: 6px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.find-replace-bar .close-find:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.find-replace-bar .close-find svg {
    width: 16px;
    height: 16px;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.modal-header svg {
    width: 24px;
    height: 24px;
    color: var(--accent-warning);
}

.modal-header h3 {
    font-size: 1.125rem;
    color: var(--text-primary);
}

.modal-body {
    margin-bottom: 20px;
}

.modal-body p {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.modal-note {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-actions .btn {
    padding: 10px 20px;
}

.btn-danger {
    background: var(--accent-error);
    border-color: var(--accent-error);
    color: white;
}

.btn-danger:hover {
    opacity: 0.9;
}

.btn-primary {
    background: var(--accent-it);
    border-color: var(--accent-it);
    color: var(--bg-primary);
}

.btn-primary:hover {
    opacity: 0.9;
}

/* Filename Input Group */
.filename-input-group {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.filename-input-group input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 12px;
}

.filename-input-group input:focus {
    box-shadow: none;
}

.filename-ext {
    padding: 10px 12px;
    background: var(--bg-card);
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    border-left: 1px solid var(--border-color);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 0.875rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

.toast.success {
    border-color: var(--accent-success);
}

.toast.error {
    border-color: var(--accent-error);
}

.toast.warning {
    border-color: var(--accent-warning);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Editor Wrapper */
.editor-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Responsive adjustments for components */
@media (max-width: 768px) {
    .find-replace-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .find-replace-bar input {
        min-width: 100%;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .toast {
        animation: none;
    }
}
