/* Assembly Viewer Styles */

/* Subcategory Selection */
#subcategory-selection {
    padding: 20px;
    display: block;
    height: 710px;
    overflow-y: auto;
}

/* Hide headings that are only for TOC */
.toc-only {
    display: none !important;
}

#subcategory-selection h2 {
    margin-top: 0;
    margin-bottom: 20px;
    text-align: center;
}

.subcategory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    padding: 10px;
}

.subcategory-card {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid #444;
    border-radius: 8px;
    padding: 30px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.subcategory-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #666;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.subcategory-card h3 {
    margin: 0;
    font-size: 1.2em;
    color: inherit;
}

/* Overview Block */
#overview-content,
[id^="subcat-overview-"] {
    padding: 20px;
    display: block;
    height: 710px;
    overflow-y: auto;
    border: 1px solid #444;
    border-radius: 8px;
}

/* Step Content Overlay - at top right of viewer */
#step-content-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    max-width: min(75%, 400px);
    width: fit-content;
    z-index: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    padding: 12px 16px;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
    transition: all 0.3s ease;
}

#step-content-overlay.hidden {
    display: none;
}

#step-content-overlay h3 {
    margin: 0 0 8px 0;
    color: white;
    font-size: 1.1em;
}

#step-content-overlay p {
    margin: 0;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9em;
    line-height: 1.5;
}

#step-content-overlay a {
    color: var(--md-accent-fg-color);
}

/* Model Viewer Container */
#model-viewer-container {
    display: block;
    width: 100%;
    margin-bottom: 15px;
}

/* Model Viewer */
#model-viewer {
    position: relative;
    width: 100%;
    height: 600px;
    border: 1px solid #444;
    border-radius: 8px;
    display: block;
    overflow: hidden;
}

/* Camera Overlay */
#camera-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.75em;
    z-index: 1;
    pointer-events: auto;
    display: none;
    cursor: pointer;
    transition: background 0.2s;
}

#camera-overlay:hover {
    background: rgba(0, 0, 0, 0.95);
}

/* Camera Info */
.camera-info {
    font-family: monospace;
}


/* Parts Panel */
#parts-panel {
    overflow-y: auto;
    margin-top: 6px;
    flex: 1 1 auto;
    min-height: 0;
    padding-right: 4px;
}

#parts-panel h3 {
    color: white;
    margin: 0 0 8px 0;
    font-size: 0.9em;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 3px;
}

/* Model overlay content container */
.model-overlay-content {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 1;
    display: flex;
    flex-direction: column;
    max-height: calc(100% - 16px);
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    padding: 6px;
    transition: transform 0.3s ease;
}

.model-overlay-content > * {
    pointer-events: auto; /* Re-enable pointer events for children */
}

/* Parts header - contains buttons and collapse */
.parts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    gap: 4px;
    overflow: visible;
}

.parts-buttons {
    display: flex;
    gap: 4px;
    overflow: visible;
}

/* Collapse button styling */
.collapse-button svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Collapsed state - hide parts list and make buttons vertical */
.model-overlay-content.collapsed #parts-panel {
    display: none !important;
}

.model-overlay-content.collapsed .parts-header {
    flex-direction: column-reverse;
    align-items: stretch;
    margin-bottom: 0;
}

.model-overlay-content.collapsed .parts-buttons {
    flex-direction: column;
}

.part-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    margin-bottom: 2px;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s;
    color: #eee;
    background: rgba(255, 255, 255, 0.1);
}

.part-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

.visibility-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.visibility-icon svg {
    width: 100%;
    height: 100%;
    fill: #888;
    display: block;
}

.visibility-icon.visible svg {
    fill: var(--md-code-hl-keyword-color);
}

.part-name {
    font-size: 0.8em;
    user-select: none;
}

.parts-button {
    margin-right: 5px;
    font-size: 0.85em;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.parts-button.icon-button {
    padding: 4px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 0;
    box-shadow: 3px 3px 1px rgb(0 0 0 / 20%);
    position: relative;
    --tooltip-offset: 8px;
}

.parts-button.icon-button svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Shared tooltip styles */
.parts-button.icon-button[data-tooltip]::after,
.color-box-wrapper[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + var(--tooltip-offset));
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.75em;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-weight: 400;
    line-height: 1.4;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 100000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.parts-button.icon-button[data-tooltip]:hover::after,
.color-box-wrapper[data-tooltip]:hover::after {
    opacity: 1;
}

#select-all-parts {
    background: var(--md-code-hl-keyword-color);
}

#deselect-all-parts {
    background: var(--md-default-fg-color--lighter);
}

#toggle-focus {
    background: var(--md-accent-fg-color);
}

#collapse-parts {
    background: rgba(255, 255, 255, 0.15);
}

#collapse-parts:hover {
    background: rgba(255, 255, 255, 0.25);
}

#toggle-step-info {
    background: var(--md-primary-fg-color);
}

/* Step Navigation - Overlay at bottom of viewer */
#step-nav {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    z-index: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    padding: 6px;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
}

.step-nav-button {
    padding: 4px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85em;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    border-radius: 4px;
    transition: all 0.2s;
    box-shadow: 3px 3px 1px rgb(0 0 0 / 20%);
}

.step-nav-button svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.step-nav-button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.25);
}

.step-nav-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

#step-counter {
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    min-width: 90px;
    text-align: center;
    padding: 0 8px;
}

/* Loading Overlay */
#loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 8px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top: 5px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    color: #ffffff;
    margin-top: 20px;
    font-size: 16px;
    font-weight: 500;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-overlay.hidden {
    display: none;
}

/* Color Picker Overlay */
.color-picker-overlay {
    padding: 8px 6px;
    pointer-events: auto;
    display: none;
    transition: all 0.3s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 6px;
    min-width: 200px;
}

.color-picker-overlay.visible {
    display: block;
}

.color-boxes-container {
    display: flex;
    gap: 4px;
}

/* Color box wrapper */
.color-box-wrapper {
    position: relative;
    --tooltip-offset: 8px;
}

.color-box {
    width: 28px;
    height: 28px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 3px 3px 1px rgb(0 0 0 / 20%);
    position: relative;
    overflow: hidden;
}

.color-box:hover {
    border-color: rgba(255, 255, 255, 0.6);
}

/* Color input styling - make it fill the box but invisible */
.color-box .color-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: none;
}

#open-color-picker {
    background: #6e3fa3;
}

/* Reset colors button */
.reset-button {
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.reset-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.reset-button svg {
    width: 18px;
    height: 18px;
    fill: rgba(255, 255, 255, 0.9);
}
