/**
 * WP Clinical Pipeline - Frontend Styles
 * Modern minimal pipeline UI with arrow endcap progress bars
 */

:root {
    --wcp-fill-color: #5EA7BF;
    --wcp-unfilled-color: #E6E6E6;
    --wcp-future-stage-color: #7A7A7A;
    --wcp-text-color: #1F2937;
    --wcp-muted-text: #6B7280;
    --wcp-program-bg: #5EA7BF;
    --wcp-details-bg: #8E8E8E;
}

.wcp-pipeline-container {
    max-width: 100%;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    background: #ffffff;
    padding: 40px 20px;
}

/* Section Header */
.wcp-pipeline-section {
    margin-bottom: 60px;
}

.wcp-section-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.wcp-section-divider {
    color: #707070;
    font-size: 24px;
    font-weight: 300;
}

.wcp-section-title {
    margin: 0;
    padding: 0;
    font-size: 24px;
    font-weight: 400;
    color: var(--wcp-text-color);
    letter-spacing: 0.5px;
}

.wcp-section-subtitle {
    font-size: 16px;
    color: var(--wcp-muted-text);
    font-weight: 300;
}

/* Timeline */
.wcp-timeline {
    margin-bottom: 30px;
    position: relative;
}

.wcp-timeline-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding: 0 280px 0 0;
}

.wcp-timeline-label {
    font-size: 12px;
    color: var(--wcp-muted-text);
    font-weight: 400;
    text-align: center;
    flex: 1;
}

.wcp-timeline-track {
    height: 2px;
    background: #D1D5DB;
    margin: 0 280px 0 0;
    position: relative;
}

.wcp-timeline-track::before {
    content: '';
    position: absolute;
    left: 0;
    top: -4px;
    width: 10px;
    height: 10px;
    background: var(--wcp-fill-color);
    border-radius: 50%;
}

.wcp-timeline-track::after {
    content: '';
    position: absolute;
    right: 0;
    top: -4px;
    width: 10px;
    height: 10px;
    background: var(--wcp-fill-color);
    border-radius: 50%;
}

/* Stage Labels Row */
.wcp-stage-labels {
    display: grid;
    grid-template-columns: 280px repeat(8, minmax(120px, 1fr));
    gap: 0;
    margin-bottom: 15px;
    padding: 0;
    white-space: nowrap;
}

.wcp-stage-label {
    padding: 12px 10px;
    font-size: 13px;
    font-weight: 400;
    color: var(--wcp-muted-text);
    text-align: center;
    background: transparent;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wcp-stage-label.wcp-stage-program {
    background: transparent;
    text-align: left;
    padding-left: 20px;
}

.wcp-stage-desc {
    display: inline;
    font-size: 11px;
    color: var(--wcp-muted-text);
    opacity: 0.8;
    margin-left: 4px;
    line-height: 1.2;
}

/* Pipeline Row */
.wcp-pipeline-row {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 0;
    margin-bottom: 12px;
    min-height: 80px;
    align-items: stretch;
    position: relative;
    overflow: visible;
}

/* Program Info Column */
.wcp-program-info {
    background: #76b3c7;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
}

.wcp-program-code {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.3;
    letter-spacing: 0.3px;
}

.wcp-program-description {
    font-size: 13px;
    font-weight: 400;
    color: #ffffff;
    line-height: 1.4;
    opacity: 0.95;
}

/* Progress Wrapper - Main container */
.wcp-progress-wrapper {
    position: relative;
    min-height: 80px;
    width: 100%;
    overflow: visible;
}

/* Progress Container - Background layer (gray) */
.wcp-progress-container {
    position: relative;
    background: var(--wcp-unfilled-color);
    min-height: 80px;
    width: 100%;
    overflow: visible;
    display: flex;
    align-items: center;
    padding: 10px 0;
    z-index: 1;
    pointer-events: none;
}

.wcp-progress-container > * {
    pointer-events: auto;
}

/* When complete, hide background */
.wcp-progress-wrapper.complete .wcp-progress-container {
    background: transparent;
}

/* Progress Fill - Blue progress bar */
.wcp-progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: var(--wcp-fill-color);
    z-index: 2;
    transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: visible;
    pointer-events: none;
    margin: 18px 0px;
}

/* Progress Fill - For 100% completion */
.wcp-progress-wrapper.complete .wcp-progress-fill {
    width: 100% !important;
}

/* Arrow at the end of progress */
.wcp-progress-arrow-end {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 18px;
    height: 100%;
    min-height: 80px;
    background: var(--wcp-fill-color);
    clip-path: polygon(0 0, 100% 50%, 0 100%);
    z-index: 15 !important;
    pointer-events: none;
    transition: left 1.5s cubic-bezier(0.4, 0, 0.2, 1), right 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Arrow positioning for partial progress - arrow tip aligns with progress end */
.wcp-progress-wrapper:not(.complete) .wcp-progress-arrow-end {
    transform: translateX(-100%);
}

/* Hide arrow when progress is 0 */
.wcp-progress-wrapper[data-progress="0"] .wcp-progress-arrow-end,
.wcp-progress-wrapper[data-progress="0%"] .wcp-progress-arrow-end {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Arrow at the end when 100% */
.wcp-progress-wrapper.complete .wcp-progress-arrow-end {
    right: -18px;
    left: auto !important;
    transform: none;
}

/* Stage Grid - 8 columns for stage labels */
.wcp-stage-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(120px, 1fr));
    gap: 0;
    width: 100%;
    align-items: center;
    position: relative;
    z-index: 3;
    height: 100%;
}

.wcp-stage-column {
    min-height: 40px;
    display: flex;
    align-items: center;
    padding: 0 4px;
    position: relative;
    z-index: 4;
}

/* Stage Track - Container for arrow tags within a column */
.wcp-stage-track {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0;
    overflow: visible;
    flex-wrap: wrap;
    width: 100%;
    position: relative;
    z-index: 5;
}

/* Stage Arrow Tags */
.wcp-stage-arrow {
    position: relative;
    height: var(--h, 34px);
    min-width: 64px;
    background: var(--color, #F2B28C);
    border: 2px solid #2E4A76;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: #111111;
    box-sizing: border-box;
    padding: 0 14px;
    clip-path: polygon(
        0 0,
        calc(100% - var(--ah, 18px)) 0,
        100% 50%,
        calc(100% - var(--ah, 18px)) 100%,
        0 100%
    );
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
    z-index: 6;
}

/* Main stage arrows */
.wcp-stage-arrow--main {
    --h: 34px;
    --ah: 18px;
    min-width: 80px;
}

/* Badge/small stage arrows (for NDA, IND, etc.) */
.wcp-stage-arrow--badge {
    --h: 28px;
    --ah: 14px;
    font-size: 13px;
    min-width: 60px;
}

/* Stage Connector - Arrow between stages */
.wcp-stage-connector {
    width: var(--ah, 18px);
    height: var(--h, 34px);
    background: var(--color, #F2B28C);
    border-top: 2px solid #2E4A76;
    border-bottom: 2px solid #2E4A76;
    clip-path: polygon(0 0, 100% 50%, 0 100%);
    flex-shrink: 0;
    margin-left: -2px;
    position: relative;
    z-index: 6;
}

.wcp-stage-arrow--badge + .wcp-stage-connector {
    --h: 28px;
    --ah: 14px;
}

/* Ensure last arrow doesn't overflow */
.wcp-stage-track .wcp-stage-arrow:last-child {
    margin-right: 0;
}

.wcp-progress-track {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: visible;
}

.wcp-progress-bar {
    height: 100%;
    background: var(--wcp-fill-color);
    border-radius: 0;
    transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: visible;
}

/* Arrow Endcap */
.wcp-progress-arrow {
    position: absolute;
    right: -18px;
    top: 0;
    bottom: 0;
    width: 18px;
    background: var(--wcp-fill-color);
    clip-path: polygon(0 0, 100% 50%, 0 100%);
    z-index: 1;
}

/* Hide arrow when at 100% to prevent overflow */
.wcp-progress-bar[style*="width: 100%"] .wcp-progress-arrow,
.wcp-progress-bar[style*="width:100%"] .wcp-progress-arrow {
    display: none;
}

/* Hide arrow when progress is 0 */
.wcp-progress-bar[style*="width: 0%"] .wcp-progress-arrow,
.wcp-progress-bar[style*="width:0%"] .wcp-progress-arrow {
    display: none;
}

/* Tooltip */
.wcp-pipeline-row[data-tooltip] {
    position: relative;
    cursor: help;
}

.wcp-pipeline-row[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    padding: 8px 12px;
    background: #1F2937;
    color: #ffffff;
    font-size: 12px;
    white-space: nowrap;
    border-radius: 4px;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.wcp-pipeline-row[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 2px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #1F2937;
    z-index: 1001;
    pointer-events: none;
}

/* Hover effects */
.wcp-pipeline-row:hover .wcp-progress-bar {
    filter: brightness(1.05);
    box-shadow: 0 0 0 1px rgba(94, 167, 191, 0.2);
}

/* Responsive Design */
@media screen and (max-width: 1024px) {
    .wcp-stage-labels {
        grid-template-columns: 220px repeat(8, minmax(100px, 1fr));
    }
    
    .wcp-stage-label {
        font-size: 12px;
        padding: 10px 6px;
    }
    
    .wcp-stage-desc {
        font-size: 10px;
    }
    
    .wcp-pipeline-row {
        grid-template-columns: 220px 1fr;
    }
    
    .wcp-timeline-labels {
        padding-right: 220px;
    }
    
    .wcp-timeline-track {
        margin-right: 220px;
    }
    
    .wcp-program-info {
        padding: 15px 16px;
    }
    
    .wcp-program-code {
        font-size: 15px;
    }
    
    .wcp-program-description {
        font-size: 12px;
    }
    
    .wcp-stage-arrow {
        font-size: 13px;
        min-width: 70px;
    }
    
    .wcp-stage-arrow--main {
        --h: 32px;
        --ah: 16px;
    }
    
    .wcp-stage-arrow--badge {
        --h: 26px;
        --ah: 12px;
        font-size: 12px;
        min-width: 56px;
    }
}

@media screen and (max-width: 768px) {
    .wcp-pipeline-container {
        padding: 20px 16px;
        overflow-x: visible;
    }
    
    .wcp-pipeline-section {
        margin-bottom: 40px;
    }
    
    .wcp-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 24px;
    }
    
    .wcp-section-divider {
        display: none;
    }
    
    .wcp-section-title {
        font-size: 22px;
    }
    
    .wcp-section-subtitle {
        font-size: 14px;
    }
    
    /* Hide desktop timeline and stage labels on mobile */
    .wcp-timeline {
        display: none;
    }
    
    .wcp-stage-labels {
        display: none;
    }
    
    /* Mobile Card Layout */
    .wcp-pipeline-row {
        display: flex;
        flex-direction: column;
        margin-bottom: 20px;
        background: #ffffff;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        overflow: hidden;
    }
    
    .wcp-program-info {
        padding: 16px;
        background: #76b3c7;
        border-radius: 0;
        border-bottom: none;
    }
    
    .wcp-program-code {
        font-size: 16px;
        font-weight: 600;
        margin-bottom: 8px;
    }
    
    .wcp-program-description {
        font-size: 13px;
        line-height: 1.5;
        margin-bottom: 4px;
    }
    
    .wcp-program-description:last-child {
        margin-bottom: 0;
    }
    
    /* Progress Wrapper - Vertical Timeline Style */
    .wcp-progress-wrapper {
        display: flex;
        flex-direction: column;
        min-height: auto;
        background: #F9FAFB;
        padding: 16px;
        position: relative;
    }
    
    /* Hide desktop progress bar and arrow */
    .wcp-progress-fill,
    .wcp-progress-arrow-end,
    .wcp-progress-track {
        display: none !important;
    }
    
    /* Remove margin on mobile */
    .wcp-progress-fill {
        margin: 0 !important;
    }
    
    .wcp-progress-container {
        background: transparent;
        min-height: auto;
        padding: 0;
    }
    
    /* Mobile: Show all 8 stages as vertical timeline */
    .wcp-stage-grid {
        display: flex;
        flex-direction: column;
        gap: 0;
        width: 100%;
        position: relative;
    }
    
    /* Create vertical timeline line */
    .wcp-stage-grid::before {
        content: '';
        position: absolute;
        left: 12px;
        top: 20px;
        bottom: 20px;
        width: 3px;
        background: #E5E7EB;
        z-index: 0;
    }
    
    /* Override: Show ALL stage columns on mobile */
    .wcp-stage-column {
        display: flex !important;
        flex-direction: column;
        padding: 12px 0 12px 44px;
        width: 100%;
        position: relative;
        min-height: 50px;
    }
    
    /* Stage indicator dot - default (pending) */
    .wcp-stage-column::before {
        content: '';
        position: absolute;
        left: 0;
        top: 12px;
        width: 28px;
        height: 28px;
        border-radius: 50%;
        background: #E5E7EB;
        border: 4px solid #F9FAFB;
        flex-shrink: 0;
        z-index: 2;
        box-shadow: 0 0 0 1px #D1D5DB;
    }
    
    /* Completed stage - filled blue dot */
    .wcp-stage-column.wcp-stage-completed::before {
        background: var(--wcp-fill-color);
        box-shadow: 0 0 0 1px var(--wcp-fill-color);
    }
    
    /* In progress stage - blue ring with white center */
    .wcp-stage-column.wcp-stage-in-progress::before {
        background: #ffffff;
        border: 4px solid var(--wcp-fill-color);
        box-shadow: 0 0 0 1px var(--wcp-fill-color), 0 0 8px rgba(94, 167, 191, 0.3);
    }
    
    /* Pending stage - gray dot */
    .wcp-stage-column.wcp-stage-pending::before {
        background: #F3F4F6;
        border: 4px solid #F9FAFB;
        box-shadow: 0 0 0 1px #D1D5DB;
    }
    
    /* Stage wrapper */
    .wcp-stage-column-wrapper {
        display: flex;
        flex-direction: column;
        flex: 1;
    }
    
    /* Stage label text */
    .wcp-stage-label-text {
        font-size: 14px;
        font-weight: 500;
        color: #9CA3AF;
        margin-bottom: 8px;
        display: block;
        line-height: 1.3;
    }
    
    /* Completed stage label - dark */
    .wcp-stage-column.wcp-stage-completed .wcp-stage-label-text {
        color: #1F2937;
        font-weight: 600;
    }
    
    /* In progress stage label - blue and bold */
    .wcp-stage-column.wcp-stage-in-progress .wcp-stage-label-text {
        color: var(--wcp-fill-color);
        font-weight: 700;
    }
    
    /* Add "In Progress" indicator */
    .wcp-stage-column.wcp-stage-in-progress .wcp-stage-label-text::after {
        content: ' (진행 중)';
        font-size: 11px;
        font-weight: 500;
        color: var(--wcp-fill-color);
        opacity: 0.8;
    }
    
    /* Pending stage label - light gray */
    .wcp-stage-column.wcp-stage-pending .wcp-stage-label-text {
        color: #D1D5DB;
        font-weight: 400;
    }
    
    /* Visual emphasis for in-progress stage */
    .wcp-stage-column.wcp-stage-in-progress {
        background: rgba(94, 167, 191, 0.08);
        padding-left: 48px;
        margin-left: -4px;
        padding-right: 4px;
        border-radius: 4px;
    }
    
    /* Completed stages - slightly bolder */
    .wcp-stage-column.wcp-stage-completed {
        opacity: 1;
    }
    
    /* Add checkmark to completed stages */
    .wcp-stage-column.wcp-stage-completed .wcp-stage-label-text::before {
        content: '✓ ';
        font-size: 13px;
        color: var(--wcp-fill-color);
        font-weight: 700;
        margin-right: 2px;
    }
    
    /* Fade out pending stages */
    .wcp-stage-column.wcp-stage-pending {
        opacity: 0.5;
    }
    
    /* Desktop: Hide the mobile stage label text */
    @media screen and (min-width: 769px) {
        .wcp-stage-label-text {
            display: none;
        }
    }
    
    /* Stage Track - Show tags inline */
    .wcp-stage-track {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
        padding: 0;
        position: relative;
    }
    
    /* Mobile Stage Item - Compact Pill */
    .wcp-stage-arrow {
        position: relative;
        height: 32px;
        min-width: auto;
        background: var(--color, #F2B28C);
        border: 2px solid #2E4A76;
        border-radius: 4px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
        font-size: 12px;
        color: #111111;
        padding: 0 10px;
        clip-path: none;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex-shrink: 0;
    }
    
    .wcp-stage-arrow--main {
        --h: 32px;
        font-size: 12px;
    }
    
    .wcp-stage-arrow--badge {
        --h: 28px;
        font-size: 11px;
    }
    
    /* Hide connectors on mobile */
    .wcp-stage-connector {
        display: none;
    }
    
    /* Mobile Status Indicator */
    .wcp-pipeline-row::after {
        content: attr(data-status);
        display: block;
        padding: 10px 16px;
        background: #F3F4F6;
        font-size: 12px;
        color: var(--wcp-muted-text);
        text-transform: capitalize;
        border-top: 1px solid #E5E7EB;
        font-weight: 500;
    }
    
    .wcp-pipeline-row[data-status="completed"]::after {
        background: #D1FAE5;
        color: #065F46;
        content: '✓ Completed';
    }
    
    .wcp-pipeline-row[data-status="active"]::after {
        background: #DBEAFE;
        color: #1E40AF;
        content: '● Active';
    }
    
    .wcp-pipeline-row[data-status="paused"]::after {
        background: #FEF3C7;
        color: #92400E;
        content: '⏸ Paused';
    }
}

@media screen and (max-width: 480px) {
    .wcp-pipeline-container {
        padding: 16px 12px;
    }
    
    .wcp-section-title {
        font-size: 20px;
    }
    
    .wcp-section-subtitle {
        font-size: 13px;
    }
    
    .wcp-pipeline-row {
        margin-bottom: 16px;
        border-radius: 6px;
    }
    
    .wcp-program-info {
        padding: 14px;
    }
    
    .wcp-program-code {
        font-size: 15px;
    }
    
    .wcp-program-description {
        font-size: 12px;
    }
    
    .wcp-progress-wrapper {
        padding: 12px 14px;
    }
    
    .wcp-stage-grid::before {
        left: 10px;
        top: 16px;
        bottom: 16px;
        width: 2px;
    }
    
    .wcp-stage-column {
        padding: 10px 0 10px 38px;
        min-height: 45px;
    }
    
    .wcp-stage-column.wcp-stage-in-progress {
        padding-left: 42px;
        margin-left: -4px;
        padding-right: 4px;
    }
    
    .wcp-stage-column::before {
        width: 24px;
        height: 24px;
        left: -2px;
        top: 10px;
        border-width: 3px;
    }
    
    .wcp-stage-label-text {
        font-size: 13px;
        margin-bottom: 6px;
    }
    
    .wcp-stage-column.wcp-stage-in-progress .wcp-stage-label-text::after {
        font-size: 10px;
    }
    
    .wcp-stage-track {
        gap: 5px;
    }
    
    .wcp-stage-arrow {
        height: 30px;
        font-size: 11px;
        padding: 0 8px;
    }
    
    .wcp-stage-arrow--main {
        --h: 30px;
        font-size: 11px;
    }
    
    .wcp-stage-arrow--badge {
        --h: 26px;
        font-size: 10px;
    }
    
    .wcp-pipeline-row::after {
        padding: 8px 14px;
        font-size: 11px;
    }
}

/* Print Styles */
@media print {
    .wcp-pipeline-container {
        background: white;
    }
    
    .wcp-progress-bar {
        transition: none;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
    
    .wcp-progress-arrow {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
    
    .wcp-program-info {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}

/* Accessibility */
.wcp-pipeline-row:focus-within {
    outline: 2px solid var(--wcp-fill-color);
    outline-offset: 2px;
}

/* Animation Loading State */
.wcp-pipeline-row.loading .wcp-progress-bar {
    width: 0 !important;
}

/* Status indicators */
.wcp-pipeline-row[data-status="paused"] .wcp-progress-bar {
    opacity: 0.6;
}

.wcp-pipeline-row[data-status="completed"] .wcp-progress-bar {
    background: #10B981;
}

.wcp-pipeline-row[data-status="completed"] .wcp-progress-arrow {
    background: #10B981;
}
