/**
 * GPT Text Generation Playground - Styles
 * Uses CSS variables from ../shared/css/demo-styles.css for theming
 */

/* Demo-specific variables that don't conflict with theming */
:root {
    --gpt-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --gpt-shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
    --gpt-transition: all 0.3s ease;
    --token-selected: #a5d75f;
    --token-alternative: #94a3b8;
    --primary-hover: #005a34;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

/* Hero Header - matches ELIZA demo styling */
.hero-header {
    padding: 3rem 0 2rem;
    margin-bottom: 30px;
    text-align: center;
    background: linear-gradient(180deg, var(--surface-color) 0%, var(--bg-color) 100%);
}

.hero-title {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 800;
    margin-bottom: 1rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: clamp(1rem, 2vw, 1.25rem);
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

.model-status {
    margin-bottom: 20px;
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    background: var(--surface-color);
    border-radius: 8px;
    gap: 10px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.main-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
}

@media (max-width: 1024px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
}

/* Controls Panel */
.controls-panel {
    background: var(--surface-color);
    border-radius: 12px;
    padding: 20px;
    height: fit-content;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    border: 1px solid var(--border-color);
    box-shadow: var(--gpt-shadow);
}

.control-section {
    margin-bottom: 25px;
    padding-bottom: 25px;
    border-bottom: 1px solid var(--border-color);
}

.control-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.control-section h2 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.control-group {
    margin-bottom: 15px;
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.control-group small {
    display: block;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 5px;
    opacity: 0.8;
}

select, textarea {
    width: 100%;
    padding: 10px;
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--surface-hover);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

input[type="checkbox"] {
    margin-right: 8px;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border-color);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Output Panel */
.output-panel {
    background: var(--surface-color);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--gpt-shadow);
}

.output-section {
    margin-bottom: 25px;
}

.output-section h2 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.generated-text {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    min-height: 150px;
    font-size: 1rem;
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.token {
    display: inline-block;
    padding: 2px 4px;
    margin: 1px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.token.selected {
    background: var(--token-selected);
    color: white;
    font-weight: 500;
}

.token:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
}

.token.high-surprise {
    border-bottom: 2px solid var(--warning-color);
}

.token.very-high-surprise {
    border-bottom: 2px solid var(--error-color);
}

.token-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    white-space: nowrap;
    font-size: 0.85rem;
    z-index: 1000;
    display: none;
    pointer-events: none;
    margin-bottom: 5px;
}

.token:hover .token-tooltip {
    display: block;
}

/* Statistics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.stat-item {
    background: var(--surface-hover);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.stat-item span:last-child {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Probability Visualization */
.probability-viz {
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.token-step {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.token-step:last-child {
    border-bottom: none;
}

.step-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.step-number {
    font-weight: 600;
    color: var(--primary-color);
}

.step-entropy {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.probability-bar {
    margin-bottom: 8px;
}

.prob-bar-container {
    background: var(--background);
    height: 24px;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.prob-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--token-selected));
    border-radius: 4px;
    transition: width 0.3s;
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: 0.85rem;
    font-weight: 600;
}

.prob-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 3px;
}

.token-text {
    font-family: 'Courier New', monospace;
    color: var(--text-primary);
}

.token-prob {
    color: var(--text-secondary);
}

/* Alternatives Visualization */
.alternatives-viz {
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.alternatives-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.alternative-token {
    background: var(--background);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alternative-token .token-text {
    font-weight: 500;
}

.alternative-token .token-prob {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Chart Container */
.chart-container {
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    height: 250px;
}

canvas {
    max-width: 100%;
    height: 100%;
}

/* Surprise Visualization */
.surprise-viz {
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
}

.surprise-legend {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    font-size: 0.85rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-color {
    width: 20px;
    height: 3px;
    border-radius: 2px;
}

/* Comparison Mode */
.comparison-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.comparison-column {
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
}

.comparison-column h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

.stats-mini {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
}

.stats-mini > div {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface-light);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.token {
    animation: fadeIn 0.3s ease-out;
}

/* Responsive Design */
@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    .main-grid {
        grid-template-columns: 1fr;
    }

    .comparison-container {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Status Messages */
.status-message {
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 15px;
    text-align: center;
}

.status-message.info {
    background: rgba(79, 70, 229, 0.1);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.status-message.success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
}

.status-message.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
}

/* Highlight effect for newly generated tokens */
@keyframes highlight {
    0% {
        background: var(--primary-color);
        transform: scale(1.1);
    }
    100% {
        background: transparent;
        transform: scale(1);
    }
}

.token.new {
    animation: highlight 0.5s ease-out;
}
