/* ProLint - NSP dark theme */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #1e1e1e;
    --bg-secondary: #252526;
    --bg-hover: #2a2d2e;
    --bg-active: #37373d;
    --bg-input: #1e1e1e;
    --bg-popup: #2d2d30;
    --border: #3c3c3c;
    --border-light: #555;
    --text-primary: #d4d4d4;
    --text-secondary: #b0b0b0;
    --text-meta: #808080;
    --accent: #e5c07b;
    --green: #4ec9b0;
    --blue: #569cd6;
    --purple: #c586c0;
    --red: #f44747;
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
}

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13px;
}

/* ---- Layout ---- */

.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
}

.left-panel {
    width: 280px;
    min-width: 220px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.center-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-width: 0;
}

.right-panel {
    width: 320px;
    min-width: 260px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: width 0.2s;
}

.right-panel.collapsed {
    display: none;
}

/* ---- Panel Headers ---- */

.panel-header {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.panel-title {
    color: var(--accent);
    font-weight: 600;
    font-size: 13px;
}

.panel-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ---- Buttons ---- */

.btn-icon {
    background: none;
    border: none;
    color: var(--text-meta);
    cursor: pointer;
    padding: 2px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.btn-toolbar {
    background: var(--bg-active);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 4px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-body);
}

.btn-toolbar:hover:not(:disabled) {
    background: #4c4c4c;
}

.btn-toolbar:disabled {
    opacity: 0.4;
    cursor: default;
}

.btn-small-action {
    background: var(--bg-active);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 3px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    font-family: var(--font-body);
}

.btn-small-action:hover {
    background: #4c4c4c;
}

.btn-skip {
    color: var(--text-meta);
}

.btn-revert {
    color: var(--accent);
}

.btn-expand-right {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-right: none;
    color: var(--text-meta);
    cursor: pointer;
    padding: 8px 4px;
    border-radius: 4px 0 0 4px;
    z-index: 10;
}

.btn-expand-right:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* ---- Left Panel: Files ---- */

.files-section {
    flex: 1;
    overflow: auto;
    min-height: 0;
}

.file-list {
    overflow-y: auto;
}

.file-item {
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 3px solid transparent;
}

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

.file-item.active {
    background: var(--bg-active);
    color: var(--accent);
    border-left-color: var(--accent);
}

.file-item .file-ext {
    color: var(--text-meta);
    font-size: 10px;
}

.file-item .file-hits {
    color: var(--text-meta);
    font-size: 10px;
    margin-left: 8px;
}

/* ---- Left Panel: Activity Log ---- */

.log-section {
    height: 160px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.activity-log {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.log-entry {
    padding: 2px 12px;
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.log-entry.log-ok {
    color: var(--green);
}

.log-entry.log-info {
    color: var(--blue);
}

.log-entry.log-warn {
    color: var(--accent);
}

/* ---- Center Panel: Toolbar ---- */

.center-toolbar {
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.file-name-display {
    color: var(--accent);
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats-display {
    color: var(--text-meta);
    font-size: 11px;
    white-space: nowrap;
}

/* ---- Center Panel: Text Display ---- */

.text-display {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
    line-height: 1.8;
    font-size: 14px;
}

.text-display .para {
    margin-bottom: 4px;
    min-height: 1.8em;
    padding: 2px 4px;
    border-radius: 2px;
}

.text-display .para:hover {
    background: rgba(255,255,255,0.02);
}

.text-display .para.empty-para {
    min-height: 1em;
}

/* Hit spans */
.hit-span {
    border-bottom: 2px solid var(--accent);
    cursor: pointer;
    padding: 1px 0;
    transition: background 0.15s;
}

.hit-span:hover {
    background: rgba(229, 192, 123, 0.15);
}

.hit-span.active {
    background: rgba(86, 156, 214, 0.25);
    border-bottom-color: var(--blue);
}

.hit-span.replaced {
    border-bottom: 2px dashed var(--green);
    color: var(--green);
    cursor: pointer;
}

.hit-span.replaced:hover {
    background: rgba(78, 201, 176, 0.15);
}

.hit-span.skipped {
    border-bottom: 2px solid var(--text-meta);
    opacity: 0.6;
    cursor: pointer;
}

.hit-span.detect-only {
    border-bottom: 2px dotted var(--purple);
    cursor: help;
}

.hit-span.detect-only:hover {
    background: rgba(197, 134, 192, 0.15);
}

/* DOCX formatted display - heading styles */
.text-display .para.docx-h1 {
    font-size: 22px;
    font-weight: 700;
    margin-top: 16px;
    margin-bottom: 8px;
}

.text-display .para.docx-h2 {
    font-size: 18px;
    font-weight: 600;
    margin-top: 12px;
    margin-bottom: 6px;
}

.text-display .para.docx-h3 {
    font-size: 15px;
    font-weight: 600;
    margin-top: 8px;
    margin-bottom: 4px;
}

.text-display .para.docx-h4 {
    font-size: 14px;
    font-weight: 600;
    margin-top: 6px;
    margin-bottom: 4px;
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-meta);
    gap: 12px;
}

.empty-state p {
    font-size: 14px;
}

.empty-hint {
    font-size: 11px !important;
    color: var(--border-light);
}

/* Drag over state */
.text-display.drag-over {
    background: rgba(229, 192, 123, 0.05);
    outline: 2px dashed var(--accent);
    outline-offset: -8px;
}

/* Inline edit */
.para-edit-area {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--accent);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.8;
    padding: 4px 6px;
    border-radius: 3px;
    resize: vertical;
    min-height: 2.5em;
}

.para-edit-area:focus {
    outline: none;
    border-color: var(--blue);
}

/* ---- Replace Popup ---- */

.replace-popup {
    position: absolute;
    background: var(--bg-popup);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 12px;
    width: 340px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    z-index: 100;
    max-height: 300px;
    overflow-y: auto;
}

.popup-header {
    margin-bottom: 8px;
}

.popup-category {
    color: var(--text-meta);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 2px;
}

.popup-match {
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
}

.popup-replacements {
    margin-bottom: 8px;
}

.replacement-chip {
    display: inline-block;
    background: var(--bg-active);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 3px 10px;
    border-radius: 14px;
    margin: 2px 4px 2px 0;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.replacement-chip:hover {
    background: var(--green);
    color: var(--bg-primary);
    border-color: var(--green);
}

.popup-custom {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

.popup-custom input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-family: var(--font-body);
}

.popup-custom input:focus {
    outline: none;
    border-color: var(--blue);
}

.popup-custom input::placeholder {
    color: var(--text-meta);
}

.popup-actions {
    display: flex;
    gap: 6px;
}

/* ---- Right Panel: Hit List ---- */

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

.filter-select {
    background: var(--bg-active);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-body);
}

.hit-item {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.1s;
}

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

.hit-item.active {
    background: var(--bg-active);
    border-left: 3px solid var(--blue);
    padding-left: 9px;
}

.hit-item.replaced-item {
    opacity: 0.5;
}

.hit-item.skipped-item {
    opacity: 0.4;
}

.hit-entry-id {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
}

.hit-entry-id.replaced-id {
    color: var(--green);
}

.hit-entry-id.skipped-id {
    color: var(--text-meta);
}

.hit-entry-id.detect-only-id {
    color: var(--purple);
}

.hit-match-text {
    font-size: 12px;
    color: var(--text-primary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hit-match-text.replaced-text {
    text-decoration: line-through;
    color: var(--text-meta);
}

.hit-replacement-info {
    font-size: 10px;
    color: var(--text-meta);
    margin-top: 2px;
}

.hit-replacement-info.replaced-info {
    color: var(--green);
}

/* ---- Scrollbar ---- */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* ---- Responsive ---- */

@media (max-width: 900px) {
    .left-panel {
        width: 220px;
    }
    .right-panel {
        width: 260px;
    }
}

@media (max-width: 700px) {
    .left-panel {
        display: none;
    }
    .right-panel {
        display: none;
    }
    .btn-expand-right {
        display: none !important;
    }
}
