/**
 * Attention Visualizer Styles
 * Uses CSS variables from ../shared/css/demo-styles.css for theming
 */

/* Demo-specific variables that don't conflict with theming */
:root {
    --attention-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --attention-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
    --attention-transition: all 0.3s ease;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0;
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* Hero Header - matches ELIZA 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;
}

/* Controls Panel */
.controls-panel {
    padding: 30px;
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border-color);
}

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

.control-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.control-group select,
.control-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s ease;
    background: var(--surface-color);
    color: var(--text-primary);
}

.control-group select:focus,
.control-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

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

/* Buttons - matches ELIZA btn pattern */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--attention-transition);
    font-weight: 600;
}

.btn-primary,
.primary-btn {
    background: var(--gradient-primary);
    color: white;
    border: none;
    padding: 14px 32px;
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--attention-transition);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover,
.primary-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.btn-loader {
    display: inline-block;
}

/* Model Info */
.model-info {
    background: var(--surface-color);
    padding: 15px;
    border-radius: var(--radius-md);
    margin-top: 20px;
    border-left: 4px solid var(--primary-color);
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    color: var(--text-primary);
}

.info-label {
    font-weight: 600;
    color: var(--text-primary);
}

/* Layer and Head Controls */
#layer-head-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    margin-left: 15px;
    font-weight: normal;
    cursor: pointer;
    color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
    margin-right: 6px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Visualization Container */
#visualization-container {
    padding: 30px;
    min-height: 500px;
    background: var(--surface-color);
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: var(--text-secondary);
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Visualization Header */
.viz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.viz-header h2 {
    color: var(--primary-color);
    font-size: 1.8em;
}

.viz-stats {
    font-size: 0.9em;
    color: var(--text-secondary);
    font-family: 'Monaco', 'Consolas', monospace;
}

/* Tokens Display */
.tokens-display {
    margin-bottom: 25px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.token-badge {
    display: inline-block;
    padding: 6px 12px;
    background: var(--surface-color);
    border: 2px solid var(--primary-color);
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.token-badge:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

/* Visualization Area */
.visualization-area {
    position: relative;
    margin-bottom: 30px;
}

.viz-view {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

/* Heatmap */
#heatmap-canvas {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    cursor: crosshair;
}

/* Arc Diagram */
#arc-svg {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface-color);
    box-shadow: var(--shadow-md);
}

.attention-arc {
    cursor: pointer;
    transition: all 0.2s ease;
}

/* Matrix View */
#matrix-container {
    max-width: 100%;
    overflow: auto;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
}

.matrix-table {
    border-collapse: collapse;
    background: var(--surface-color);
    font-size: 0.85em;
    margin: 0 auto;
}

.matrix-table th,
.matrix-table td {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-primary);
}

.matrix-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.matrix-table tbody th {
    background: var(--bg-secondary);
    position: sticky;
    left: 0;
    z-index: 5;
}

.matrix-table td {
    font-family: 'Monaco', 'Consolas', monospace;
    transition: all 0.2s ease;
    cursor: pointer;
}

.matrix-table td:hover {
    box-shadow: 0 0 0 2px var(--primary-color);
}

.matrix-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.pos-num {
    font-size: 0.8em;
    color: var(--text-secondary);
    font-weight: normal;
}

/* Multi-head View */
#multihead-view {
    margin-top: 30px;
}

#multihead-view h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
}

#multihead-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
}

.head-minimap {
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 15px;
    text-align: center;
    transition: var(--attention-transition);
}

.head-minimap:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.head-minimap h4 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 1em;
}

.head-minimap canvas {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
}

.head-stats {
    font-size: 0.85em;
    color: var(--text-secondary);
    text-align: left;
}

/* Tooltip */
.tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 10px 15px;
    border-radius: var(--radius-md);
    font-size: 0.9em;
    pointer-events: none;
    z-index: 1000;
    display: none;
    box-shadow: var(--shadow-lg);
    max-width: 300px;
}

.tooltip strong {
    color: var(--accent-color);
}

/* Legend */
.legend {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-top: 20px;
}

.legend-label {
    font-weight: 600;
    color: var(--text-primary);
}

.color-scale {
    flex: 1;
    max-width: 300px;
}

.scale-bar {
    height: 30px;
    background: linear-gradient(to right,
        rgb(255, 255, 255),
        rgb(179, 217, 255),
        rgb(102, 178, 255),
        rgb(26, 140, 255),
        rgb(0, 102, 204)
    );
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 5px;
}

.scale-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
    color: var(--text-secondary);
}

/* Info Panel */
.info-panel {
    background: var(--bg-secondary);
    padding: 30px;
    border-top: 2px solid var(--border-color);
}

.info-panel h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.4em;
}

.info-panel h4 {
    color: var(--text-primary);
    margin: 15px 0 10px;
    font-size: 1.1em;
}

.info-panel ol,
.info-panel ul {
    margin-left: 20px;
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.info-panel li {
    margin-bottom: 8px;
    line-height: 1.6;
}

.info-panel p {
    margin-bottom: 15px;
    line-height: 1.7;
    color: var(--text-secondary);
}

.viz-types {
    background: var(--surface-color);
    padding: 20px;
    border-radius: var(--radius-md);
    margin-top: 20px;
    border-left: 4px solid var(--secondary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .controls-panel {
        padding: 20px;
    }

    #layer-head-controls {
        grid-template-columns: 1fr;
    }

    .viz-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .tokens-display {
        font-size: 0.85em;
    }

    #multihead-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .matrix-table {
        font-size: 0.75em;
    }

    .matrix-table th,
    .matrix-table td {
        padding: 4px 6px;
    }

    .hero-title {
        font-size: 1.8rem;
    }
}

/* Print Styles */
@media print {
    .controls-panel,
    .info-panel {
        display: none;
    }

    .container {
        box-shadow: none;
    }

    .tooltip {
        display: none !important;
    }
}

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

#viz-content {
    animation: fadeIn 0.5s ease;
}

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

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

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}
