/**
 * BERT MLM Interactive Demo - Styles
 * Uses CSS variables from ../shared/css/demo-styles.css for theming
 */

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

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-color);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
}

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

/* Hero Header - matches main index.html 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;
}

.main-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    min-height: calc(100vh - 200px);
    background: var(--surface-color);
    border-radius: 16px;
    box-shadow: var(--bert-shadow-lg);
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    background: var(--bg-secondary);
    padding: 20px;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}

.control-panel {
    background: var(--surface-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--bert-shadow);
}

.control-panel h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.3em;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 8px;
}

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

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

.control-section label {
    display: block;
    margin: 10px 0 5px 0;
    font-weight: 600;
    color: var(--text-secondary);
}

.control-section select {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
    background: var(--surface-color);
    color: var(--text-primary);
}

.control-section select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.control-section input[type="range"] {
    width: calc(100% - 50px);
    margin-right: 10px;
}

.control-section span {
    display: inline-block;
    min-width: 40px;
    text-align: right;
    font-weight: 600;
    color: var(--primary-color);
}

.checkbox-group {
    margin-top: 10px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    margin: 8px 0;
    font-weight: 400;
    cursor: pointer;
    color: var(--text-primary);
}

.checkbox-group input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--bert-transition);
    margin-top: 10px;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--bert-shadow);
}

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

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

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    margin-left: 10px;
}

.status-text {
    margin-top: 10px;
    padding: 8px;
    border-radius: 6px;
    font-size: 13px;
    text-align: center;
}

.status-success {
    background: var(--surface-hover);
    color: var(--success-color);
}

.status-error {
    background: var(--surface-hover);
    color: var(--error-color);
}

.status-info {
    background: var(--surface-hover);
    color: var(--secondary-color);
}

.examples-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.example-btn {
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface-color);
    color: var(--text-primary);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: var(--bert-transition);
}

.example-btn:hover {
    border-color: var(--primary-color);
    background: var(--surface-hover);
}

.info-panel {
    background: var(--surface-hover);
    border-radius: 12px;
    padding: 20px;
    border-left: 4px solid var(--warning-color, #ffc107);
}

.info-panel h4 {
    color: var(--warning-color, #f57c00);
    margin-bottom: 10px;
}

.info-panel p {
    margin-bottom: 10px;
    line-height: 1.6;
    font-size: 14px;
    color: var(--text-primary);
}

.info-panel ul {
    list-style: none;
    padding-left: 0;
}

.info-panel li {
    margin: 8px 0;
    padding-left: 20px;
    position: relative;
    font-size: 14px;
    color: var(--text-primary);
}

.info-panel li:before {
    content: '\25B8';
    position: absolute;
    left: 0;
    color: var(--warning-color, #f57c00);
}

/* Main Content */
.main-content {
    padding: 30px;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
    background: var(--surface-color);
}

.hidden {
    display: none !important;
}

/* Loading */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface-color);
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--bert-shadow-lg);
    text-align: center;
    z-index: 1000;
    color: var(--text-primary);
}

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

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

/* Input Section */
.input-section {
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
}

.input-section h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.instruction {
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-size: 14px;
}

#text-input {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

#text-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.input-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.input-actions .btn {
    flex: 1;
    margin-top: 0;
}

/* Text Display */
.text-display-section {
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
}

.text-display-section h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.text-display {
    min-height: 100px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 8px;
    line-height: 2;
    font-size: 18px;
}

.text-display .placeholder {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
}

.token {
    display: inline-block;
    padding: 4px 8px;
    margin: 2px;
    background: var(--surface-hover);
    border: 2px solid var(--secondary-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    color: var(--text-primary);
}

.token:hover {
    background: var(--border-color);
    transform: translateY(-2px);
}

/* Masked tokens use accent colors (semantic, not themeable) */
.token.masked {
    background: #fff3e0;
    border-color: #ff9800;
    font-weight: 700;
    position: relative;
    color: #333;
}

[data-theme="dark"] .token.masked {
    background: rgba(255, 152, 0, 0.2);
    color: #ffb74d;
}

.token.masked::after {
    content: '[MASK]';
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff9800;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    white-space: nowrap;
}

.mask-info {
    margin-top: 15px;
    padding: 10px;
    background: var(--surface-hover);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-primary);
}

#mask-count {
    font-weight: 700;
    color: #ff9800;
    font-size: 18px;
}

/* Predictions */
.predictions-section {
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
}

.predictions-section h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
}

#predictions-container {
    display: grid;
    gap: 20px;
}

.prediction-block {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    border-left: 4px solid var(--primary-color);
}

.prediction-block h4 {
    color: var(--text-primary);
    margin-bottom: 15px;
    font-size: 16px;
}

/* Original token uses accent color (semantic) */
.original-token {
    color: #ff9800;
    font-weight: 700;
    background: rgba(255, 152, 0, 0.15);
    padding: 2px 8px;
    border-radius: 4px;
}

.predictions-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.prediction-item {
    display: grid;
    grid-template-columns: 30px 120px 1fr 80px;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: var(--surface-color);
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--bert-transition);
}

.prediction-item:hover {
    border-color: var(--primary-color);
    transform: translateX(5px);
}

.prediction-rank {
    width: 30px;
    height: 30px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.prediction-word {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 16px;
}

.prediction-bar-container {
    background: var(--border-color);
    height: 24px;
    border-radius: 12px;
    overflow: hidden;
}

.prediction-bar {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 12px;
    transition: width 0.5s ease;
}

.prediction-prob {
    text-align: right;
    font-weight: 600;
    color: var(--primary-color);
}

/* Attention Visualization */
.attention-section {
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
}

.attention-section h2 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.attention-section .subtitle {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.attention-controls {
    display: grid;
    grid-template-columns: auto 1fr auto 1fr auto;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
}

.attention-controls label {
    font-weight: 600;
    color: var(--text-secondary);
}

.attention-controls select {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--surface-color);
    color: var(--text-primary);
}

.attention-heatmap {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 20px;
    min-height: 400px;
}

.attention-details {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 8px;
    color: var(--text-primary);
}

/* Statistics */
.stats-panel {
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
}

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

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

.stat-item {
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 8px;
    text-align: center;
}

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

.stat-value {
    display: block;
    color: var(--primary-color);
    font-size: 1.8em;
    font-weight: 700;
}

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

    .sidebar {
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .input-actions {
        flex-direction: column;
    }

    .prediction-item {
        grid-template-columns: 30px 1fr;
        grid-template-rows: auto auto;
    }

    .prediction-bar-container {
        grid-column: 1 / -1;
    }

    .prediction-prob {
        grid-column: 1 / -1;
        text-align: center;
    }
}

@media (max-width: 768px) {
    .hero-title {
        font-size: 1.8rem;
    }

    .hero-subtitle {
        font-size: 0.9rem;
    }

    .main-content {
        padding: 15px;
    }

    .text-display {
        font-size: 16px;
    }

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