/* Organisation Library (frontend/library.*) — builds on styles.css theme variables. */

.lib-header { padding: 28px 0 8px; }
.lib-header h4 { margin: 0 0 4px; font-weight: 800; }
.lib-header p { margin: 0; color: var(--text-secondary); }
.lib-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.lib-toolbar .lib-org-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-weight: 600; }
.lib-role { font-size: 0.75rem; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); color: var(--text-secondary); }

.lib-search { position: relative; flex: 1; min-width: 220px; max-width: 520px; }
.lib-search input { width: 100%; }
.lib-search-results { position: absolute; z-index: 50; top: calc(100% + 4px); left: 0; right: 0; max-height: 60vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); padding: 8px; display: none; }
.lib-search-results.open { display: block; }
.lib-search-results .hit { padding: 8px; border-radius: 6px; cursor: pointer; }
.lib-search-results .hit:hover, .lib-search-results .hit:focus { background: var(--bg); outline: none; }
.lib-search-results .hit small { color: var(--text-secondary); display: block; }

.lib-partner-banner { margin: 12px 0 0; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--accent); background: var(--surface); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.lib-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin: 20px 0 0; padding: 0; list-style: none; }
.lib-tabs button { background: none; border: none; color: var(--text-secondary); padding: 10px 14px; cursor: pointer; font-weight: 600; border-bottom: 3px solid transparent; display: inline-flex; align-items: center; gap: 6px; font-size: 0.95rem; }
.lib-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.lib-tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lib-tabs .badge-count { background: var(--accent); color: var(--bg); border-radius: 999px; padding: 0 7px; font-size: 0.75rem; min-width: 20px; text-align: center; }

.lib-panel { padding: 20px 0 60px; }
.lib-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.lib-card h6 { margin: 0 0 12px; font-weight: 700; }
.lib-card .muted, .lib-muted { color: var(--text-secondary); font-size: 0.9rem; }

.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.lib-grid .span-2 { grid-column: span 2; }
.lib-grid .span-all { grid-column: 1 / -1; }
@media (max-width: 600px) { .lib-grid .span-2 { grid-column: 1 / -1; } }

.lib-field label { display: block; font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 4px; font-weight: 600; }
.lib-field input.browser-default, .lib-field select.browser-default, .lib-field textarea.browser-default,
.lib-input { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 0.95rem; font-family: inherit; box-sizing: border-box; }
.lib-field textarea.browser-default { min-height: 90px; resize: vertical; }
.lib-field textarea.tall { min-height: 220px; }
.lib-field input:focus, .lib-field select:focus, .lib-field textarea:focus, .lib-input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.lib-field input[readonly], .lib-field textarea[readonly] { opacity: .75; }
.lib-field .hint { font-size: 0.75rem; color: var(--text-secondary); margin-top: 3px; }
.lib-check { display: flex; align-items: center; gap: 8px; padding-top: 22px; }
.lib-check input { position: static !important; opacity: 1 !important; pointer-events: auto !important; width: 18px; height: 18px; accent-color: var(--accent); }

.lib-repeat { border: 1px dashed var(--border); border-radius: 8px; padding: 10px; }
.lib-repeat-row { border-bottom: 1px solid var(--border); padding: 10px 0; position: relative; }
.lib-repeat-row:last-of-type { border-bottom: none; }
.lib-repeat-row .row-remove { position: absolute; top: 6px; right: 0; }
.lib-repeat-title { font-weight: 700; font-size: 0.85rem; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }

.lib-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.lib-list { display: flex; flex-direction: column; gap: 8px; }
.lib-item { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.lib-item .title { font-weight: 700; }
.lib-item .meta { font-size: 0.85rem; color: var(--text-secondary); margin-top: 2px; }
.lib-item .tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.lib-item .item-actions { display: flex; gap: 4px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.lib-tag { font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-secondary); }
.lib-tag.ok { border-color: #3fb67b; color: #3fb67b; }
.lib-tag.warn { border-color: #e0a526; color: #e0a526; }
.lib-tag.bad { border-color: var(--danger, #e05252); color: var(--danger, #e05252); }
.lib-tag.accent { border-color: var(--accent); color: var(--accent); }

.lib-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.lib-table th, .lib-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.lib-table th { color: var(--text-secondary); font-weight: 600; font-size: 0.8rem; }
.lib-table code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 0.8rem; }

.lib-derived { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.lib-derived .stat { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.lib-derived .stat b { display: block; font-size: 1.25rem; }
.lib-derived .stat span { font-size: 0.78rem; color: var(--text-secondary); }

.lib-dropzone { border: 2px dashed var(--border); border-radius: 10px; padding: 22px; text-align: center; cursor: pointer; transition: border-color .2s; }
.lib-dropzone.drag { border-color: var(--accent); }
.lib-dropzone i { font-size: 40px; color: var(--accent); }

.lib-progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.lib-progress > div { height: 100%; background: var(--accent); transition: width .3s; }

.lib-asset-preview { max-width: 220px; max-height: 120px; background: #fff; border-radius: 6px; padding: 6px; border: 1px solid var(--border); display: block; margin: 8px 0; }
.lib-notice { border-left: 3px solid var(--accent); padding: 8px 12px; background: var(--bg); border-radius: 4px; font-size: 0.88rem; margin: 8px 0 12px; }
.lib-empty { padding: 24px; text-align: center; color: var(--text-secondary); border: 1px dashed var(--border); border-radius: 8px; }

.lib-modal { max-height: 88vh; width: min(980px, 94vw); background: var(--surface); color: var(--text); border-radius: 12px; }
.lib-modal .modal-content { padding: 20px 22px; }
.lib-modal .modal-footer { background: var(--surface); border-top: 1px solid var(--border); }
.lib-modal h5 { margin-top: 0; font-weight: 800; }

.lib-conflict { margin-top: 6px; font-size: 0.85rem; }
.lib-conflict label { display: flex; gap: 8px; align-items: center; margin: 2px 0; color: var(--text); cursor: pointer; }
.lib-conflict input[type=radio] { position: static !important; opacity: 1 !important; pointer-events: auto !important; accent-color: var(--accent); }
.lib-quote { font-style: italic; color: var(--text-secondary); font-size: 0.82rem; margin-top: 4px; }

.btn-tiny { padding: 0 10px; height: 28px; line-height: 28px; font-size: 0.8rem; text-transform: none; }
.lib-danger { color: var(--danger, #e05252) !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
