/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow: auto;
    padding: var(--spacing-xl);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    width: 2rem;
    height: 2rem;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

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

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

/* Ontology Modal Specific */
.ontology-info {
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--background);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.ontology-label-section {
    margin-bottom: var(--spacing-md);
}

.ontology-label-section h4 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.ontology-value-detail {
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--background);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.ontology-detail-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.ontology-detail-label,
.ontology-detail-value {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.ontology-detail-label strong,
.ontology-detail-value strong {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 600;
}

.ontology-detail-label p,
.ontology-detail-value p {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.5;
}

.ontology-value-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: var(--spacing-xs);
}

.ontology-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-sm);
    background: var(--background);
    border-radius: var(--radius-md);
}

.ontology-exact-checkbox {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.875rem;
    cursor: pointer;
}

.ontology-exact-checkbox input[type="checkbox"] {
    cursor: pointer;
}

.ontology-stats {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    padding: var(--spacing-sm);
    background: var(--background);
    border-radius: var(--radius-sm);
}

.ontology-values {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
}

.ontology-values-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.ontology-value-item {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.ontology-value-item:hover {
    background: var(--background);
    border-color: var(--primary);
}

.ontology-value-item.selected {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

/* Side Panel */
.side-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: var(--card);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transition: right 0.3s ease-in-out;
    z-index: 999;
    display: flex;
    flex-direction: column;
}

.side-panel.active {
    right: 0;
}

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

.panel-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.panel-close {
    width: 2rem;
    height: 2rem;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.panel-close:hover {
    color: var(--text);
}

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

/* Product Metrics Panel Content */
.product-metrics-header {
    margin-bottom: var(--spacing-lg);
}

.product-id {
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Monaco', 'Courier New', monospace;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.category-match {
    padding: var(--spacing-md);
    background: var(--background);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
}

.category-match-status {
    font-size: 0.875rem;
    margin-bottom: var(--spacing-xs);
}

.category-versions {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.label-performance {
    margin-bottom: var(--spacing-lg);
}

.label-performance h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
}

.performance-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.performance-stat:last-child {
    border-bottom: none;
}

.performance-stat-label {
    color: var(--text-secondary);
}

.performance-stat-value {
    font-weight: 600;
}

.label-breakdown {
    margin-top: var(--spacing-lg);
}

.label-breakdown h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
}

.label-item {
    padding: var(--spacing-sm);
    background: var(--background);
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-sm);
    font-size: 0.8125rem;
}

.label-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xs);
}

.label-name {
    font-weight: 600;
}

.label-status {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.label-status.perfect {
    background: rgba(34, 197, 94, 0.1);
    color: var(--metric-61-80);
}

.label-status.partial {
    background: rgba(234, 179, 8, 0.1);
    color: var(--metric-41-60);
}

.label-status.mismatch {
    background: rgba(239, 68, 68, 0.1);
    color: var(--metric-0-20);
}

.label-values {
    color: var(--text-secondary);
}

/* Action Buttons */
.panel-action {
    margin-top: var(--spacing-lg);
}

.panel-action .btn {
    width: 100%;
    justify-content: center;
}

/* Loading Spinner */
.spinner {
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: var(--spacing-xl) auto;
}

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

/* Tooltip */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: var(--text);
    color: var(--card);
    text-align: center;
    border-radius: var(--radius-sm);
    padding: var(--spacing-sm);
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.8125rem;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* Responsive */
@media (max-width: 768px) {
    .side-panel {
        width: 100%;
        right: -100%;
    }
    
    .modal-content {
        max-width: 100%;
        margin: var(--spacing-md);
    }
}
