/* ========================================================================
   Protocol 3D Viewer Extension Styles
   All selectors are scoped under .protocol3d-root to avoid leaking into
   other modules or global styles.
   ======================================================================== */

/* ── Root: self-contained full-height container ─────────────────────────── */

.protocol3d-root {
    height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Main panel: title card stays fixed at top, section list scrolls below */
.v3d-panel {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* ── Title Card ───────────────────────────────────────────────────────── */

.v3d-title-card {
    flex-shrink: 0;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 8px 12px 6px;
}

.v3d-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    min-width: 0;
}

.v3d-title-text {
    flex: 1;
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #212529;
}

/* Save state indicators */
.v3d-save-indicator { font-size: 0.8rem; flex-shrink: 0; }
.v3d-save-indicator.saving { color: #6c757d; }
.v3d-save-indicator.saved  { color: #28a745; }
.v3d-save-indicator.error  { color: #dc3545; }

/* Toolbar row */
.v3d-toolbar-row {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 4px;
}

/* Toolbar buttons */
.v3d-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: #fff;
    color: #495057;
    font-size: 0.78rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s, border-color 0.12s;
}

.v3d-toolbar-btn:hover:not(:disabled) {
    background: #f0f0f0;
    border-color: #adb5bd;
}

.v3d-toolbar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.v3d-toolbar-btn--chevron { margin-left: auto; }

/* Due date badge */
.v3d-due-date-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border: none;
    border-radius: 4px;
    background: #0068a8;
    color: #fff;
    font-size: 0.78rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s;
}

.v3d-due-date-badge:hover { background: #005a91; }

/* Inline date picker row */
.v3d-due-date-picker-row {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.v3d-date-input {
    padding: 2px 5px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.78rem;
    color: #495057;
}

/* ── Collapsible file list in title card ─────────────────────────────── */

.v3d-files-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 5px 0 3px;
    border-top: 1px solid #f0f0f0;
    margin-top: 4px;
}

.v3d-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    background: #f3f5f7;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    font-size: 0.75rem;
    color: #495057;
    max-width: 190px;
}

.v3d-file-chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.v3d-file-chip-view {
    background: none;
    border: none;
    padding: 0 2px;
    color: #0068a8;
    cursor: pointer;
    font-size: 0.75rem;
    line-height: 1;
    flex-shrink: 0;
}

.v3d-file-chip-view:hover { color: #005a91; }

/* ── Editor area (replaces section list — ProtocolEditor fills available space) ── */

.v3d-editor-area {
    flex: 1 1 0;
    overflow-y: auto;
    min-height: 0;
}

.v3d-editor-empty {
    color: #6c757d;
    font-size: 0.85rem;
    padding: 16px 12px;
    text-align: center;
}

.v3d-section-row {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fafafa;
    overflow: hidden;
}

.v3d-section-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    background: #f0f2f5;
    border-bottom: 1px solid #e0e0e0;
}

.v3d-section-title-input {
    flex: 1;
    border: none;
    background: transparent;
    font-weight: 600;
    font-size: 0.88rem;
    color: #212529;
    min-width: 0;
    padding: 2px 4px;
}

.v3d-section-title-input:focus {
    outline: none;
    background: rgba(0, 104, 168, 0.04);
    border-radius: 3px;
}

.v3d-section-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.v3d-section-btn {
    background: none;
    border: none;
    border-radius: 3px;
    padding: 3px 5px;
    color: #6c757d;
    cursor: pointer;
    font-size: 0.82rem;
    line-height: 1;
    transition: color 0.12s, background 0.12s;
}

.v3d-section-btn:hover { background: rgba(0,0,0,0.07); color: #212529; }
.v3d-section-btn.assigned { color: #0068a8; }
.v3d-section-btn.completed { color: #28a745; }
.v3d-section-btn.has-context { color: #6f42c1; }
.v3d-section-btn.delete:hover { color: #dc3545; background: rgba(220,53,69,0.08); }

.v3d-bcf-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.75rem;
    color: #495057;
    cursor: pointer;
}

.v3d-section-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: #f8f9fa;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.78rem;
}

.v3d-section-person { color: #0068a8; }

.v3d-section-due-date { margin-left: auto; }

.v3d-due-date-input {
    padding: 1px 5px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.75rem;
    color: #495057;
}

/* Section content */
.v3d-section-content { padding: 6px 8px; }

.v3d-block { margin-bottom: 4px; }

.v3d-block-paragraph {
    font-size: 0.85rem;
    min-height: 22px;
    padding: 2px 4px;
    border-radius: 3px;
    color: #212529;
    outline: none;
}

.v3d-block-paragraph:focus { background: rgba(0,104,168,0.04); }

.v3d-block-list {
    margin: 0 0 4px 18px;
    padding: 0;
    font-size: 0.85rem;
    color: #212529;
}

.v3d-block-insert-controls {
    display: flex;
    gap: 5px;
    padding-top: 5px;
}

.v3d-insert-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    border: 1px dashed #ced4da;
    border-radius: 4px;
    background: transparent;
    color: #6c757d;
    font-size: 0.75rem;
    cursor: pointer;
    transition: color 0.12s, border-color 0.12s;
}

.v3d-insert-btn:hover { color: #495057; border-color: #adb5bd; }

/* ── 3D Context bottom sheet ──────────────────────────────────────────── */

.v3d-context-sheet {
    position: relative;
    flex-shrink: 0;
    background: #fff;
    border-top: 2px solid #0068a8;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.v3d-context-sheet-drag {
    flex-shrink: 0;
    height: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: ns-resize;
    background: #f8f9fa;
}

.v3d-context-sheet-drag-indicator {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: #ced4da;
}

.v3d-context-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 10px;
    border-bottom: 1px solid #e0e0e0;
    background: #f3f5f7;
}

.v3d-context-sheet-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: #212529;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.v3d-context-close-btn {
    background: none;
    border: none;
    font-size: 0.85rem;
    color: #6c757d;
    cursor: pointer;
    padding: 2px 5px;
    line-height: 1;
    flex-shrink: 0;
}

.v3d-context-close-btn:hover { color: #212529; }

.v3d-context-sheet-tabs {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.v3d-tab-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 8px;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    font-size: 0.78rem;
    color: #6c757d;
    cursor: pointer;
    transition: color 0.12s, border-color 0.12s;
}

.v3d-tab-btn.active { color: #0068a8; border-bottom-color: #0068a8; }
.v3d-tab-btn:hover:not(.active) { color: #495057; }

.v3d-tab-count {
    background: #0068a8;
    color: #fff;
    border-radius: 8px;
    font-size: 0.68rem;
    padding: 1px 5px;
}

.v3d-context-sheet-body {
    flex: 1 1 0;
    overflow-y: auto;
    padding: 6px 10px;
}

.v3d-tab-empty {
    color: #6c757d;
    font-size: 0.8rem;
    padding: 10px 0;
    text-align: center;
}

.v3d-obj-toolbar {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.v3d-obj-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: #fff;
    color: #495057;
    font-size: 0.78rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s;
}

.v3d-obj-toolbar-btn:hover:not(:disabled) { background: #f0f0f0; }
.v3d-obj-toolbar-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.v3d-obj-list { display: flex; flex-direction: column; gap: 4px; }

.v3d-obj-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    background: #f3f5f7;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #495057;
}

.v3d-obj-chip-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.v3d-obj-chip-remove {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0 2px;
    line-height: 1;
    flex-shrink: 0;
}

.v3d-snapshots {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.v3d-snapshot-item {
    position: relative;
    width: 80px;
    height: 60px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    overflow: hidden;
    background: #f3f5f7;
}

.v3d-snapshot-img { width: 100%; height: 100%; object-fit: cover; }

.v3d-snapshot-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
    font-size: 1.4rem;
}

.v3d-snapshot-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(220,53,69,0.85);
    border: none;
    color: #fff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.v3d-context-sheet-footer {
    display: flex;
    gap: 6px;
    padding: 6px 10px;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
}

/* ── Person dropdown ──────────────────────────────────────────────────── */

.v3d-person-overlay {
    position: fixed;
    inset: 0;
    z-index: 199;
}

.v3d-person-dropdown {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 60px;
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    z-index: 200;
    max-height: 260px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.v3d-person-search { padding: 7px 10px; border-bottom: 1px solid #e0e0e0; }

.v3d-person-search-input {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.82rem;
    color: #212529;
}

.v3d-person-search-input:focus { outline: none; border-color: #0068a8; }

.v3d-person-loading {
    padding: 10px;
    text-align: center;
    font-size: 0.8rem;
    color: #6c757d;
}

.v3d-person-item {
    padding: 8px 12px;
    font-size: 0.82rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.1s;
}

.v3d-person-item:hover { background: #f0f7ff; }
.v3d-person-item.selected { color: #0068a8; background: #e8f4fd; }

.v3d-person-empty { padding: 10px 12px; font-size: 0.8rem; color: #6c757d; }

.v3d-person-remove {
    padding: 6px 10px;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
}

/* ── Footer ───────────────────────────────────────────────────────────── */

.v3d-footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
}

.v3d-footer-spacer { flex: 1; }

/* ── Bottom panel ─────────────────────────────────────────────────────── */

.v3d-bottom-panel {
    flex-shrink: 0;
    background: #fff;
    border-top: 1px solid #dee2e6;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.v3d-bottom-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.v3d-new-protocol-input {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.82rem;
    color: #212529;
}

.v3d-new-protocol-input:focus { outline: none; border-color: #0068a8; }

.v3d-protocol-select {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.82rem;
    color: #212529;
    background: #fff;
}

/* ── Status message ───────────────────────────────────────────────────── */

.v3d-status-message {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 0.78rem;
    font-weight: 500;
    text-align: center;
}

.v3d-status-message.success { background: #d4edda; color: #155724; }
.v3d-status-message.error   { background: #f8d7da; color: #721c24; }
.v3d-status-message.warning { background: #fff3cd; color: #856404; }
