/* OCN Constitution Management System Styling */

:root {
    /* Light mode color palette - OCN inspired */
    --color-bg: #f5f7fa;
    --color-bg-elevated: #ffffff;
    --color-bg-hover: #e8ecf1;
    --color-surface: #ffffff;
    --color-border: #d1d9e6;
    --color-border-subtle: #e5eaf2;
    
    --color-text: #1a2b3c;
    --color-text-muted: #5a6b7c;
    --color-text-subtle: #8a99aa;
    
    /* Accent - OCN teal/blue */
    --color-accent: #0891b2;
    --color-accent-hover: #0e7490;
    --color-accent-muted: #67cfe0;
    --color-accent-light: #e0f7fa;
    
    /* Semantic colors */
    --color-success: #059669;
    --color-warning: #d97706;
    --color-danger: #dc2626;
    
    /* Typography - OCN uses DM Sans */
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-serif: 'Georgia', 'Times New Roman', Times, serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
}

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

html, body {
    height: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-xl);
    background: #1a2b3c;
    border-bottom: none;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    color: #ffffff;
}

.logo img {
    height: 36px;
    width: auto;
}

.logo h1 {
    font-size: 1.1rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: #ffffff;
}

.logo h1 span {
    color: var(--color-accent-muted);
    font-weight: 700;
}

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

/* User Menu */
.user-menu {
    position: relative;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: auto !important;
    height: auto !important;
    padding: 6px 12px !important;
}

.user-menu-btn svg {
    flex-shrink: 0;
}

.user-display-name {
    font-size: 0.875rem;
    font-weight: 500;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    overflow: hidden;
}

.user-menu-dropdown.hidden {
    display: none;
}

.user-menu-header {
    padding: var(--space-md);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.user-full-name {
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 2px;
}

.user-email {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.user-menu-divider {
    height: 1px;
    background: var(--color-border);
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: none;
    background: transparent;
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.user-menu-item:hover {
    background: var(--color-bg-hover);
}

.user-menu-item svg {
    color: var(--color-text-muted);
}

/* Version Badge in Header */
.version-badge {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-left: var(--space-sm);
}

/* Document Selector */
.document-selector {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: #ffffff;
}

.document-selector label {
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
}

.document-select {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    padding-right: 32px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='white' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    min-width: 200px;
    transition: var(--transition-fast);
}

.document-select:hover {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.document-select:focus {
    outline: none;
    border-color: var(--color-accent-muted);
    box-shadow: 0 0 0 2px rgba(103, 207, 224, 0.3);
}

.document-select option {
    background: #1a2b3c;
    color: #ffffff;
    padding: 8px;
}

/* No Document Selected State */
.no-document-selected {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: var(--space-lg);
    color: var(--color-text-muted);
    text-align: center;
    padding: var(--space-2xl);
}

.no-document-selected svg {
    width: 64px;
    height: 64px;
    opacity: 0.4;
}

.no-document-selected h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

.no-document-selected p {
    font-size: 0.95rem;
    max-width: 400px;
    margin: 0;
}

/* Auto-save Indicator */
.autosave-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.8rem;
    color: #6ee7b7;
    opacity: 0;
    transition: opacity var(--transition-normal);
    padding: var(--space-xs) var(--space-sm);
}

.autosave-indicator.visible {
    opacity: 1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn:hover:not(:disabled) {
    background: var(--color-bg-hover);
    border-color: var(--color-border);
}

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

.btn-primary {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
    color: #ffffff;
}

.btn-sm {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.8rem;
}

.btn-icon {
    padding: var(--space-xs);
    background: transparent;
    border: none;
}

.btn-danger {
    color: var(--color-danger);
}

.btn-danger:hover {
    background: rgba(184, 92, 92, 0.15);
}

/* Main Content Area - Always Split View */
.app-main {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
}

/* Panels */
.panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.panel-left {
    flex: 0 0 380px;
    min-width: 280px;
    border-right: 1px solid var(--color-border);
    background: var(--color-bg-elevated);
}

.panel-right {
    flex: 1;
    min-width: 400px;
    display: flex;
    flex-direction: column;
}

/* Panel Header */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.panel-header h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
}

.panel-toolbar {
    display: flex;
    gap: var(--space-sm);
}

/* Resize handle */
.panel-resize-handle {
    width: 5px;
    background: var(--color-border);
    cursor: col-resize;
    flex-shrink: 0;
    transition: background var(--transition-fast);
}

.panel-resize-handle:hover,
.panel-resize-handle.dragging {
    background: var(--color-accent);
}

/* Navigation Tabs (in right panel) */
.view-tabs {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--space-lg);
    background: var(--color-bg-elevated);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.tabs-left {
    display: flex;
    gap: 0;
}

.tab {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-muted);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab:hover {
    color: var(--color-text);
    background: var(--color-bg-hover);
}

.tab.active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

/* View Panels */
.view-panel {
    display: none;
    flex: 1;
    overflow: hidden;
}

.view-panel.active {
    display: flex;
    flex-direction: column;
}

/* Rendered Document View */
.document-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    background: var(--color-bg);
}

.rendered-content {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--space-2xl) var(--space-2xl) var(--space-2xl) var(--space-2xl);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    font-family: var(--font-serif);
    font-size: 1rem;
    line-height: 1.7;
    text-align: justify;
    hyphens: auto;
}

/* Document element styling - Legislative format */

/* Clickable document elements */
.doc-clickable {
    cursor: pointer;
}

.doc-hover {
    background: var(--color-accent-light);
    border-radius: 4px;
    outline: 1px solid var(--color-accent-muted);
}

.doc-part {
    margin-bottom: var(--space-2xl);
    page-break-before: always;
}

.doc-part:first-child {
    page-break-before: avoid;
}

.doc-part > .element-header {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-align: center;
    margin-bottom: var(--space-lg);
    padding: var(--space-sm) 0;
}

.doc-chapter {
    margin-bottom: var(--space-xl);
}

.doc-chapter > .element-header {
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
    margin-bottom: var(--space-md);
}

.doc-section {
    margin-bottom: var(--space-lg);
}

.doc-section > .element-header {
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    font-style: italic;
    color: var(--color-text);
    text-align: center;
    margin-bottom: var(--space-md);
}

.doc-subsection {
    margin-bottom: var(--space-md);
}

.doc-subsection > .element-header {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.doc-article {
    margin-bottom: var(--space-lg);
    padding-left: 0;
}

.doc-article > .element-header {
    font-weight: 700;
    margin-bottom: var(--space-sm);
}

.doc-article .article-num {
    font-weight: 700;
    color: var(--color-text);
    margin-right: var(--space-sm);
}

.doc-article .article-title {
    font-style: italic;
}

.doc-paragraph {
    margin-bottom: var(--space-md);
    text-indent: 2em;
}

.doc-paragraph:first-child {
    text-indent: 0;
}

.doc-paragraph .para-num {
    font-weight: 600;
    color: var(--color-text);
    margin-right: var(--space-xs);
    text-indent: 0;
    display: inline;
}

/* List wrapper for closing text after lists */
.doc-list-wrapper {
    margin-bottom: var(--space-md);
    text-indent: 0;
}

/* Standard list styling - UL and OL */
.doc-list {
    margin-left: 2.5em;
    margin-bottom: var(--space-md);
    padding-left: 0;
    text-indent: 0;
}

/* Unordered list styling */
ul.doc-list {
    list-style-type: none;
}

ul.doc-list > li {
    position: relative;
    padding-left: 1.5em;
}

ul.doc-list > li::before {
    content: "—";
    position: absolute;
    left: 0;
    color: var(--color-text);
}

/* Ordered list base styling */
ol.doc-list {
    list-style-type: none;
    counter-reset: list-counter;
}

ol.doc-list > li {
    counter-increment: list-counter;
    position: relative;
    padding-left: 2em;
}

ol.doc-list > li::before {
    position: absolute;
    left: 0;
    font-weight: 400;
    color: var(--color-text);
}

/* Alphabetic lower: (a), (b), (c) */
ol.doc-list.list-alpha-lower > li::before {
    content: "(" counter(list-counter, lower-alpha) ")";
}

/* Alphabetic upper: (A), (B), (C) */
ol.doc-list.list-alpha-upper > li::before {
    content: "(" counter(list-counter, upper-alpha) ")";
}

/* Roman lower: (i), (ii), (iii) */
ol.doc-list.list-roman-lower > li::before {
    content: "(" counter(list-counter, lower-roman) ")";
}

/* Roman upper: (I), (II), (III) */
ol.doc-list.list-roman-upper > li::before {
    content: "(" counter(list-counter, upper-roman) ")";
}

/* Decimal with parentheses: (1), (2), (3) */
ol.doc-list.list-decimal-paren > li::before {
    content: "(" counter(list-counter) ")";
}

/* Decimal with dot: 1., 2., 3. */
ol.doc-list.list-decimal > li::before {
    content: counter(list-counter) ".";
}

/* Dash/indent style */
ol.doc-list.list-dash > li::before {
    content: "—";
}

/* List item (point) styling */
.doc-point {
    margin-bottom: var(--space-xs);
    line-height: 1.7;
    text-align: justify;
}

.doc-point-content {
    display: inline;
}

/* Nested lists get different styling */
.doc-list .doc-list {
    margin-top: var(--space-xs);
    margin-left: 1.5em;
}

/* Second level: Roman numerals */
ol.doc-list ol.doc-list {
    counter-reset: list-counter-2;
}

ol.doc-list ol.doc-list > li {
    counter-increment: list-counter-2;
}

ol.doc-list ol.doc-list > li::before {
    content: "(" counter(list-counter-2, lower-roman) ")";
}

/* Third level: Numbers */
ol.doc-list ol.doc-list ol.doc-list {
    counter-reset: list-counter-3;
}

ol.doc-list ol.doc-list ol.doc-list > li {
    counter-increment: list-counter-3;
}

ol.doc-list ol.doc-list ol.doc-list > li::before {
    content: "(" counter(list-counter-3) ")";
}

/* Fourth level: Dash */
ol.doc-list ol.doc-list ol.doc-list ol.doc-list > li::before {
    content: "—";
}

/* Legacy point-num support for backward compatibility */
.doc-point .point-num {
    color: var(--color-text);
    margin-right: var(--space-xs);
    font-weight: 400;
}

.doc-subparagraph {
    font-style: italic;
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

/* Content wrapper */
.doc-content {
    display: block;
}

.doc-content p {
    margin: 0;
    line-height: 1.7;
    text-align: justify;
}

.doc-content p + p {
    margin-top: var(--space-sm);
    text-indent: 2em;
}

/* Tables */
.doc-table-wrapper {
    margin: var(--space-md) 0;
    overflow-x: auto;
}

.doc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: var(--color-bg-elevated);
}

.doc-table th,
.doc-table td {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--color-border);
    text-align: left;
    vertical-align: top;
}

.doc-table th {
    background: var(--color-bg);
    font-weight: 600;
    color: var(--color-text);
}

.doc-table tr:nth-child(even) td {
    background: var(--color-bg);
}

.doc-table tr:hover td {
    background: var(--color-bg-hover);
}

/* Images */
.doc-image-wrapper {
    margin: var(--space-md) 0;
    text-align: center;
}

.doc-image {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--color-border);
    border-radius: 4px;
}

.doc-image-caption {
    margin-top: var(--space-xs);
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-style: italic;
}

/* Tree View */
.tree-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
}

.tree-node {
    user-select: none;
}

.tree-node-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    border-radius: 4px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.tree-node-header:hover {
    background: var(--color-bg-hover);
}

.tree-node-header.selected {
    background: var(--color-accent-muted);
}

.tree-toggle {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    transition: transform var(--transition-fast);
    font-size: 0.7rem;
}

.tree-toggle.collapsed {
    transform: rotate(-90deg);
}

.tree-toggle.empty {
    visibility: hidden;
}

.tree-icon {
    color: var(--color-accent);
    font-size: 0.85rem;
}

.tree-label {
    flex: 1;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-type {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    background: var(--color-bg);
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid var(--color-border-subtle);
    flex-shrink: 0;
}

.tree-actions {
    display: none;
    gap: var(--space-xs);
    flex-shrink: 0;
    max-height: 1em;
}

.tree-node-header:hover .tree-actions {
    display: flex;
}

.tree-children {
    margin-left: var(--space-md);
    border-left: 1px solid var(--color-border-subtle);
    padding-left: var(--space-sm);
}

.tree-children.collapsed {
    display: none;
}

/* Content element nodes (tables, images) */
.tree-content-element .tree-node-header {
    background: var(--color-accent-light);
    border-radius: 4px;
}

.tree-content-icon {
    font-size: 0.9rem;
    margin-right: var(--space-xs);
}

.tree-type-content {
    background: var(--color-accent-light);
    color: var(--color-accent);
    border-color: var(--color-accent-muted);
}

/* XML Editor */
.xml-container {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.xml-editor {
    flex: 1;
    padding: var(--space-md);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    border: none;
    resize: none;
    outline: none;
    white-space: pre;
    overflow: auto;
    tab-size: 2;
}

/* Version Panel Resize Handle */
.version-resize-handle {
    height: 6px;
    background: var(--color-border);
    cursor: row-resize;
    flex-shrink: 0;
    transition: background var(--transition-fast);
    position: relative;
}

.version-resize-handle::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 3px;
    background: var(--color-text-subtle);
    border-radius: 2px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.version-resize-handle:hover {
    background: var(--color-accent);
}

.version-resize-handle:hover::after {
    opacity: 1;
    background: #ffffff;
}

.version-resize-handle.dragging {
    background: var(--color-accent);
}

/* Version Panel */
.version-panel {
    flex-shrink: 0;
    background: var(--color-bg-elevated);
    height: 200px;
    min-height: 100px;
    max-height: 50vh;
    display: flex;
    flex-direction: column;
}

.version-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--color-border-subtle);
    background: var(--color-bg);
}

.version-panel-header h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

.version-list-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-sm);
}

/* Version Release Groups */
.version-release-group {
    margin-bottom: var(--space-sm);
    border: 1px solid var(--color-border-subtle);
    border-radius: 6px;
    overflow: hidden;
}

.version-release-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.version-release-header:hover {
    background: var(--color-bg-hover);
}

.release-toggle {
    color: var(--color-text-muted);
    font-size: 0.7rem;
    transition: transform var(--transition-fast);
}

.release-toggle.collapsed {
    transform: rotate(-90deg);
}

.release-name {
    flex: 1;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text);
}

.release-badge {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--color-accent);
    background: var(--color-accent-light);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Version List Items */
.version-list-items {
    background: var(--color-bg-elevated);
}

.version-list-items.collapsed {
    display: none;
}

.version-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-xs) var(--space-md);
    padding-left: calc(var(--space-md) + var(--space-lg));
    border-bottom: 1px solid var(--color-border-subtle);
    transition: background var(--transition-fast);
}

.version-item:last-child {
    border-bottom: none;
}

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

.version-item.current {
    background: var(--color-accent-light);
}

.version-info {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.version-number {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text);
}

.version-number.major {
    color: var(--color-accent);
    font-weight: 600;
}

.version-number.minor {
    color: var(--color-text-muted);
}

.version-time {
    font-size: 0.7rem;
    color: var(--color-text-subtle);
}

.version-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.current-badge {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--color-success);
    background: rgba(61, 122, 74, 0.1);
    padding: 2px 8px;
    border-radius: 3px;
}

.version-load-btn {
    font-size: 0.7rem;
    padding: 2px 8px;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

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

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--color-text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
}

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

.modal-footer {
    display: flex;
    gap: var(--space-md);
    justify-content: flex-end;
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--color-border);
}

/* Modal Description */
.modal-description {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-bottom: var(--space-lg);
    line-height: 1.5;
}

/* Form fields */
.form-field {
    margin-bottom: var(--space-md);
}

.form-field label {
    display: block;
    margin-bottom: var(--space-xs);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.form-field input,
.form-field textarea {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    font-family: var(--font-sans);
    font-size: 1rem;
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    outline: none;
    transition: border-color var(--transition-fast);
}

.form-field input:focus,
.form-field textarea:focus {
    border-color: var(--color-accent);
}

.form-field textarea {
    min-height: 100px;
    resize: vertical;
}

.field-hint {
    display: block;
    margin-top: var(--space-xs);
    font-size: 0.75rem;
    color: var(--color-text-subtle);
    font-style: italic;
}

.field-hint code {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    background: var(--color-bg);
    padding: 2px 6px;
    border-radius: 3px;
    font-style: normal;
}

/* Element Path Display */
.element-path-field {
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--color-border-subtle);
}

.element-path {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg);
    border-radius: 6px;
    font-size: 0.85rem;
}

.path-segment {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.path-type {
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-subtle);
    background: var(--color-border-subtle);
    padding: 2px 6px;
    border-radius: 3px;
}

.path-id {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.path-segment-current .path-type {
    background: var(--color-accent-light);
    color: var(--color-accent);
}

.path-segment-current .path-id {
    color: var(--color-text);
    font-weight: 500;
}

.path-separator {
    color: var(--color-text-subtle);
    font-weight: 300;
    margin: 0 2px;
}

/* Context Menu */
.context-menu {
    position: fixed;
    z-index: 1001;
    min-width: 200px;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.context-menu.hidden {
    display: none;
}

.context-menu-header {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-subtle);
    background: var(--color-bg);
}

.context-menu-item {
    display: block;
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--color-text);
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.context-menu-item:hover {
    background: var(--color-bg-hover);
}

.context-menu-separator {
    height: 1px;
    background: var(--color-border-subtle);
    margin: var(--space-xs) 0;
}

.context-menu-subheader {
    padding: var(--space-xs) var(--space-md);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-subtle);
    background: var(--color-bg);
}

.context-menu-icon {
    margin-right: var(--space-xs);
}

/* Table Editor Modal */
.modal-large {
    max-width: 800px;
}

.table-editor-controls {
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--color-border-subtle);
}

.form-row {
    display: flex;
    align-items: flex-end;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.form-row .form-field {
    margin-bottom: 0;
    flex: 0 0 100px;
}

.table-actions {
    display: flex;
    gap: var(--space-sm);
}

.table-preview-container {
    max-height: 400px;
    overflow: auto;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: var(--space-md);
    background: var(--color-bg);
}

.table-editor-preview {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table-editor-preview th,
.table-editor-preview td {
    padding: var(--space-sm);
    border: 1px solid var(--color-border);
    min-width: 80px;
}

.table-editor-preview th {
    background: var(--color-bg-elevated);
    font-weight: 600;
}

.table-editor-preview .editable-cell {
    outline: none;
    cursor: text;
}

.table-editor-preview .editable-cell:focus {
    background: var(--color-accent-light);
    outline: 2px solid var(--color-accent);
}

.table-editor-preview .editable-cell.focused {
    background: var(--color-accent-light);
}

/* Help Button in Header */
.btn-icon-header {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon-header:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    color: #ffffff;
}

.btn-icon-header:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(103, 207, 224, 0.3);
}

/* Image Modal */
.image-preview-container {
    margin-bottom: var(--space-md);
    text-align: center;
    padding: var(--space-md);
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.image-preview-container.hidden {
    display: none;
}

.image-preview-container img {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-sm);
}

#image-file-input {
    width: 100%;
    padding: var(--space-sm);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
}

#image-file-input:hover {
    border-color: var(--color-accent);
}

#image-file-input::file-selector-button {
    padding: var(--space-xs) var(--space-md);
    margin-right: var(--space-md);
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast);
}

#image-file-input::file-selector-button:hover {
    background: var(--color-accent-hover);
}

/* Help Modal */
.modal-help {
    max-width: 700px;
    max-height: 85vh;
}

.hotkeys-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.hotkeys-category {
    border: 1px solid var(--color-border-subtle);
    border-radius: 8px;
    overflow: hidden;
}

.hotkeys-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border-subtle);
}

.hotkeys-category-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
}

.hotkeys-category-description {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.hotkeys-list {
    padding: var(--space-sm) 0;
}

.hotkey-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-xs) var(--space-md);
    transition: background var(--transition-fast);
}

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

.hotkey-description {
    font-size: 0.875rem;
    color: var(--color-text);
}

.hotkey-keys {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 var(--space-sm);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

kbd.kbd-wide {
    min-width: auto;
    padding: 0 var(--space-sm);
}

.hotkey-separator {
    font-size: 0.75rem;
    color: var(--color-text-subtle);
    margin: 0 2px;
}

.help-footer-hint {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-right: auto;
}

.help-footer-hint kbd {
    margin: 0 2px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg-elevated);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* Loading state */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    color: var(--color-text-muted);
}

/* Cover page styling */
.doc-coverpage {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    margin-bottom: var(--space-lg);
    border-bottom: none;
}

.doc-coverpage .doc-type-label {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-accent);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: var(--space-sm);
}

.doc-coverpage .doc-title {
    font-family: var(--font-sans);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-lg);
    line-height: 1.4;
}

.doc-coverpage .doc-subtitle {
    font-size: 1rem;
    color: var(--color-text-muted);
    margin-bottom: var(--space-md);
}

.doc-preface {
    margin-bottom: var(--space-2xl);
    padding-bottom: var(--space-xl);
    text-align: justify;
}

.doc-preface > .element-header {
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
    margin-bottom: var(--space-md);
}

/* Glossary/Definitions styling */
.doc-glossary {
    margin-top: var(--space-2xl);
    padding-top: var(--space-xl);
}

.doc-glossary > .element-header {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-align: center;
    margin-bottom: var(--space-lg);
}

.doc-definition {
    margin-bottom: var(--space-md);
    padding-left: var(--space-lg);
    text-indent: -var(--space-lg);
}

.doc-definition .def-term {
    font-weight: 700;
    color: var(--color-text);
}

.doc-definition .def-meaning {
    color: var(--color-text);
}

/* Schedule/Annex styling */
.doc-schedule {
    margin-top: var(--space-2xl);
    padding-top: var(--space-xl);
    page-break-before: always;
}

.doc-schedule > .element-header {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-align: center;
    margin-bottom: var(--space-lg);
}
