*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-size: 14px;
    background-color: #f0f2f5; /* Light gray background */
    font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

/* Page root layout */
.page-root {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Main layout */
.main-content {
    display: grid;
    grid-template-columns: 1fr 340px; /* Slightly wider side panel */
    gap: 16px; /* Spacing between columns */
    flex: 1;
    overflow: hidden;
    padding: 16px;
    max-width: 1600px; /* Limit width on large screens */
    margin: 0 auto; /* Center content */
    width: 100%;
}

/* Board area */
.board-area {
    overflow: hidden; /* Hide scrollbars here, handle in container */
    display: flex;
    flex-direction: column;
    height: 100%;
}

.board-container {
    border: 1px solid #e1dfdd;
    border-radius: 8px;
    padding: 24px;
    background: #ffffff;
    flex: 1;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05); /* Subtle shadow */
    transition: background-color 0.2s, border-color 0.2s;
}

.board-container:hover {
    border-color: #c8c6c4;
}

.board-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    opacity: 0.7;
    color: #605e5c;
    text-align: center;
    max-width: 400px;
}

.board-placeholder svg {
    width: 64px;
    height: 64px;
    opacity: 0.5;
    fill: currentColor;
}

/* Info panel */
.info-panel {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-right: 4px; /* Space for scrollbar */
}

/* Custom scrollbar for info panel */
.info-panel::-webkit-scrollbar {
    width: 6px;
}
.info-panel::-webkit-scrollbar-thumb {
    background-color: #c8c6c4;
    border-radius: 3px;
}
.info-panel::-webkit-scrollbar-track {
    background-color: transparent;
}

/* Component list grid */
.component-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.component-item {
    border: 1px solid #edebe9;
    border-radius: 6px;
    padding: 8px;
    background: #faf9f8;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.2s;
}

.component-item:hover {
    background: #ffffff;
    border-color: #c8c6c4;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.component-label {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* Sample images */
.sample-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.sample-image-container {
    position: relative;
    cursor: pointer;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.sample-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s;
}

.sample-image-container:hover {
    border-color: #0078d4; /* Fluent accent color */
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.sample-image-container:hover img {
    transform: scale(1.05);
}

.sample-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 11px;
    padding: 4px 8px;
    opacity: 0;
    transition: opacity 0.2s;
    text-align: center;
}

.sample-image-container:hover .sample-overlay {
    opacity: 1;
}

/* Loading overlay */
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 4px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #ccc;
    border-top-color: #0078d4;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* File input hidden */
.file-input-hidden {
    display: none;
}

/* SVG board */
.board-svg text {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    user-select: none;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto;
    }

    .info-panel {
        max-height: 40vh;
    }
}

/* --- Sidebar Styles --- */

/* Color Groups */
.color-group-item {
    display: flex;
    align-items: center;
    background: #f3f2f1;
    padding: 2px 8px 2px 4px;
    border-radius: 4px;
    font-size: 12px;
}

.color-swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 6px;
    display: inline-block;
}

/* Component List */
.component-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.component-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    border: 1px solid #edebe9;
    border-radius: 4px;
    background: #faf9f8;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    flex-grow: 1;
    min-width: 80px;
}

.component-label {
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    width: 100%;
}

/* Sample Grid */
.sample-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.sample-image-container {
    position: relative;
    cursor: pointer;
    border-radius: 4px;
    overflow: hidden;
    aspect-ratio: 1;
    background-color: #f3f2f1;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.sample-image-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.12);
    border-color: #0078d4;
}

.sample-image-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
    display: block;
}

.sample-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    color: #323130;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    backdrop-filter: blur(4px);
    border-top: 1px solid rgba(0,0,0,0.05);
}


/* Fluent Overrides */
fluent-card {
    padding: 16px;
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #edebe9;
    box-shadow: 0 1.6px 3.6px 0 rgba(0,0,0,0.132), 0 0.3px 0.9px 0 rgba(0,0,0,0.108);
    border-radius: 4px;
    background-color: white;
}

