/* ============================================
   NoteView - Document View Overrides
   ============================================ */


.document-view .block {
        max-width: 800px;
        margin-left: auto;
        margin-right: auto;
        background: transparent;
        border: none;
        border-bottom: 1px solid var(--bg-tertiary);
        border-radius: 0;
        margin-bottom: 1rem;
        padding-bottom: 0.5rem;
        box-shadow: none;
        position: relative;
        transition: border-color 0.2s;
        overflow: visible;
        margin-top: 1.5rem;
}

@media (min-width: 1200px) {
    .document-view .block {
        max-width: 1100px;
    }
}

@media (min-width: 1600px) {
    .document-view .block {
        max-width: 1400px;
    }
}

.document-view .block::before {
    content: '';
    position: absolute;
    left: -1rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: transparent;
    transition: background 0.2s;
}

.document-view .block:focus-within::before {
    background: var(--accent);
}

/* Empty block styling */
.document-view .block.empty {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    opacity: 0.6;
    margin-top: 1rem;
}

.document-view .block.empty:focus-within {
    border-color: var(--accent);
    background: var(--bg-primary);
    opacity: 1;
}

.document-view .block-metadata {
    background: var(--bg-primary);
    padding: 0 1rem;
    opacity: 0;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 0;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: absolute;
    bottom: calc(100% - 1px);
    left: -1px;
    width: calc(100% + 2px);
    z-index: 5;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.document-view .block:hover .block-metadata,
.document-view .block:focus-within .block-metadata {
    opacity: 1;
    height: auto;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
}

.document-view .block-tags {
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.remove-tag {
    cursor: pointer;
    margin-left: 0.25rem;
    opacity: 0.5;
    font-size: 1.1em;
}

.meta-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.tag-input {
    background: transparent;
    border: none;
    font-size: 0.75rem;
    color: var(--text-primary);
    padding: 0.2rem 0.5rem;
    width: 60px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.tag-input:focus {
    outline: none;
    background: var(--bg-tertiary);
    width: 100px;
}

/* Content Modal (used for editing block content) */
.tag-modal.content-modal {
    width: 800px;
    height: 600px;
    max-height: 85vh;
}

.tag-modal.large-paste-modal {
    width: 620px;
    max-width: calc(100vw - 2rem);
}

.large-paste-summary {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.large-paste-summary p {
    margin: 0;
    color: var(--text-secondary);
}

.large-paste-preview {
    margin: 0;
    max-height: 180px;
    overflow: auto;
    padding: 0.9rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.45;
    white-space: pre-wrap;
}

.large-paste-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.content-modal .tag-modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* Metadata header in modal */
.content-modal .block-metadata {
    position: static;
    opacity: 1;
    height: auto;
    padding: 1rem 1.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    box-shadow: none;
    border-radius: 0;
    width: 100%;
    background: var(--bg-secondary);
}

.content-modal .block-tags {
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.content-modal .block-dates {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.content-modal .block-editor {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.content-modal .codemirror-container {
    flex: 1;
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-primary);
}

.content-modal .cm-editor {
    height: 100%;
}

.content-modal.fenced-block-modal {
    width: min(960px, calc(100vw - 2rem));
    height: min(720px, calc(100vh - 2rem));
}

.fenced-block-modal .tag-modal-body {
    padding: 1.25rem 1.5rem 1.5rem;
    gap: 1rem;
}

.fenced-block-modal-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.fenced-block-modal-content {
    flex: 1;
    min-height: 0;
    margin: 0;
    overflow: auto;
    padding: 1rem 1.1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.md-fenced-block-source {
    display: inline-block;
    width: 100%;
    margin: 0.2rem 0;
    padding: 0.2rem 0.35rem;
    border-left: 2px solid var(--border);
    background: color-mix(in srgb, var(--bg-secondary) 84%, transparent);
}

.cm-line.md-fenced-block-hidden-line {
    display: none;
}

.cm-line.md-task-filter-hidden-line {
    display: none;
}

.cm-line.md-fenced-block-summary-line {
    padding: 0;
}

.md-fenced-block-preview {
    display: block;
    width: 100%;
    margin: 0.45rem 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.md-fenced-block-preview.kind-log {
    border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
}

.md-fenced-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 0.85rem;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg-primary) 60%, var(--bg-secondary));
}

.md-fenced-block-meta {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.md-fenced-block-kind {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 1.7rem;
    padding: 0 0.55rem;
    border-radius: var(--radius-full);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.md-fenced-block-count {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.md-fenced-block-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.md-fenced-block-btn {
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: var(--radius-full);
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}

.md-fenced-block-btn.primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.md-fenced-block-body {
    margin: 0;
    max-height: 180px;
    overflow: auto;
    padding: 0.9rem 0.95rem 1rem;
    color: var(--text-primary);
    background: linear-gradient(180deg, color-mix(in srgb, var(--bg-secondary) 88%, transparent), var(--bg-primary));
    font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.45;
    white-space: pre-wrap;
}

/* History Button */
.history-btn {
    background: transparent;
    border: 1px solid var(--border);
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    margin-left: 0.5rem;
    color: var(--text-muted);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.history-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--border-light);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

/* Delete Button */
.delete-btn {
    background: transparent;
    border: none;
    padding: 0.3rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    opacity: 0;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    pointer-events: auto;
    position: relative;
    z-index: 10;
}

.document-view .block:hover .delete-btn,
.document-view .block:focus-within .delete-btn {
    opacity: 0.5;
}

.delete-btn:hover {
    opacity: 1 !important;
    color: var(--danger, #ef4444);
    background: rgba(239, 68, 68, 0.1);
    transform: scale(1.1);
}

/* Content modal delete button is always visible */
.content-modal .delete-btn {
    opacity: 0.6;
}

/* Pin Button */
.pin-btn {
    background: transparent;
    border: none;
    padding: 0.3rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    opacity: 0;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    position: relative;
    z-index: 10;
}

.document-view .block:hover .pin-btn,
.document-view .block:focus-within .pin-btn {
    opacity: 0.5;
}

.pin-btn:hover {
    opacity: 1 !important;
    color: var(--accent);
    background: var(--accent-light, rgba(59, 130, 246, 0.1));
    transform: scale(1.1);
}

/* Pinned (active) state - always visible with accent */
.pin-btn.pinned {
    opacity: 1 !important;
    color: var(--accent);
}

.pin-btn.pinned:hover {
    background: var(--accent-light, rgba(59, 130, 246, 0.1));
    transform: scale(1.1);
}

/* Pinned block visual indicator */
.document-view .block.block-pinned {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-light, rgba(59, 130, 246, 0.15)), var(--shadow-sm);
}

/* Always show metadata bar on pinned blocks */
.document-view .block.block-pinned .block-metadata {
    opacity: 1;
    height: auto;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

/* Content modal pin button is always visible */
.content-modal .pin-btn {
    opacity: 0.6;
}

/* Microphone / Speech-to-Text Button */
.mic-btn {
    background: transparent;
    border: none;
    padding: 0.3rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    opacity: 0;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    position: relative;
    z-index: 10;
}

.document-view .block:hover .mic-btn,
.document-view .block:focus-within .mic-btn {
    opacity: 0.5;
}

.mic-btn:hover {
    opacity: 1 !important;
    color: var(--accent);
    background: var(--accent-light, rgba(59, 130, 246, 0.1));
    transform: scale(1.1);
}

/* Recording (active) state */
.mic-btn.recording {
    opacity: 1 !important;
    color: var(--danger, #ef4444);
    animation: mic-pulse 1.5s ease-in-out infinite;
}

.mic-btn.recording:hover {
    background: rgba(239, 68, 68, 0.1);
    transform: scale(1.1);
}

@keyframes mic-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Keep metadata bar visible during recording */
.document-view .block.block-recording .block-metadata {
    opacity: 1;
    height: auto;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

/* Content modal mic button is always visible */
.content-modal .mic-btn {
    opacity: 0.6;
}

@media (max-width: 768px) {
    .tag-modal.content-modal {
        width: 95vw;
        max-width: 800px;
        height: auto;
        max-height: 90vh;
    }
}
