/**
 * node-transformer.css - Styling for Transformer category nodes
 *
 * Transformer nodes are AI-powered data transformation panels that accept
 * inputs, process them, and emit outputs in a visual programming style.
 */

/* =============================================================================
   TRANSFORMER PANEL BASE
   ============================================================================= */

.node-panel--ai-caller {
    --node-accent: #9C27B0;
    --transformer-gradient-start: rgba(156, 39, 176, 0.4);
    --transformer-gradient-end: rgba(103, 58, 183, 0.4);
}

/* Panel header with transformer icon */
.node-panel--ai-caller .node-panel__header {
    background: linear-gradient(90deg,
        rgba(156, 39, 176, 0.15) 0%,
        rgba(103, 58, 183, 0.08) 100%);
}

/* =============================================================================
   AI CALLER CONTENT LAYOUT
   ============================================================================= */

.ai-caller__content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
}

/* Field sections */
.ai-caller__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ai-caller__field-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.6);
}

/* =============================================================================
   INPUT FIELD
   ============================================================================= */

.ai-caller__input {
    min-height: 60px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(156, 39, 176, 0.2);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
    line-height: 1.5;
    overflow: hidden;
    position: relative;
}

.ai-caller__input--empty {
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
}

.ai-caller__source-indicator {
    display: block;
    margin-top: 6px;
    font-size: 10px;
    color: rgba(156, 39, 176, 0.7);
    font-style: italic;
}

/* Input chip for story content (concept, treatment, outline) */
.ai-caller__input-chip {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(156, 39, 176, 0.2);
    border: 1px solid rgba(156, 39, 176, 0.4);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #e1bee7;
}

/* =============================================================================
   CHIP FIELDS (Emphasize / Avoid)
   ============================================================================= */

.ai-caller__chip-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ai-caller__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 28px;
}

.ai-caller__chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 14px;
    font-size: 12px;
    max-width: 150px;
    transition: all 0.15s ease;
}

/* Piped chips (from connections) - purple accent */
.ai-caller__chip--piped {
    background: rgba(156, 39, 176, 0.25);
    border: 1px solid rgba(156, 39, 176, 0.5);
    color: #e1bee7;
}

.ai-caller__chip--piped:hover {
    background: rgba(156, 39, 176, 0.35);
}

/* Manual chips (typed by user) - subtle */
.ai-caller__chip--manual {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
}

.ai-caller__chip--manual:hover {
    background: rgba(255, 255, 255, 0.12);
}

.ai-caller__chip-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-caller__chip-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    padding: 0;
    border: none;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.ai-caller__chip-remove:hover {
    background: rgba(244, 67, 54, 0.5);
    color: #fff;
}

/* Chip input */
.ai-caller__chip-input {
    flex: 1;
    min-width: 100px;
    padding: 4px 8px;
    background: transparent;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    outline: none;
    transition: all 0.15s ease;
}

.ai-caller__chip-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.ai-caller__chip-input:focus {
    border-color: rgba(156, 39, 176, 0.5);
    background: rgba(156, 39, 176, 0.1);
}

/* Avoid field - red accent for chips */
.ai-caller__field--avoid .ai-caller__chip--piped {
    background: rgba(244, 67, 54, 0.2);
    border-color: rgba(244, 67, 54, 0.4);
    color: #ffcdd2;
}

.ai-caller__field--avoid .ai-caller__chip--piped:hover {
    background: rgba(244, 67, 54, 0.3);
}

/* =============================================================================
   MODE INDICATOR
   ============================================================================= */

.ai-caller__mode-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin: 4px 0;
    background: rgba(156, 39, 176, 0.08);
    border: 1px solid rgba(156, 39, 176, 0.15);
    border-radius: 6px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
}

.ai-caller__mode-indicator--connected {
    background: rgba(156, 39, 176, 0.15);
    border-color: rgba(156, 39, 176, 0.3);
}

.ai-caller__mode-icon {
    font-size: 16px;
    color: rgba(156, 39, 176, 0.7);
    transition: color 0.2s ease;
}

.ai-caller__mode-indicator--connected .ai-caller__mode-icon {
    color: #9C27B0;
}

.ai-caller__mode-label {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    transition: color 0.2s ease;
}

.ai-caller__mode-indicator--connected .ai-caller__mode-label {
    color: #e1bee7;
}

/* =============================================================================
   PROVIDER / MODEL SELECTORS
   ============================================================================= */

.ai-caller__selectors {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.ai-caller__selector {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ai-caller__selector label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.5);
}

.ai-caller__select {
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 12px;
    cursor: pointer;
    outline: none;
    transition: all 0.15s ease;
}

.ai-caller__select:hover {
    border-color: rgba(156, 39, 176, 0.4);
}

.ai-caller__select:focus {
    border-color: rgba(156, 39, 176, 0.6);
    box-shadow: 0 0 0 2px rgba(156, 39, 176, 0.15);
}

/* =============================================================================
   BUTTON ROW
   ============================================================================= */

.ai-caller__buttons {
    display: flex;
    gap: 8px;
    margin: 8px 0;
}

.ai-caller__transform-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
    padding: 14px;
    background: linear-gradient(135deg,
        var(--transformer-gradient-start),
        var(--transformer-gradient-end));
    border: 1px solid rgba(156, 39, 176, 0.5);
    border-radius: 8px;
    color: #e1bee7;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-caller__transform-btn:hover:not(:disabled) {
    background: linear-gradient(135deg,
        rgba(156, 39, 176, 0.5),
        rgba(103, 58, 183, 0.5));
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(156, 39, 176, 0.4);
}

.ai-caller__transform-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(156, 39, 176, 0.3);
}

.ai-caller__transform-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-caller__transform-btn .material-icons {
    font-size: 18px;
}

/* Processing state */
.ai-caller__transform-btn--processing {
    background: linear-gradient(135deg,
        rgba(156, 39, 176, 0.3),
        rgba(103, 58, 183, 0.3));
    animation: ai-caller-pulse 1.5s ease-in-out infinite;
}

@keyframes ai-caller-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(156, 39, 176, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(156, 39, 176, 0);
    }
}

/* Spinner */
.ai-caller__spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: #e1bee7;
    border-radius: 50%;
    animation: ai-caller-spin 0.8s linear infinite;
}

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

/* Reset button */
.ai-caller__reset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    padding: 14px 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-caller__reset-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.85);
}

.ai-caller__reset-btn:active {
    transform: scale(0.95);
}

.ai-caller__reset-btn .material-icons {
    font-size: 18px;
}

/* =============================================================================
   OUTPUT FIELD
   ============================================================================= */

.ai-caller__output {
    min-height: 80px;
    max-height: 200px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(156, 39, 176, 0.2);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
    line-height: 1.5;
    overflow-y: auto;
    transition: all 0.2s ease;
}

.ai-caller__output--empty {
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
}

.ai-caller__output:focus {
    outline: none;
    border-color: rgba(156, 39, 176, 0.5);
    box-shadow: 0 0 0 2px rgba(156, 39, 176, 0.15);
}

/* Output with content - make it look editable */
.ai-caller__output:not(.ai-caller__output--empty) {
    cursor: text;
}

.ai-caller__output:not(.ai-caller__output--empty):hover {
    border-color: rgba(156, 39, 176, 0.4);
}

/* =============================================================================
   FIELD PORTS (for connection system)
   ============================================================================= */

.ai-caller__field[data-field] {
    position: relative;
}

/* Input port indicator */
.ai-caller__field[data-field="input"]::before,
.ai-caller__field[data-field="emphasize"]::before,
.ai-caller__field[data-field="avoid"]::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: rgba(156, 39, 176, 0.4);
    border: 2px solid #9C27B0;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Output port indicator */
.ai-caller__field[data-field="output"]::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: rgba(156, 39, 176, 0.4);
    border: 2px solid #9C27B0;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Show ports when field ports are expanded */
.node-panel--field-ports-expanded .ai-caller__field[data-field]::before,
.node-panel--field-ports-expanded .ai-caller__field[data-field]::after {
    opacity: 1;
}

/* =============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================= */

@media (max-width: 480px) {
    .ai-caller__selectors {
        grid-template-columns: 1fr;
    }

    .ai-caller__transform-btn {
        padding: 12px;
        font-size: 13px;
    }
}

/* =============================================================================
   DARK MODE REFINEMENTS (default is already dark)
   ============================================================================= */

/* Light mode overrides if needed */
@media (prefers-color-scheme: light) {
    .node-panel--ai-caller {
        --transformer-gradient-start: rgba(156, 39, 176, 0.15);
        --transformer-gradient-end: rgba(103, 58, 183, 0.15);
    }
}
