/* 
    # Copyright (c) 2026 Deni Hamdani
    # SPDX-License-Identifier: MIT

    ============================================
    Sidebar, Merge Panel, Preview Panel, Modals
    ============================================ 
*/

/* ── HEADER ── */
.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.logo {
    font-size: 22px;
}

.app-title {
    font-size: var(--fs-heading-md);
    font-weight: var(--fw-bold);
}

.app-version {
    font-family: var(--font-mono);
    font-size: var(--fs-badge);
    color: var(--text-disabled);
    padding: 1px 6px;
    background: var(--bg-hover);
    border-radius: var(--r-sm);
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* ── SIDEBAR ── */
.sidebar-search {
    padding: var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-search input {
    width: 100%;
    height: 32px;
    padding: 0 var(--space-3);
    font-family: var(--font-sans);
    font-size: var(--fs-body-sm);
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--r-md);
    outline: none;
}

.sidebar-search input:focus {
    border-color: var(--border-focus);
}

.sidebar-section {
    border-bottom: 1px solid var(--border-subtle);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-3) var(--space-2);
}

.section-header h2 {
    font-size: var(--fs-body-sm);
    font-weight: var(--fw-semibold);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.item-list {
    list-style: none;
    padding: 0 var(--space-2) var(--space-2);
    max-height: 250px;
    overflow-y: auto;
}

.item-list li {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: background var(--t-fast);
    position: relative;
}

.item-list li:hover {
    background: var(--bg-hover);
}

.item-list li:hover .item-menu-btn {
    opacity: 1;
}

.item-list li.selected {
    background: var(--bg-selected);
    border-left: 3px solid var(--blue-500);
    padding-left: calc(var(--space-3) - 3px);
}

.item-list li.selected .item-title {
    color: var(--blue-500);
}

.item-emoji {
    font-size: 16px;
    flex-shrink: 0;
}

.item-info {
    flex: 1;
    min-width: 0;
}

.item-title {
    font-size: var(--fs-body-sm);
    font-weight: var(--fw-medium);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-snippet {
    font-size: var(--fs-caption);
    color: var(--text-disabled);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-menu-btn {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 2px;
    font-size: 16px;
    transition: opacity var(--t-fast);
}

.item-menu-btn:hover {
    color: var(--text-primary);
}

.in-merge-badge {
    font-size: 9px;
    padding: 1px 4px;
    background: var(--yellow-100);
    color: var(--yellow-500);
    border-radius: var(--r-sm);
    font-weight: var(--fw-semibold);
}

.empty-state {
    padding: var(--space-6) var(--space-4);
    text-align: center;
    color: var(--text-disabled);
    font-size: var(--fs-body-sm);
}

.empty-state p {
    margin-bottom: var(--space-2);
}

.empty-state .hint {
    font-size: var(--fs-caption);
    color: var(--text-disabled);
}

/* ── MERGE PANEL ── */
.merge-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--r-lg);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}

.panel-header h2 {
    font-size: var(--fs-heading-sm);
    font-weight: var(--fw-semibold);
}

.merge-controls {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.merge-items-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-2);
}

.merge-items {
    list-style: none;
}

.merge-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-sm);
    margin-bottom: var(--space-1);
    background: var(--bg-base);
    transition: background var(--t-fast);
}

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

.merge-item .drag-handle {
    color: var(--text-disabled);
    cursor: grab;
    font-size: 14px;
    user-select: none;
}

.merge-item .item-order {
    width: 24px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: var(--fs-badge);
    color: var(--text-disabled);
    font-weight: var(--fw-semibold);
}

.merge-item .item-type-icon {
    font-size: 14px;
}

.merge-item .item-name {
    flex: 1;
    font-size: var(--fs-body-sm);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.merge-item .item-tokens {
    font-family: var(--font-mono);
    font-size: var(--fs-caption);
    color: var(--text-tertiary);
}

.merge-item .move-btn {
    background: none;
    border: none;
    color: var(--text-disabled);
    cursor: pointer;
    padding: 2px;
    font-size: 12px;
}

.merge-item .move-btn:hover {
    color: var(--text-primary);
}

.merge-item .remove-btn {
    background: none;
    border: none;
    color: var(--text-disabled);
    cursor: pointer;
    padding: 2px;
    font-size: 14px;
}

.merge-item .remove-btn:hover {
    color: var(--red-500);
}

.merge-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-disabled);
    gap: var(--space-2);
    text-align: center;
}

.merge-empty .hint {
    font-size: var(--fs-caption);
    color: var(--text-disabled);
}

.action-bar {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border-subtle);
}

/* ── PREVIEW PANEL ── */
.preview-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--r-lg);
    overflow: hidden;
}

.preview-controls {
    display: flex;
    gap: var(--space-1);
}

.preview-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3);
}

.preview-content pre {
    font-family: var(--font-mono);
    font-size: var(--fs-code);
    line-height: var(--lh-relaxed);
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
}

#preview-rendered {
    font-family: var(--font-sans);
    font-size: var(--fs-body-md);
    line-height: var(--lh-relaxed);
}

#preview-rendered h1,
#preview-rendered h2,
#preview-rendered h3 {
    margin-bottom: var(--space-2);
}

#preview-rendered pre {
    background: var(--bg-base);
    padding: var(--space-3);
    border-radius: var(--r-sm);
    overflow-x: auto;
}

#preview-rendered hr {
    border: none;
    border-top: 1px solid var(--border-default);
    margin: var(--space-3) 0;
}

#preview-rendered code {
    background: var(--bg-hover);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 12px;
}

/* ── STATUS BAR ── */
.status-left,
.status-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.separator {
    color: var(--text-disabled);
}

.save-indicator {
    color: var(--green-500);
}

/* ── MODAL OVERLAY ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-overlay);
    z-index: 1000;
    animation: fade-in 150ms ease;
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    width: 520px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    animation: modal-in 200ms ease-out;
}

@keyframes modal-in {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-shortcuts {
    width: 560px;
}

.modal-danger {
    border-left: 3px solid var(--red-500);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
    font-size: var(--fs-heading-md);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-5);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-subtle);
}

.warning-text {
    color: var(--red-500);
    font-size: var(--fs-body-sm);
    margin-top: var(--space-3);
}

.import-info {
    margin-bottom: var(--space-4);
    padding: var(--space-3);
    background: var(--bg-base);
    border-radius: var(--r-md);
    font-family: var(--font-mono);
    font-size: var(--fs-caption);
    color: var(--text-secondary);
    line-height: var(--lh-relaxed);
}

.import-mode {
    margin-top: var(--space-3);
}

/* ── SHORTCUTS OVERLAY ── */
.shortcuts-body h4 {
    margin: var(--space-4) 0 var(--space-2);
    color: var(--yellow-500);
    font-size: var(--fs-body-sm);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.shortcuts-body h4:first-child {
    margin-top: 0;
}

.shortcut-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-1) 0;
    font-size: var(--fs-body-sm);
    color: var(--text-secondary);
}

.shortcut-row span {
    flex-grow: 2;
    color: var(--text-primary);
}

.shortcut-row kbd {
    margin-left: 2px;
}

/* ── DRAG & DROP ── */
.drop-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 128, 255, 0.08);
    z-index: 1200;
    border: 3px dashed var(--blue-500);
}

.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-8) var(--space-12);
    background: var(--bg-surface);
    border: 2px solid var(--blue-500);
    border-radius: var(--r-lg);
    color: var(--text-primary);
}

.drop-icon {
    font-size: 48px;
}

.drop-zone p {
    font-size: var(--fs-heading-sm);
}

.drop-zone .hint {
    font-size: var(--fs-caption);
    color: var(--text-tertiary);
}