/* ======================================
   KG COMPONENTS - Shared UI Components
   ====================================== */

/* ======================================
   DETAIL PANEL STYLES (Clean Markdown)
   ====================================== */
.kg-detail-content {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1a202c;
    line-height: 1.7;
    font-size: 0.95rem;
}

.kg-detail-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d3748;
    margin: 1.5em 0 0.75em 0;
    padding-bottom: 0.5em;
    border-bottom: 1px solid #e2e8f0;
}

.kg-detail-content h4 {
    font-size: 1rem;
    font-weight: 600;
    color: #4a5568;
    margin: 1.25em 0 0.5em 0;
}

.kg-detail-content p {
    margin: 0 0 1em 0;
}

/* Hide first heading in report — already shown in modal header */
.model-report > h2:first-child {
    display: none;
}

.kg-detail-content strong {
    color: #2d3748;
}

.kg-detail-content a {
    color: #3182ce;
    text-decoration: none;
}

.kg-detail-content a:hover {
    text-decoration: underline;
}

.kg-detail-content .md-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    font-size: 0.875rem;
}

.kg-detail-content .md-table th,
.kg-detail-content .md-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.kg-detail-content .md-table th {
    font-weight: 600;
    color: #4a5568;
    background: #f7fafc;
}

.kg-detail-content .md-table tr:hover td {
    background: #f7fafc;
}

.kg-detail-content .math-block {
    margin: 1em 0;
    padding: 12px 16px;
    background: #f7fafc;
    border-radius: 6px;
    overflow-x: auto;
}

.kg-detail-content .math-inline {
    padding: 0 2px;
}

/* ======================================
   MODAL STYLES
   ====================================== */
.kg-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.kg-modal.show {
    opacity: 1;
    visibility: visible;
}

.kg-modal.hidden {
    opacity: 0;
    visibility: hidden;
}

.kg-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.kg-modal-dialog {
    position: relative;
    width: 90%;
    max-width: 1200px;
    max-height: 85vh;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.kg-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    gap: 12px;
}

.kg-modal-thumb-wrap {
    flex-shrink: 0;
}

.kg-modal-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.kg-modal-type-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 10px;
    color: #fff;
    font-size: 1.3rem;
}

.kg-modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1a202c;
    flex: 1;
    min-width: 0;
}

.kg-modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kg-modal-action-btn,
.kg-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    color: #718096;
    cursor: pointer;
    transition: all 0.15s ease;
}

.kg-modal-action-btn:hover {
    background: #edf2f7;
    color: #2d3748;
}

/* Labeled variant: the "what do I do next?" actions carry text, not just an icon. */
.kg-modal-action-btn.labeled {
    width: auto;
    padding: 0 12px;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
}

/* Primary next-step: send the inspected entity into the Experiment Builder. */
.kg-modal-builder-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border-radius: 6px;
    background: #3b4ce2;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s ease;
}

.kg-modal-builder-btn:hover {
    background: #2f3fc0;
    color: #fff;
}

.kg-modal-close:hover {
    background: #fed7d7;
    color: #c53030;
}

.kg-modal-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* ---- Mobile modal layout ----
   The header packs a thumb, title and two labelled action buttons on one row;
   on a phone the buttons overflow and print on top of the title. Let the header
   wrap so the title keeps the first row and the actions drop to a full-width
   second row. Also give the dialog a little more of the viewport. */
@media (max-width: 600px) {
    .kg-modal-dialog {
        width: 94%;
        max-height: 90vh;
    }

    /* Float the close button to the conventional top-right corner so the
       thumb + title keep the first row and the two action buttons get a clean
       full-width second row. */
    .kg-modal-header {
        flex-wrap: wrap;
        align-items: center;
        padding: 14px 16px;
        padding-right: 48px;
        position: relative;
    }

    .kg-modal-close {
        position: absolute;
        top: 10px;
        right: 12px;
    }

    .kg-modal-title {
        font-size: 1.05rem;
        overflow-wrap: anywhere;
    }

    .kg-modal-actions {
        width: 100%;
        order: 3;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Roomier tap targets for the primary next-step actions. */
    .kg-modal-builder-btn,
    .kg-modal-action-btn.labeled {
        height: 38px;
    }

    .kg-modal-content {
        padding: 16px;
    }
}

/* ======================================
   TOOLTIP STYLES
   ====================================== */
.kg-tooltip {
    position: fixed;
    z-index: 10001;
    background: #1a202c;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    max-width: 280px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(5px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.kg-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.kg-tooltip-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.kg-tooltip-title {
    font-weight: 600;
}

.kg-tooltip-symbol {
    font-style: italic;
    opacity: 0.7;
}

.kg-tooltip-type {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 2px;
}
