/* ==========================================================================
   AOP Network Graph — Page-specific styles
   Loaded only from templates/aop-network.html
   Uses VHP4Safety CSS tokens from main.css :root
   ========================================================================== */

/* --------------------------------------------------------------------------
   Page Header
   -------------------------------------------------------------------------- */
.aop-page-header {
    padding: 32px 0 20px;
}

.aop-page-header__title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-primary-dark);
    margin: 0 0 8px;
}

.aop-page-header__subtitle {
    font-size: 0.95rem;
    color: var(--color-text-secondary, #555);
    margin: 0;
    max-width: 680px;
}

/* --------------------------------------------------------------------------
   AOP Selector Bar
   -------------------------------------------------------------------------- */
.aop-selector-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--color-white, #fff);
    border: 1px solid var(--color-border, #ddd);
    border-radius: 4px;
    padding: 14px 16px;
    margin-bottom: 24px;
}

.aop-selector-bar__label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-primary-dark);
    white-space: nowrap;
    flex-shrink: 0;
}

.aop-selector-bar__select {
    flex: 1;
}

/* --------------------------------------------------------------------------
   Card Search Input
   -------------------------------------------------------------------------- */
.aop-card-search-wrap {
    margin-bottom: 16px;
}

.aop-card-search {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9rem;
    border: 1px solid var(--color-border, #ddd);
    border-radius: 4px;
    background: var(--color-white, #fff);
    color: var(--color-text-primary, #222);
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.15s ease;
}

.aop-card-search:focus {
    border-color: var(--color-primary-blue);
}

/* --------------------------------------------------------------------------
   AOP Card Grid
   -------------------------------------------------------------------------- */
.aop-card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    content-visibility: auto;
    margin-bottom: 32px;
}

@media (max-width: 1024px) {
    .aop-card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .aop-card-grid {
        grid-template-columns: 1fr;
    }
}

.aop-card-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--color-text-secondary, #555);
    font-size: 0.9rem;
}

/* --------------------------------------------------------------------------
   AOP Card
   -------------------------------------------------------------------------- */
.aop-card {
    background: var(--color-white, #fff);
    border: 1px solid var(--color-border, #ddd);
    border-radius: 6px;
    padding: 16px;
    cursor: pointer;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.aop-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--color-primary-blue);
}

.aop-card:focus {
    outline: 2px solid var(--color-primary-blue);
    outline-offset: 2px;
}

.aop-card__id {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-primary-dark);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.aop-card__title {
    font-size: 0.875rem;
    color: var(--color-text-primary, #222);
    line-height: 1.4;
    flex: 1;
}

.aop-card__ke-count {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-white, #fff);
    background: var(--color-primary-blue);
    border-radius: 12px;
    padding: 2px 10px;
    align-self: flex-start;
    margin-top: 4px;
}

/* --------------------------------------------------------------------------
   Back Button
   -------------------------------------------------------------------------- */
.aop-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-primary-blue);
    background: none;
    border: 1px solid var(--color-primary-blue);
    border-radius: 4px;
    padding: 8px 14px;
    cursor: pointer;
    margin-bottom: 16px;
    transition: background 0.15s ease, color 0.15s ease;
}

.aop-back-btn:hover {
    background: var(--color-primary-blue);
    color: var(--color-white, #fff);
}

/* --------------------------------------------------------------------------
   Cytoscape Graph Container
   -------------------------------------------------------------------------- */
#cy {
    width: 100%;
    min-height: 500px;
    border: 1px solid var(--color-border, #ddd);
    border-radius: 6px;
    background: var(--color-bg-page, #f5f5f7);
    margin-bottom: 32px;
}

/* --------------------------------------------------------------------------
   KE Side Panel
   -------------------------------------------------------------------------- */
.ke-side-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 360px;
    height: 100vh;
    background: var(--color-white, #fff);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: var(--z-graph-panel, 10000);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.ke-side-panel--open {
    transform: translateX(0);
}

.ke-side-panel__close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--color-text-secondary, #555);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.ke-side-panel__close:hover {
    background: var(--color-bg-page, #f5f5f7);
    color: var(--color-primary-dark);
}

.ke-side-panel__content {
    padding: 20px 20px 20px;
    padding-top: 48px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ke-side-panel__ke-type {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-white, #fff);
    border-radius: 4px;
    padding: 3px 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    align-self: flex-start;
}

.ke-side-panel__ke-type--mie {
    background: var(--color-primary-pink);
}

.ke-side-panel__ke-type--ke {
    background: var(--color-primary-blue);
}

.ke-side-panel__ke-type--ao {
    background: var(--color-secondary-teal);
}

.ke-side-panel__title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-primary-dark);
    margin: 0;
    line-height: 1.4;
}

.ke-side-panel__id {
    font-size: 0.8rem;
    color: var(--color-text-secondary, #555);
    margin: 0;
}

.ke-side-panel__section {
    border-top: 1px solid var(--color-border, #ddd);
    padding-top: 12px;
}

.ke-side-panel__section-heading {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-secondary, #555);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 8px;
}

.ke-side-panel__aop-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ke-side-panel__aop-list li {
    font-size: 0.825rem;
    color: var(--color-text-primary, #222);
    padding: 4px 0;
    border-bottom: 1px solid var(--color-bg-page, #f5f5f7);
}

.ke-side-panel__actions {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--color-border, #ddd);
}

.ke-side-panel__select-btn {
    width: 100%;
    padding: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-white, #fff);
    background: var(--color-primary-pink);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.ke-side-panel__select-btn:hover {
    opacity: 0.88;
}

/* --------------------------------------------------------------------------
   Inline AOP Graph Panel (mapper page)
   -------------------------------------------------------------------------- */
#aop-inline-graph-panel {
    overflow: hidden;
    max-width: 100%;
}

.ke-inline-graph-wrapper {
    position: relative;
    margin: 12px 0;
    overflow: hidden;
    max-width: 100%;
}

#cy-inline {
    width: 100%;
    height: 250px;
    border: 1px solid var(--color-border, #ddd);
    border-radius: 6px;
    background: var(--color-bg-page, #f5f5f7);
    overflow: hidden;
    box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Inline KE Info Panel (mapper page)
   -------------------------------------------------------------------------- */
.ke-inline-panel {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 340px;
    max-height: 280px;
    overflow-y: auto;
    background: var(--color-white, #fff);
    border: 1px solid var(--color-border, #ddd);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    padding: 12px 14px;
    z-index: 10;
    font-size: 0.825rem;
}

.ke-inline-panel__header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 4px;
}

.ke-inline-panel__title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-primary-dark);
    margin: 0;
    line-height: 1.3;
}

.ke-inline-panel__id {
    font-size: 0.75rem;
    color: var(--color-text-secondary, #555);
    margin: 0 0 4px;
}

.ke-inline-panel__biolevel {
    font-size: 0.75rem;
    color: var(--color-text-secondary, #555);
    margin: 0 0 6px;
    font-style: italic;
}

.ke-inline-panel__status {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
    margin-bottom: 6px;
}

.ke-inline-panel__status--mapped {
    background: #e8f5e9;
    color: #2e7d32;
}

.ke-inline-panel__status--unmapped {
    background: #f5f5f5;
    color: #888;
}

.ke-inline-panel__use-btn {
    width: 100%;
    padding: 6px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-white, #fff);
    background: var(--color-primary-pink);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: opacity 0.15s ease;
    margin-top: 4px;
}

.ke-inline-panel__use-btn:hover {
    opacity: 0.88;
}

/* ---------------------------------------------------------------------------
   Gene count badge overlay (cytoscape-node-html-label)
   --------------------------------------------------------------------------- */
.gene-badge-container {
    /* Rendered as absolute div by plugin; no sizing needed here */
}

.gene-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #29235C;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 9px;
    line-height: 1;
    transform: translate(30%, -40%);
    box-sizing: border-box;
    pointer-events: none;
}

/* Legend for gene badges */
.aop-graph-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--color-text-secondary, #666);
    border-top: 1px solid var(--color-border-light, #eee);
    margin-top: 4px;
}

.aop-graph-legend__badge-sample {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #29235C;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 9px;
    line-height: 1;
}

/* Gene group collapsible sections */
.gene-group {
    border-bottom: 1px solid var(--color-border-light, #eee);
}

.gene-group:last-child {
    border-bottom: none;
}

.gene-group__header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-primary, #333);
    user-select: none;
}

.gene-group__header:hover {
    color: var(--color-primary-blue, #307BBF);
}

.gene-group__arrow {
    display: inline-block;
    width: 12px;
    font-size: 10px;
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.gene-group--open .gene-group__arrow {
    transform: rotate(90deg);
}

.gene-group__count {
    font-weight: 400;
    color: var(--color-text-secondary, #888);
    font-size: 12px;
}

.gene-group__type-badge {
    display: inline-block;
    padding: 1px 5px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 3px;
    line-height: 1.4;
    flex-shrink: 0;
}

.gene-group__type-badge--wp {
    background: #e8f0fe;
    color: #1a56db;
}

.gene-group__type-badge--go {
    background: #f0fdf4;
    color: #166534;
}

.gene-group__genes {
    display: none;
    list-style: none;
    padding: 0 0 4px 18px;
    margin: 0;
    max-height: 160px;
    overflow-y: auto;
}

.gene-group--open .gene-group__genes {
    display: block;
}

.gene-group__genes li {
    padding: 2px 0;
    font-size: 12px;
}

.gene-group__genes a {
    color: var(--color-primary-blue, #307BBF);
    text-decoration: none;
}

.gene-group__genes a:hover {
    text-decoration: underline;
}

/* Gene list containers */
.ke-side-panel__gene-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
}

.ke-side-panel__gene-loading {
    color: var(--color-text-secondary, #888);
    font-style: italic;
    font-size: 13px;
    padding: 4px 0;
}

/* Inline gene panel */
.ke-inline-panel__gene-section {
    margin-top: 8px;
    border-top: 1px solid var(--color-border-light, #eee);
    padding-top: 8px;
}

.ke-inline-panel__gene-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 200px;
    overflow-y: auto;
}

.ke-inline-panel__gene-list a {
    color: var(--color-primary-blue, #307BBF);
    text-decoration: none;
}

.ke-inline-panel__gene-list a:hover {
    text-decoration: underline;
}
