/* css/components/cell-widget.css */
/* Styles for g-cell and g-ref host elements and their internal structure */
/* (name, value, CI, formula display, error messages). */
/* Includes states like error, dependency error. */

/* Element base styles (formerly :host) */
g-cell, g-ref {
    position: relative; /* For absolute positioning of formula-display */
    display: inline-block; /* Default display for cells/refs */
    padding: 3px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin: 2px;
    font-family: sans-serif; /* Default font for cell content */
    font-size: 0.9rem;
    vertical-align: baseline; /* Changed from middle to baseline */
    background-color: #f9f9f9;
}

g-cell[full-width-active], 
g-ref[full-width-active] { /* Changed selector */
    display: block;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
    padding: 8px;
    background-color: #fff;
}

/* Error state indicators on the elements (formerly :host(.class)) */
g-cell.error-state-indicator, 
g-ref.error-state-indicator {
    border-color: #ff3860; /* Matches Bulma's danger color */
    background-color: #fff5f7;
}
g-cell.dependency-error-indicator, 
g-ref.dependency-error-indicator {
    border-color: #ffdd57; /* Matches Bulma's warning color */
    background-color: #fffbeb;
}
g-cell.cell-not-found-indicator, 
g-ref.cell-not-found-indicator {
    border-color: #ff3860;
    background-color: #fff5f7;
    font-style: italic;
}

/* Internal structure styling */
.content-wrapper {
    display: flex; 
    flex-direction: row; /* Default: Viz area and Info area side-by-side */
    align-items: flex-end; /* Align items to the bottom, so text baseline aligns with viz bottom */
    position: relative; /* For absolute positioning of formula-display */
}

g-cell[full-width-active] .content-wrapper, 
g-ref[full-width-active] .content-wrapper {
    flex-direction: column; /* Stack info area and viz area vertically */
    align-items: stretch;   /* Stretch children to full width */
}

.cell-viz-area {
    flex-shrink: 0; /* Prevent shrinking */
    width: 80px;    /* Fixed width for inline display */
    height: 40px;   /* Fixed height for inline display, matches histogram default */
    margin-right: 8px;
    display: flex;
    align-items: center; /* Center placeholder vertically */
    justify-content: center; /* Center placeholder horizontally */
    overflow: hidden; /* Ensure histogram doesn't overflow its fixed bounds */
}

/* Collapse viz area for inline scalars */
.cell-viz-area.scalar-mode {
    width: 0;
    height: 0;
    margin-right: 0;
    border: none;
    padding: 0;
}


g-cell[full-width-active] .cell-viz-area {
    width: 100%;
    height: 130px; /* Taller histogram for full-width */
    margin-right: 0;
    margin-top: 5px; /* Space between info area and viz area in full-width */
}

.scalar-placeholder {
    font-size: 1.8em; /* Larger placeholder text */
    color: #ccc;
    font-family: monospace;
    line-height: 1; /* Ensure it centers well */
}

.cell-info-area { 
    display: flex;
    flex-direction: column; /* Stack ID and info-main-line vertically for inline cells */
    align-items: flex-start; /* Align children to the start of the cross-axis */
}

/* The .scalar-value-prominent is now inside .info-main-line for inline scalars,
   so the direct child selector rule above is no longer needed.
   Baseline alignment within .info-main-line should handle it. */


.info-main-line {
    display: flex;
    align-items: baseline;
    flex-wrap: nowrap;
}

/* Specific styling for the info line of inline scalars if needed */
.scalar-info-main-line {
    /* Potentially adjust margins if the preceding prominent scalar value affects layout */
}

g-cell[full-width-active] .cell-info-area {
    flex-direction: row; /* Explicitly set to row for full-width, overriding the base */
    align-items: baseline; /* Maintain baseline alignment for full-width */
    width: 100%; 
    order: -1; 
}


.cell-id-display {
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.15s ease-in-out, visibility 0s linear 0.15s;
    font-size: 0.8em;
    color: #777;
    font-style: italic;
    margin-bottom: 0.2em; /* Space below the ID when it's above the name */
    white-space: nowrap;
}

g-cell:hover .cell-id-display,
g-ref:hover .cell-id-display {
    visibility: visible;
    opacity: 1;
    transition-delay: 0s;
}

.name {
    font-weight: bold;
    color: #363636; /* Bulma's text color */
    margin-right: 5px;
}

.value { /* Base style for value */
    margin-right: 5px;
    color: #2254a2; /* A distinct color for values */
}

/* Prominent value for inline scalars */
g-cell:not([full-width-active]) .scalar-value-prominent,
g-ref:not([full-width-active]) .scalar-value-prominent {
    font-size: 1.2em; /* Larger font size */
    font-weight: bold;
    margin-right: 0.4em; /* Adjust spacing as it's now before name */
}

/* Prominent value for inline distributions/arrays */
g-cell:not([full-width-active]) .distribution-value-prominent,
g-ref:not([full-width-active]) .distribution-value-prominent {
    font-size: 1.1em; /* Slightly larger font size */
    /* font-weight: bold; /* Optional: if you want it bolder too */
}


.ci {
    font-size: 0.9em;
    color: #7a7a7a; /* Bulma's grey-dark */
    margin-right: 5px;
}
.ci::before {
    content: "(";
}
.ci::after {
    content: ")";
}

.formula-display {
    visibility: hidden; /* Hidden by default, but occupies space */
    opacity: 0;         /* Fully transparent */
    font-size: 0.8em;
    color: #7a7a7a;
    /* margin-left: 5px; Removed, will be absolutely positioned */
    font-style: italic;
    transition: opacity 0.15s ease-in-out, visibility 0s linear 0.15s; /* Smooth fade */
    
    position: absolute;
    top: -1.3em; /* Position above the cell content area */
    right: 3px;
    background: rgba(248, 249, 250, 0.95); /* Light background for tooltip effect */
    border: 1px solid #ccc;
    padding: 2px 5px;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    z-index: 100; /* Ensure it's on top */
    max-width: calc(100% - 10px); /* Prevent overflow from cell boundaries */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

g-cell:hover .formula-display, 
g-ref:hover .formula-display { /* Changed selector */
    visibility: visible; /* Make it visible */
    opacity: 1;          /* Fully opaque */
    transition-delay: 0s; /* Apply immediately on hover */
}

/* Adjust histogram container margin if needed. Now it's inside .cell-viz-area */
/* .content-wrapper > .histogram-container rule is no longer applicable directly */
/* .cell-viz-area handles margins for the histogram container indirectly. */


.error-message {
    color: #ff3860;
    font-style: italic;
    margin-left: 5px;
}

/* Styles for specific states like processing or empty array */
.value[style*="italic"] { /* Catches italicized status messages */
    color: #7a7a7a;
}
