/**
 * ═══════════════════════════════════════════════════════════════════════════
 * CORE-WOUND CHAIN MAPPING STYLES
 * Deep Pattern Visualization - DSP-08 Extension
 * ═══════════════════════════════════════════════════════════════════════════
 */

/* Enable scrolling for this page */
body.core-wounds-page {
    overflow-y: auto !important;
    overflow-x: hidden;
    height: auto;
    min-height: 100vh;
}

body.core-wounds-page #app {
    height: auto;
    min-height: 100vh;
}

/* ═══════════════════════════════════════════════════════════════════════════
   VARIABLES
   ═══════════════════════════════════════════════════════════════════════════ */

.core-wounds-page {
    --wound-worthiness: #fbbf24;
    --wound-safety: #f472b6;
    --wound-performance: #60a5fa;
    --wound-connection: #a78bfa;
    
    --role-root: #ef4444;
    --role-origin: #f97316;
    --role-mediator: #eab308;
    --role-expression: #22c55e;
    --role-symptom: #3b82f6;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PAGE LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */

.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
    padding-top: 80px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.page-title {
    font-size: 1.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.title-icon {
    font-size: 2rem;
}

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

.header-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-secondary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-muted);
}

.btn-primary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #64b4a0, #508cb4);
    border: none;
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(100, 180, 160, 0.3);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   CATEGORIES SECTION
   ═══════════════════════════════════════════════════════════════════════════ */

.categories-section {
    margin-bottom: 2rem;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.category-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--category-color);
}

.category-card:hover {
    transform: translateY(-2px);
    border-color: var(--category-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.category-card.active {
    border-color: var(--category-color);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
}

.category-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

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

.category-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.category-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════════
   CHAINS SECTION
   ═══════════════════════════════════════════════════════════════════════════ */

.chains-section {
    margin-bottom: 2rem;
}

.chains-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.chains-stats {
    display: flex;
    gap: 1.5rem;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: #64b4a0;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.chains-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   CHAIN CARD
   ═══════════════════════════════════════════════════════════════════════════ */

.chain-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chain-card:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
    border-color: rgba(100, 180, 160, 0.3);
    transform: translateX(4px);
}

.chain-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.chain-wound {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.wound-category-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: rgba(255, 255, 255, 0.05);
}

.wound-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.wound-category-name {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.chain-confidence {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: rgba(100, 180, 160, 0.1);
    border-radius: 20px;
    font-size: 0.8rem;
    color: #64b4a0;
}

/* Chain Path Visualization */
.chain-path {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
}

.chain-path::-webkit-scrollbar {
    height: 4px;
}

.chain-path::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
}

.chain-path::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.path-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    min-width: 70px;
}

.node-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.node-icon.role-root { border-color: var(--role-root); background: rgba(239, 68, 68, 0.1); }
.node-icon.role-origin { border-color: var(--role-origin); background: rgba(249, 115, 22, 0.1); }
.node-icon.role-mediator { border-color: var(--role-mediator); background: rgba(234, 179, 8, 0.1); }
.node-icon.role-expression { border-color: var(--role-expression); background: rgba(34, 197, 94, 0.1); }
.node-icon.role-symptom { border-color: var(--role-symptom); background: rgba(59, 130, 246, 0.1); }

.node-name {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: center;
    max-width: 80px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.node-role {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
}

.node-role.role-root { color: var(--role-root); }
.node-role.role-origin { color: var(--role-origin); }
.node-role.role-mediator { color: var(--role-mediator); }
.node-role.role-expression { color: var(--role-expression); }
.node-role.role-symptom { color: var(--role-symptom); }

.path-arrow {
    color: var(--text-muted);
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* Chain Footer */
.chain-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.chain-insight {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
    flex: 1;
    margin-right: 1rem;
}

.chain-companion {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    font-size: 0.8rem;
}

.companion-emoji {
    font-size: 1rem;
}

.companion-name {
    color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODAL STYLES
   ═══════════════════════════════════════════════════════════════════════════ */

.chain-detail-modal,
.analysis-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.chain-detail-modal.hidden,
.analysis-modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    background: linear-gradient(135deg, #1a1a24, #12121a);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-title-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.modal-category-icon {
    font-size: 2rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.modal-category {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.subsection-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Chain Flow in Modal */
.chain-flow-section {
    margin-bottom: 1.5rem;
}

.chain-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    overflow-x: auto;
}

.flow-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.flow-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid transparent;
}

.flow-icon.role-root { border-color: var(--role-root); background: rgba(239, 68, 68, 0.15); }
.flow-icon.role-origin { border-color: var(--role-origin); background: rgba(249, 115, 22, 0.15); }
.flow-icon.role-mediator { border-color: var(--role-mediator); background: rgba(234, 179, 8, 0.15); }
.flow-icon.role-expression { border-color: var(--role-expression); background: rgba(34, 197, 94, 0.15); }
.flow-icon.role-symptom { border-color: var(--role-symptom); background: rgba(59, 130, 246, 0.15); }

.flow-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    max-width: 90px;
}

.flow-role {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.flow-arrow {
    color: var(--text-muted);
    font-size: 1.5rem;
}

/* Metrics Section */
.metrics-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.metric-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    padding: 1rem;
}

.metric-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.metric-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.metric-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.confidence-fill {
    background: linear-gradient(90deg, #64b4a0, #4ade80);
}

.strength-fill {
    background: linear-gradient(90deg, #60a5fa, #a78bfa);
}

.metric-value {
    font-size: 1.1rem;
    font-weight: 600;
    text-align: right;
}

/* Insight Section */
.insight-section {
    margin-bottom: 1.5rem;
}

.insight-text {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-secondary);
    padding: 1rem;
    background: rgba(100, 180, 160, 0.1);
    border-radius: 10px;
    border-left: 3px solid #64b4a0;
}

/* Healing Focus Section */
.healing-focus-section {
    margin-bottom: 1.5rem;
}

.healing-focus {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
}

.companion-badge {
    font-size: 2rem;
}

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

/* Propagation Section */
.propagation-section {
    margin-bottom: 1.5rem;
}

.propagation-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.propagation-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}

.propagation-from,
.propagation-to {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.propagation-arrow {
    color: var(--text-muted);
}

.propagation-mechanism {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: auto;
    max-width: 200px;
    text-align: right;
}

/* Approach Section */
.approach-section {
    margin-bottom: 1rem;
}

.approach-steps {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.approach-step {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}

.step-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #64b4a0, #508cb4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

.step-content {
    flex: 1;
}

.step-focus {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

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

/* Modal Footer */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Analysis Modal */
.analysis-content {
    max-width: 500px;
    text-align: center;
}

.analysis-header {
    padding: 2rem 1.5rem 1rem;
}

.analysis-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.analysis-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.analysis-body {
    padding: 1.5rem;
}

.analysis-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #64b4a0;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.analysis-results {
    text-align: left;
}

.analysis-stat {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.analysis-stat:last-child {
    border-bottom: none;
}

.analysis-insights {
    margin-top: 1.5rem;
}

.analysis-insights h4 {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.analysis-insight-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.analysis-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

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

.empty-text {
    font-size: 0.95rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .header-actions {
        width: 100%;
    }
    
    .header-actions .btn-secondary {
        flex: 1;
        justify-content: center;
    }
    
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .chain-path {
        gap: 0.25rem;
    }
    
    .path-node {
        min-width: 60px;
    }
    
    .node-icon {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }
    
    .metrics-section {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        max-height: 95vh;
        border-radius: 16px 16px 0 0;
    }
    
    .chain-flow {
        justify-content: flex-start;
    }
}

@media (max-width: 480px) {
    .categories-grid {
        grid-template-columns: 1fr;
    }
    
    .chains-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .chain-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .chain-insight {
        margin-right: 0;
    }
}
