/* Twenthir Federated Health Intelligence - Styles */

:root {
    --primary-color: #1E88E5;
    --primary-dark: #1565C0;
    --accent-color: #43A047;
    --background: #F5F5F5;
    --card-bg: #FFFFFF;
    --text-primary: #212121;
    --text-secondary: #757575;
    --border-color: #E0E0E0;
    --success: #43A047;
    --online: #4CAF50;
}

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

body {
    font-family: 'Inter', 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

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

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

nav {
    display: flex;
    gap: 0.5rem;
}

.nav-btn {
    background: rgba(255,255,255,0.1);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-btn:hover {
    background: rgba(255,255,255,0.2);
}

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

/* Tagline */
.tagline {
    background: var(--card-bg);
    padding: 2rem 0;
    text-align: center;
    border-bottom: 3px solid var(--primary-color);
}

.tagline h2 {
    color: var(--primary-color);
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

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

/* Main Content */
main {
    padding: 2rem 0;
    min-height: calc(100vh - 400px);
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.4s ease-in;
}

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

.page h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.page-description {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1.05rem;
}

.section {
    margin-top: 2rem;
}

.section h3 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.section h4 {
    font-size: 1.2rem;
    margin: 1.5rem 0 1rem 0;
    color: var(--text-primary);
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.metric-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.metric-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.metric-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

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

.metric-status {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.metric-status.online {
    color: var(--online);
    font-weight: 600;
}

.metric-status.secure {
    color: var(--accent-color);
    font-weight: 600;
}

/* Facilities Grid */
.facilities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.facility-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.facility-card:hover {
    transform: translateY(-5px);
}

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

.facility-header h4 {
    font-size: 1.1rem;
    margin: 0;
    color: var(--text-primary);
}

.status-badge {
    font-size: 0.85rem;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-weight: 500;
}

.status-badge.online {
    background: rgba(76, 175, 80, 0.1);
    color: var(--online);
}

.location {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.facility-stats {
    display: flex;
    gap: 2rem;
    margin: 1rem 0;
}

.stat {
    display: flex;
    flex-direction: column;
}

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

.stat-value {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary-color);
}

.specialty {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.95rem;
}

/* Query Templates */
.query-templates {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.template-btn {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    padding: 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    transition: all 0.3s ease;
}

.template-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(30, 136, 229, 0.2);
}

.template-btn.selected {
    border-color: var(--primary-color);
    background: rgba(30, 136, 229, 0.05);
}

.template-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.template-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Buttons */
.primary-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.primary-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 136, 229, 0.3);
}

.primary-btn:disabled {
    background: #BDBDBD;
    cursor: not-allowed;
}

/* Progress */
.progress-section {
    margin: 2rem 0;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    width: 0%;
    transition: width 0.3s ease;
    animation: progressAnimation 2s ease-in-out;
}

@keyframes progressAnimation {
    0% { width: 0%; }
    100% { width: 100%; }
}

.progress-text {
    text-align: center;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Success Message */
.success-message {
    background: rgba(67, 160, 71, 0.1);
    border-left: 4px solid var(--success);
    padding: 1rem;
    border-radius: 8px;
    margin: 1.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    color: var(--success);
}

/* Info Box */
.info-box {
    background: rgba(30, 136, 229, 0.1);
    border-left: 4px solid var(--primary-color);
    padding: 1rem;
    border-radius: 8px;
    margin: 1.5rem 0;
    display: flex;
    align-items: start;
    gap: 0.75rem;
}

.info-box i {
    color: var(--primary-color);
    margin-top: 0.2rem;
}

/* Detail Rows */
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

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

.detail-value {
    color: var(--text-secondary);
}

/* Data Table */
.data-table {
    width: 100%;
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.data-table thead {
    background: var(--primary-color);
    color: white;
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody tr:last-child {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: rgba(30, 136, 229, 0.05);
}

/* Charts */
#facility-map,
#results-chart,
#payout-chart,
#pharma-payout-chart {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin: 1.5rem 0;
    min-height: 400px;
}

/* Facility Map Fallback */
.facility-map-container {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin: 1.5rem 0;
}

.map-fallback {
    width: 100%;
}

.map-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--primary-color);
}

.map-header h4 {
    font-size: 1.4rem;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
}

.map-header p {
    color: var(--text-secondary);
    margin: 0;
}

.facilities-map-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.map-facility-card {
    background: linear-gradient(135deg, rgba(30, 136, 229, 0.05), rgba(255,255,255,1));
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    padding: 1.5rem;
    position: relative;
    transition: all 0.3s ease;
}

.map-facility-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(30, 136, 229, 0.2);
}

.map-facility-card.west {
    border-color: #1E88E5;
}

.map-facility-card.south {
    border-color: #43A047;
}

.map-facility-card.mountain {
    border-color: #FF9800;
}

.map-pin {
    font-size: 2rem;
    position: absolute;
    top: -10px;
    right: 20px;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.facility-map-info h5 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
}

.facility-map-info .location {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 0 0 1rem 0;
}

.facility-mini-stats {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1rem 0;
    padding: 1rem 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.facility-mini-stats span {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.status-indicator {
    display: inline-block;
    padding: 0.4rem 1rem;
    background: rgba(76, 175, 80, 0.1);
    color: var(--online);
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.map-legend {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.map-legend span {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Diagnosis Chart CSS */
.diagnosis-chart-container {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin: 1.5rem 0;
}

.chart-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--primary-color);
}

.chart-header h4 {
    font-size: 1.3rem;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
}

.chart-header p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.95rem;
}

.diagnosis-bars {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin: 2rem 0;
}

.diagnosis-bar-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.diagnosis-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.diagnosis-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.diagnosis-count {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.diagnosis-bar-bg {
    width: 100%;
    height: 40px;
    background: var(--border-color);
    border-radius: 20px;
    overflow: hidden;
    position: relative;
}

.diagnosis-bar-fill {
    height: 100%;
    border-radius: 20px;
    transition: width 1s ease-out;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 1rem;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
}

.chart-footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.chart-footer p {
    margin: 0;
}

/* Footer */
footer {
    background: var(--text-primary);
    color: white;
    padding: 2rem 0;
    margin-top: 4rem;
    text-align: center;
}

footer p {
    margin: 0.25rem 0;
}

/* Responsive */
@media (max-width: 768px) {
    header .container {
        flex-direction: column;
        gap: 1rem;
    }

    nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    .nav-btn {
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
    }

    .metrics-grid,
    .facilities-grid,
    .query-templates {
        grid-template-columns: 1fr;
    }

    .tagline h2 {
        font-size: 1.4rem;
    }

    .page h2 {
        font-size: 1.6rem;
    }
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.pulsing {
    animation: pulse 2s ease-in-out infinite;
}

/* Pharma Study Card */
.pharma-study-card {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin: 1.5rem 0;
}

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

.study-header h4 {
    font-size: 1.3rem;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
}

.study-sponsor {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 0;
}

.study-badge {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

.study-description {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 1rem 0 1.5rem 0;
}

.study-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.study-stat {
    text-align: center;
}

.study-stat .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.study-stat .stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Calculation Card */
.calculation-card {
    background: linear-gradient(135deg, rgba(30, 136, 229, 0.05), rgba(67, 160, 71, 0.05));
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    border: 2px solid var(--primary-color);
}

.calculation-card h4 {
    margin: 0 0 1rem 0;
    color: var(--primary-color);
}

.formula-display {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
}

.formula-line {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.formula-line:last-child {
    border-bottom: none;
}

.formula-line.highlighted {
    background: rgba(30, 136, 229, 0.1);
    padding: 1rem;
    margin: 0.5rem -1rem 0;
    border-radius: 8px;
    font-weight: 600;
    border-bottom: none;
}

.formula-label {
    color: var(--text-primary);
    font-weight: 500;
}

.formula-value {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.1rem;
}

/* Weighting Grid */
.weighting-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.weight-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.weight-card:hover {
    transform: translateY(-5px);
}

.weight-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.weight-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0.5rem 0;
}

.weight-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0.5rem 0;
}

.weight-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Contribution Table */
.contribution-table {
    overflow-x: auto;
}

.score-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.score-bar-bg {
    flex: 1;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    border-radius: 10px;
    transition: width 0.5s ease;
}

.score-number {
    font-weight: 600;
    color: var(--primary-color);
    min-width: 40px;
    text-align: right;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .study-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .study-badge {
        align-self: flex-start;
    }
    
    .weighting-grid {
        grid-template-columns: 1fr;
    }
    
    .formula-line {
        flex-direction: column;
        gap: 0.5rem;
    }
}
