/* Enhanced Clinical Trial Dashboard Styles - SAFE VERSION */

:root {
    --ctd-orange: #da5018;
    --ctd-blue: #1a99ce;
    --ctd-green: #2f9121;
    --ctd-grey: #f5f5f5;
    --ctd-dark: #2c3e50;
    --ctd-light: #ffffff;
}

.ctd-dashboard-enhanced {
    padding: 20px;
    max-width: 1600px;
    background: #f8f9fa;
}

/* Header */
.ctd-header { margin-bottom: 30px; }
.ctd-header h1 { font-size: 28px; color: var(--ctd-dark); margin: 0 0 5px 0; }
.ctd-subtitle { font-size: 14px; color: #666; margin: 0; }

/* Global Stats */
.ctd-global-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.ctd-stat-card {
    background: var(--ctd-light); border-radius: 12px; padding: 24px;
    display: flex; align-items: center; gap: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}
.ctd-stat-card:hover { transform: translateY(-3px); box-shadow: 0 4px 12px rgba(0,0,0,0.12); }

.ctd-stat-icon { width: 60px; height: 60px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.ctd-stat-icon .dashicons { font-size: 32px; width: 32px; height: 32px; }

.ctd-stat-primary .ctd-stat-icon { background: linear-gradient(135deg, var(--ctd-orange), #ff6b3d); color: white; }
.ctd-stat-success .ctd-stat-icon { background: linear-gradient(135deg, var(--ctd-green), #4cbd42); color: white; }
.ctd-stat-info .ctd-stat-icon { background: linear-gradient(135deg, var(--ctd-blue), #3bb5e8); color: white; }
.ctd-stat-warning .ctd-stat-icon { background: linear-gradient(135deg, #f39c12, #f1c40f); color: white; }

.ctd-stat-content { flex: 1; }
.ctd-stat-value { font-size: 32px; font-weight: 700; color: var(--ctd-dark); line-height: 1; margin-bottom: 5px; }
.ctd-stat-label { font-size: 14px; color: #666; font-weight: 500; }

/* Layout */
.ctd-section { margin: 40px 0; }
.ctd-section-title { font-size: 22px; color: var(--ctd-dark); margin-bottom: 20px; font-weight: 600; }

.ctd-two-column { display: grid; grid-template-columns: 400px 1fr; gap: 20px; margin-top: 20px; }
.ctd-left-column, .ctd-right-column { display: flex; flex-direction: column; gap: 20px; }

.ctd-card { background: var(--ctd-light); border-radius: 12px; padding: 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.ctd-card h3 { margin-top: 0; margin-bottom: 20px; font-size: 18px; color: var(--ctd-dark); font-weight: 600; }

/* Trial Cards */
.ctd-trial-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; margin-bottom: 30px; }
.ctd-trial-card { background: var(--ctd-light); border-radius: 12px; padding: 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); transition: all 0.3s ease; cursor: pointer; border: 2px solid transparent; }
.ctd-trial-card:hover { transform: translateY(-4px); box-shadow: 0 6px 16px rgba(0,0,0,0.12); }
.ctd-trial-card.ctd-trial-selected { border-color: var(--ctd-orange); box-shadow: 0 4px 12px rgba(218, 80, 24, 0.2); }

.ctd-trial-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; min-height: 50px; }
.ctd-trial-card-header h3 { font-size: 18px; font-weight: 700; margin: 0; line-height: 1.3; min-height: 46px; display: flex; align-items: center; }

.ctd-trial-diabetes .ctd-trial-card-header h3 { color: #f39c12; }
.ctd-trial-cancer .ctd-trial-card-header h3 { color: #e74c3c; }
.ctd-trial-dengue .ctd-trial-card-header h3 { color: var(--ctd-blue); }
.ctd-trial-other .ctd-trial-card-header h3 { color: #9b59b6; }

.ctd-trial-phase { background: #e3f2fd; color: var(--ctd-blue); padding: 4px 12px; border-radius: 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.ctd-trial-card-title { font-size: 14px; color: #666; margin: 0 0 16px 0; line-height: 1.5; }
.ctd-trial-participants { font-size: 14px; color: var(--ctd-dark); margin-bottom: 12px; }
.ctd-trial-participants strong { font-size: 18px; font-weight: 700; }

.ctd-trial-progress { margin: 12px 0 20px 0; }
.ctd-progress-bar { height: 8px; background: #e9ecef; border-radius: 4px; overflow: hidden; }
.ctd-progress-fill { height: 100%; border-radius: 4px; transition: width 1s ease; }
.ctd-trial-diabetes .ctd-progress-fill { background: linear-gradient(90deg, #f39c12, #f1c40f); }
.ctd-trial-cancer .ctd-progress-fill { background: linear-gradient(90deg, #e74c3c, #ec7063); }
.ctd-trial-dengue .ctd-progress-fill { background: linear-gradient(90deg, var(--ctd-blue), #3bb5e8); }
.ctd-trial-other .ctd-progress-fill { background: linear-gradient(90deg, #9b59b6, #a569bd); }

.ctd-trial-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.ctd-trial-meta-item { display: flex; flex-direction: column; }
.ctd-meta-label { font-size: 11px; color: #999; text-transform: uppercase; font-weight: 600; margin-bottom: 4px; }
.ctd-meta-value { font-size: 13px; color: var(--ctd-dark); font-weight: 600; }

.ctd-trial-view-btn { width: 100%; padding: 10px; background: var(--ctd-orange); color: white; border: none; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.3s ease; }
.ctd-trial-view-btn:hover { background: #c04516; }

/* Charts */
.ctd-funnel-chart-vertical { margin-bottom: 20px; min-height: 400px; }
.ctd-funnel-stats-vertical { display: flex; flex-direction: column; gap: 12px; }
.ctd-funnel-stat { display: flex; align-items: center; gap: 12px; padding: 12px; background: #f8f9fa; border-radius: 8px; }
.ctd-funnel-color { width: 20px; height: 20px; border-radius: 4px; }
.ctd-funnel-intake { background: rgba(26, 153, 206, 0.8); }
.ctd-funnel-qualified { background: rgba(243, 156, 18, 0.8); }
.ctd-funnel-converted { background: rgba(47, 145, 33, 0.8); }
.ctd-funnel-info { flex: 1; display: flex; justify-content: space-between; align-items: center; }
.ctd-funnel-stats-vertical .ctd-funnel-label { font-size: 13px; color: var(--ctd-dark); font-weight: 600; }
.ctd-funnel-stats-vertical .ctd-funnel-value { font-size: 14px; color: #666; font-weight: 500; }

.ctd-pueblos-chart { position: relative; height: 300px; }

/* Map */
.ctd-heatmap-container {
    position: relative;
    height: 400px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #fff;
    border: 1px solid #dee2e6;
}

#puerto-rico-map { width: 95% !important; height: auto !important; max-height: 90% !important; transform-origin: center center; cursor: grab; transition: transform 0.3s ease; }
#puerto-rico-map:active { cursor: grabbing; }

.ctd-map-controls {
    position: absolute; bottom: 15px !important; right: 15px !important;
    display: flex; flex-direction: row !important; gap: 8px; z-index: 100;
}

.ctd-map-btn {
    width: 32px; height: 32px; background: white; border: 1px solid #ccc; border-radius: 4px;
    font-size: 18px; font-weight: bold; color: #555; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.ctd-map-btn:hover { background: #f0f0f0; color: #000; }

.ctd-heatmap-legend { position: absolute; bottom: 10px; left: 15px; display: flex; align-items: center; gap: 8px; }
.ctd-legend-gradient { width: 100px; height: 10px; background: linear-gradient(90deg, #f8f9fa 0%, #fff0eb 25%, #ffcbb3 50%, #ff9668 75%, #da5018 100%); border-radius: 2px; }

/* Scroll Button */
.ctd-section-header-with-button { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.ctd-section-header-with-button h3 { margin: 0; }
.ctd-scroll-to-table-btn {
    background: linear-gradient(135deg, var(--ctd-orange), #ff6b3d);
    color: white; border: none; border-radius: 8px; padding: 10px 18px;
    font-size: 13px; font-weight: 600; cursor: pointer;
    display: flex; align-items: center; gap: 8px;
    transition: all 0.3s ease; box-shadow: 0 2px 6px rgba(218, 80, 24, 0.3);
}
.ctd-scroll-to-table-btn:hover { background: linear-gradient(135deg, #c04516, #e55a2a); box-shadow: 0 4px 12px rgba(218, 80, 24, 0.4); transform: translateY(-2px); }
.ctd-scroll-to-table-btn:active { transform: translateY(0); }
.ctd-scroll-to-table-btn .dashicons { font-size: 18px; width: 18px; height: 18px; }

/* Participant Cards */
.ctd-participant-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 30px; }
.ctd-participant-card {
    background: var(--ctd-light); border: 1px solid #e9ecef; border-radius: 12px; padding: 20px;
    transition: all 0.3s ease; cursor: pointer; min-height: 240px; display: flex; flex-direction: column; position: relative;
}
.ctd-participant-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-2px); border-color: var(--ctd-orange); }

/* CLICK INDICATOR ARROW (SAFE CSS CODE) */
.ctd-participant-card::after {
    content: '\2192'; /* SAFE ARROW */
    position: absolute; right: 20px; top: 50%; transform: translateY(-50%);
    font-size: 20px; color: var(--ctd-orange); opacity: 0; transition: all 0.3s;
}
.ctd-participant-card:hover::after { opacity: 1; right: 15px; }

.ctd-participant-header { display: flex; gap: 12px; margin-bottom: 16px; }
.ctd-participant-avatar { width: 50px; height: 50px; background: linear-gradient(135deg, var(--ctd-orange), #ff6b3d); border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ctd-participant-avatar .dashicons { color: white; font-size: 28px; width: 28px; height: 28px; }
.ctd-participant-info { flex: 1; min-width: 0; }
.ctd-participant-info h4 { margin: 0 0 4px 0; font-size: 15px; font-weight: 600; color: var(--ctd-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctd-participant-meta { font-size: 12px; color: #666; line-height: 1.5; margin: 0; }
.ctd-participant-score { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ctd-score-circle { width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; border: 3px solid; }
.ctd-match-high .ctd-score-circle { background: #d4edda; border-color: var(--ctd-green); color: var(--ctd-green); }
.ctd-match-medium .ctd-score-circle { background: #fff3cd; border-color: #f39c12; color: #f39c12; }
.ctd-match-low .ctd-score-circle { background: #f8d7da; border-color: #e74c3c; color: #e74c3c; }
.ctd-score-label { font-size: 11px; color: #999; text-transform: uppercase; font-weight: 600; }

.ctd-participant-details { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid #e9ecef; margin-top: auto; }
.ctd-detail-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #666; }
.ctd-detail-icon { font-size: 14px; flex-shrink: 0; }

/* Medical Pills */
.ctd-medical-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.ctd-med-tag { background: #f1f3f5; color: #495057; border: 1px solid #dee2e6; border-radius: 12px; padding: 2px 8px; font-size: 11px; font-weight: 600; white-space: nowrap; display: inline-block; }
.ctd-med-tag.alert-high { background: #fff5f5; color: #e03131; border-color: #ffc9c9; }
.ctd-more-tag { color: var(--ctd-orange); background-color: #fff0eb; border-color: #ffdac9; }

/* Table */
.ctd-table { border: 1px solid #ddd !important; border-radius: 8px; overflow: hidden; }
.ctd-table th { background: #f8f9fa !important; font-weight: 600 !important; padding: 14px 12px !important; border-bottom: 2px solid #dee2e6 !important; font-size: 13px; }
.ctd-table td { padding: 16px 12px !important; vertical-align: middle !important; }
.ctd-table tbody tr:hover { background: #f8f9fa; }
.ctd-col-rank { width: 50px; text-align: center; }
.ctd-rank { font-weight: 700; color: var(--ctd-orange); font-size: 16px; }
.ctd-contact-info { font-size: 11px; color: #666; line-height: 1.6; }

.ctd-stage-badge { display: inline-block; padding: 5px 12px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: capitalize; }
.ctd-stage-converted { background: #d4edda; color: #155724; }
.ctd-stage-qualified { background: #fff3cd; color: #856404; }
.ctd-stage-intake { background: #d1ecf1; color: #0c5460; }

.ctd-score-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Bar container: always use full available width */
.ctd-score-bar {
    flex: 1 1 auto;
    width: 100%;
    max-width: none;
    /*min-width: 80px;*/
    height: 20px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #dee2e6;
}

/* Fill element – gets the width inline (0–100%) */
.ctd-score-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s ease;
}

/* Colors apply ONLY to the fill */
.ctd-score-fill.ctd-score-high   { background: #2ecc71; }
.ctd-score-fill.ctd-score-medium { background: #f1c40f; }
.ctd-score-fill.ctd-score-low    { background: #e67e22; }

/* Percentage text – no colored pill behind it */
.ctd-score-text-readable {
    font-weight: 900 !important;
    font-size: 16px !important;
    min-width: 65px;
    text-align: right;
    color: #333 !important;
    margin-left: 12px;
    background: transparent; /* make sure there is no color block */
    white-space: nowrap;
}

/* Extra safety: remove background if any score class leaks onto the text */
.ctd-score-text-readable.ctd-score-high,
.ctd-score-text-readable.ctd-score-medium,
.ctd-score-text-readable.ctd-score-low {
    background: transparent;
}


/* Details */
.ctd-details-content { padding: 24px; }
.ctd-details-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.ctd-detail-section { background: var(--ctd-light); padding: 16px; border-radius: 8px; border: 1px solid #dee2e6; }
.ctd-detail-section h4 { margin: 0 0 12px 0; font-size: 13px; color: var(--ctd-dark); font-weight: 600; border-bottom: 2px solid var(--ctd-orange); padding-bottom: 8px; }
.ctd-match-details li { padding: 8px 0; font-size: 13px; color: #666; border-bottom: 1px solid #eee; }
.ctd-match-details li:before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 10px; background: var(--ctd-orange); }
.ctd-toggle-details { font-size: 12px; padding: 6px 12px; height: auto; line-height: 1.4; }

@keyframes highlightRow { 0% { background-color: #fff3cd; } 100% { background-color: transparent; } }
.ctd-row-highlight { animation: highlightRow 2.5s ease-out forwards; background-color: #fff3cd !important; }
.ctd-row-highlight td { background-color: #fff3cd !important; }

/* Responsive */
@media screen and (max-width: 1400px) { .ctd-two-column { grid-template-columns: 350px 1fr; } }
@media screen and (max-width: 1200px) { .ctd-two-column { grid-template-columns: 1fr; } .ctd-details-grid { grid-template-columns: 1fr; } .ctd-section-header-with-button { flex-direction: column; align-items: flex-start; gap: 15px; } .ctd-scroll-to-table-btn { width: 100%; justify-content: center; } }
@media screen and (max-width: 768px) { .ctd-global-stats { grid-template-columns: 1fr; } .ctd-mini-stats { grid-template-columns: repeat(2, 1fr); } .ctd-table { font-size: 12px; } }

/* Tab Navigation */
.ctd-tabs { 
    margin-bottom: 20px; 
    display: flex;
    gap: 0;
    border-bottom: 2px solid #ddd;
}
.ctd-tabs .nav-tab { 
    display: inline-flex; 
    align-items: center; 
    gap: 8px; 
    padding: 14px 28px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    text-decoration: none;
    color: #555;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    margin-bottom: -2px;
}
.ctd-tabs .nav-tab:hover {
    background: #e8e8e8;
    color: #333;
}
.ctd-tabs .nav-tab-active {
    background: #fff;
    border-bottom: 2px solid #fff;
    color: var(--ctd-orange);
}
.ctd-tabs .nav-tab .dashicons { 
    font-size: 18px; 
    width: 18px; 
    height: 18px; 
}
.ctd-tab-badge { 
    background: #d63638; 
    color: #fff; 
    padding: 3px 10px; 
    border-radius: 12px; 
    font-size: 12px; 
    font-weight: 700; 
    margin-left: 8px; 
}