/* Semantic Search POC - Professional Dark Mode Styling */
/* Adheres to brandbook.md specifications */

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

:root {
    /* Primary Colors - per brandbook */
    --primary-accent: #60a5fa;
    --secondary-accent: #818cf8;
    --gold-accent: #fbbf24;

    /* Semantic Colors */
    --success-green: #34d399;
    --warning-amber: #fbbf24;
    --error-red: #f87171;

    /* Background Colors */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;

    /* Text Colors */
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;

    /* Border Colors */
    --border-subtle: #334155;
    --border-medium: #475569;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* Header Section */
header {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, #1a2847 100%);
    border-bottom: 1px solid var(--border-subtle);
    padding: 48px 40px;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 12px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-accent), var(--secondary-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Flow Diagram */
.flow-diagram {
    background: var(--bg-primary);
    padding: 32px 40px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    position: relative;
}

.flow-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
}

.flow-icon {
    font-size: 1.5rem;
}

.flow-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-weight: 500;
    white-space: nowrap;
}

.flow-arrow {
    color: var(--primary-accent);
    font-size: 1.25rem;
    font-weight: bold;
}

.flow-divider {
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-subtle), transparent);
    margin: 8px 0;
}

/* Two-Phase Layout */
.two-phase-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 0;
    border-bottom: 1px solid var(--border-subtle);
}

.phase-panel {
    padding: 40px;
    background: var(--bg-primary);
}

.phase-1 {
    border-right: 1px solid var(--border-subtle);
}

.phase-2 {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.03), rgba(129, 140, 248, 0.03));
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.panel-icon {
    font-size: 1.5rem;
}

.panel-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    font-weight: 600;
    margin: 0;
}

/* Badge Component */
.badge {
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--border-subtle);
}

.badge-active {
    background: linear-gradient(135deg, var(--primary-accent), var(--secondary-accent));
    color: white;
    border: none;
}

/* Status Indicator */
.status-indicator {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-left: auto;
}

.status-disabled {
    background: rgba(248, 113, 113, 0.1);
    color: var(--error-red);
    border: 1px solid var(--error-red);
}

.status-ready {
    background: rgba(52, 211, 153, 0.1);
    color: var(--success-green);
    border: 1px solid var(--success-green);
}

/* Help Text */
.help-text {
    color: var(--text-tertiary);
    margin-bottom: 24px;
    font-size: 0.95rem;
}

.help-text-small {
    display: block;
    color: var(--text-tertiary);
    font-size: 0.875rem;
    margin-top: 8px;
}

.text-count {
    color: var(--text-tertiary);
    font-weight: 400;
    font-size: 0.875rem;
}

/* Input Groups */
.input-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 24px;
}

.input-group label {
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.input-group textarea {
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    transition: all 0.2s ease;
}

.input-group textarea:focus {
    outline: none;
    border-color: var(--primary-accent);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
}

.input-group textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-group textarea::placeholder {
    color: var(--text-tertiary);
}

/* Concept Input Special Styling */
.concept-group label {
    color: var(--primary-accent);
    font-weight: 600;
}

.concept-group textarea {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.05), rgba(129, 140, 248, 0.05));
    border: 2px solid var(--primary-accent);
    font-size: 1rem;
}

.concept-group textarea:focus {
    border-color: var(--secondary-accent);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}

/* Buttons */
.button-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-accent), var(--secondary-accent));
    color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(96, 165, 250, 0.3);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
}

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

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    margin-top: 24px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px dashed var(--border-subtle);
    text-align: center;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p {
    color: var(--text-tertiary);
    font-size: 0.95rem;
}

/* Index Status */
.index-status {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
}

.index-status h3 {
    font-size: 1.125rem;
    color: var(--text-primary);
    margin-bottom: 16px;
    font-weight: 600;
}

.indexed-posts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.indexed-post-card {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
}

.post-header {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 8px;
}

.post-number {
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.post-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Collapsible Descriptors */
.descriptors-collapsible,
.match-descriptors {
    margin-top: 8px;
}

.descriptors-collapsible summary,
.match-descriptors summary {
    cursor: pointer;
    color: var(--primary-accent);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 6px 0;
    user-select: none;
}

.descriptors-collapsible summary:hover,
.match-descriptors summary:hover {
    color: var(--secondary-accent);
}

.descriptors-content {
    padding: 12px;
    margin-top: 8px;
    background: var(--bg-primary);
    border-radius: 6px;
    border-left: 3px solid var(--primary-accent);
    color: var(--text-tertiary);
    font-size: 0.85rem;
    line-height: 1.5;
}

/* Loading Indicator */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    margin: 24px 40px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--bg-tertiary);
    border-top: 3px solid var(--primary-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

.loading p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Error Message */
.error {
    background: rgba(248, 113, 113, 0.1);
    color: var(--error-red);
    padding: 16px 20px;
    border-radius: 8px;
    border-left: 4px solid var(--error-red);
    margin: 20px 40px;
}

/* Results Section */
.results-section {
    padding: 40px;
    background: var(--bg-primary);
}

.results-section h2 {
    font-size: 1.75rem;
    margin-bottom: 32px;
    color: var(--text-primary);
    font-weight: 600;
}

.result-panel {
    background: var(--bg-secondary);
    padding: 28px;
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    margin-bottom: 24px;
}

.result-panel h3 {
    font-size: 1.125rem;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-weight: 600;
}

.panel-description {
    color: var(--text-tertiary);
    font-size: 0.875rem;
    margin-bottom: 20px;
}

/* Variations Display */
.variations-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.variation-tag {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.15), rgba(129, 140, 248, 0.15));
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid var(--primary-accent);
    font-size: 0.9rem;
}

/* Statistics Summary */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    text-align: center;
    transition: all 0.2s ease;
}

.stat-card:hover {
    border-color: var(--primary-accent);
    transform: translateY(-2px);
}

.stat-card.stat-primary {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.1), rgba(129, 140, 248, 0.1));
    border: 1px solid rgba(96, 165, 250, 0.3);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Matches Display */
.matches-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.match-card {
    background: var(--bg-primary);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    transition: all 0.2s ease;
}

.match-card:hover {
    border-color: var(--primary-accent);
    transform: translateX(4px);
}

.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.match-rank {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
}

.match-score {
    display: flex;
    align-items: center;
    gap: 12px;
}

.score-value {
    font-size: 1.25rem;
    font-weight: 700;
    min-width: 60px;
    text-align: right;
}

.score-bar {
    width: 120px;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Score-based colors */
.match-score.score-high .score-value {
    color: var(--success-green);
}

.match-score.score-high .score-bar-fill {
    background: var(--success-green);
}

.match-score.score-medium-high .score-value {
    color: var(--primary-accent);
}

.match-score.score-medium-high .score-bar-fill {
    background: var(--primary-accent);
}

.match-score.score-medium-low .score-value {
    color: var(--warning-amber);
}

.match-score.score-medium-low .score-bar-fill {
    background: var(--warning-amber);
}

.match-score.score-low .score-value {
    color: var(--error-red);
}

.match-score.score-low .score-bar-fill {
    background: var(--error-red);
}

/* Match Content */
.match-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.match-post {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.6;
}

.match-post strong {
    color: var(--primary-accent);
}

.match-variation {
    color: var(--text-tertiary);
    font-size: 0.85rem;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    border-left: 3px solid var(--secondary-accent);
}

.match-variation strong {
    color: var(--text-secondary);
}

.no-results {
    text-align: center;
    padding: 32px;
    color: var(--text-tertiary);
    font-size: 0.95rem;
}

/* Footer */
footer {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    text-align: center;
    padding: 28px;
    font-size: 0.9rem;
    border-top: 1px solid var(--border-subtle);
}

footer strong {
    color: var(--primary-accent);
    font-weight: 600;
}

/* Responsive Design - Mobile First */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header {
        padding: 32px 24px;
    }

    header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .flow-diagram {
        padding: 20px;
        gap: 8px;
    }

    .flow-step {
        padding: 8px 12px;
    }

    .flow-icon {
        font-size: 1.25rem;
    }

    .flow-label {
        font-size: 0.7rem;
    }

    .two-phase-layout {
        grid-template-columns: 1fr;
    }

    .phase-1 {
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
    }

    .phase-panel {
        padding: 24px;
    }

    .results-section {
        padding: 24px;
    }

    .button-group {
        flex-direction: column;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
        justify-content: center;
    }

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

    .stat-value {
        font-size: 2rem;
    }

    .match-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .match-score {
        width: 100%;
        justify-content: space-between;
    }

    .score-bar {
        flex: 1;
    }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Accessibility - Focus Indicators */
*:focus {
    outline: 2px solid var(--primary-accent);
    outline-offset: 2px;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: no-preference) {
    .match-card,
    .stat-card,
    .indexed-post-card,
    .input-group textarea,
    .btn-primary,
    .btn-secondary {
        transition: all 0.2s ease;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
