/* Combiner — layout & previews (Bootstrap handles typography, forms, buttons). */

.combiner-split {
    min-height: 0;
}

.combiner-sidebar {
    width: min(450px, 100%);
    max-width: min(450px, 100%);
}

@media (min-width: 992px) {
    .combiner-sidebar {
        width: min(450px, var(--app-left-panel-width, 420px));
    }
}

.combiner-sidebar-scroll {
    scrollbar-width: thin;
    scrollbar-color: var(--bs-secondary-bg) var(--bs-tertiary-bg);
}

.combiner-sidebar-scroll::-webkit-scrollbar {
    width: 8px;
}

.combiner-sidebar-scroll::-webkit-scrollbar-track {
    background: var(--bs-tertiary-bg);
}

.combiner-sidebar-scroll::-webkit-scrollbar-thumb {
    background: var(--bs-secondary-bg);
    border-radius: 10px;
}

.layout-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.375rem;
}

.layout-grid .mode-btn.active {
    /* Reinforce Bootstrap active state for layout tiles */
    box-shadow: 0 0 0 1px var(--bs-primary);
}

/* --- Viewport & canvas --- */
.combiner-viewport {
    background-color: var(--bs-dark);
    overflow: hidden;
}

[data-bs-theme="light"] .combiner-viewport {
    background-color: #dee2e6;
}

canvas#master-canvas {
    box-shadow: var(--bs-box-shadow-lg);
    image-rendering: pixelated;
    aspect-ratio: 16 / 9;
    width: 100%;
    height: auto;
    max-height: 100%;
    object-fit: contain;
    border: 1px solid var(--bs-border-color);
}

#hidden-sandbox {
    position: absolute;
    top: -9999px;
    left: -9999px;
    visibility: hidden;
}

iframe {
    width: 640px;
    height: 360px;
    border: none;
}

/* --- Library modal (custom overlay; not Bootstrap Modal JS) --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 1040;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.combiner-lib-dialog {
    width: 90%;
    max-width: 1200px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: var(--bs-border-radius-lg);
}

.combiner-lib-header {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    padding: 0.75rem 1rem;
}

.combiner-lib-header-start {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
    flex: 1 1 220px;
}

.lib-grid {
    flex-grow: 1;
    padding: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    grid-auto-rows: min-content;
    gap: 1.25rem;
    align-content: start;
    overflow-y: auto;
    min-height: 0;
}

.lib-empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2.5rem 1.5rem;
    border: 1px dashed var(--bs-border-color);
    border-radius: var(--bs-border-radius-lg);
    background: rgba(var(--bs-secondary-rgb), 0.15);
    max-width: 28rem;
    margin-inline: auto;
}

.lib-empty-icon {
    font-size: 2.5rem;
    opacity: 0.45;
    margin-bottom: 0.75rem;
}

.lib-empty-title {
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.lib-grid::-webkit-scrollbar {
    width: 8px;
}

.lib-grid::-webkit-scrollbar-track {
    background: var(--bs-tertiary-bg);
}

.lib-grid::-webkit-scrollbar-thumb {
    background: var(--bs-secondary-bg);
    border-radius: 10px;
}

.drop-overlay {
    position: absolute;
    inset: 0;
    background: rgba(var(--bs-primary-rgb), 0.12);
    border: 3px dashed var(--bs-primary);
    z-index: 50;
    pointer-events: none;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: var(--bs-border-radius-lg);
}

.drop-overlay-msg {
    color: var(--bs-primary);
    font-size: clamp(1.1rem, 2.5vw, 1.75rem);
    font-weight: bold;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
    text-align: center;
    padding: 1rem;
}

.combiner-lib-dialog.drag-active .drop-overlay {
    display: flex;
}

/* Library cards */
.lib-card {
    background: var(--bs-secondary-bg);
    border: 2px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.1s;
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: var(--bs-box-shadow);
    min-height: 220px;
    height: auto;
}

.lib-card:hover {
    transform: translateY(-2px);
    border-color: var(--bs-secondary-color);
}

.lib-card:focus {
    outline: none;
}

.lib-card:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

.lib-card.selected {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 1px rgba(var(--bs-primary-rgb), 0.35);
}

.lib-card.selected::after {
    content: "✔";
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--bs-primary);
    color: var(--bs-primary-bg-subtle, #000);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: var(--bs-box-shadow-sm);
}

.lib-thumb-container {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-bottom: 1px solid var(--bs-border-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.lib-thumb {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.lib-thumb-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    opacity: 0.65;
}

.thumb-placeholder {
    color: var(--bs-secondary-color);
    font-size: 0.8rem;
    font-style: italic;
}

.lib-info {
    padding: 12px;
    font-size: 0.85rem;
    text-align: left;
    background: var(--bs-body-bg);
    flex-grow: 1;
}

.lib-title {
    font-weight: bold;
    margin-bottom: 4px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lib-desc {
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}

.lib-delete {
    position: absolute;
    top: 5px;
    right: 5px;
    padding: 0;
    margin: 0;
    background: rgba(0, 0, 0, 0.75);
    color: var(--bs-danger);
    border: 1px solid var(--bs-danger);
    border-radius: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background-color 0.15s, color 0.15s;
    font-size: 14px;
    z-index: 5;
    line-height: 1;
}

.lib-card:hover .lib-delete {
    opacity: 1;
}

.lib-delete:hover {
    background: var(--bs-danger);
    color: var(--bs-white);
}

.combiner-sort-select {
    max-width: 200px;
}

/* Layer card: long comma-separated control names must wrap, not clip */
.combiner-detected-controls {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    word-wrap: break-word;
}
