/* Programmes & Exchange Section Styles */
.programmes-exchange-section {
    background: #f8f9fa;
    padding: 4rem 0;
}

/* Programmes Section */
.programmes-overview {
    margin: 0 auto 4rem auto;
}

.programmes-header {
    text-align: center;
    margin-bottom: 2rem;
}

.programmes-title {
    font-size: 3rem;
    font-weight: normal;
    color: #666;
    margin: 0 0 0.5rem 0;
}

.programmes-title-english {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--cuhk-classic-purple);
    margin: 0 0 2rem 0;
}

.programmes-intro {
    display: grid;
    gap: 0.45rem;
    margin: 0 0 1.75rem 0;
    text-align: left;
    max-width: 980px;
}

.intro-chinese {
    font-weight: normal;
    color: #666;
    margin: 0;
    line-height: 1.5;
}

.intro-subtitle {
    font-weight: normal;
    color: #666;
    margin: -0.15rem 0 0 0;
    line-height: 1.5;
}

.intro-english {
    font-size: 1rem;
    font-weight: normal;
    text-align: left;
    line-height: inherit;
    margin: 0;
    white-space: nowrap;
}

.programmes-intro .intro-chinese + .intro-english {
    margin-top: 0.55rem;
}

/* Medicine Highlight */
.medicine-highlight {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
    align-items: stretch;
    gap: 1rem;
    background: #ffffff;
    border: 1px solid var(--dewy-purple);
    border-radius: 7px;
    padding: 1.25rem;
    margin: 2rem auto 3rem auto;
    box-shadow: none;
}

.medicine-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.medicine-icon {
    background: linear-gradient(135deg, var(--cuhk-classic-purple), var(--cuhk-classic-purple));
    width: 64px;
    height: 64px;
    margin-left: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.6rem;
    flex-shrink: 0;
}

.medicine-info {
    min-width: 0;
}

.medicine-title {
    font-size: 1.2rem;
    font-weight: normal;
    color: var(--cuhk-black);
    margin: 0.4rem 0 0 0;
    line-height: 1.25;
}

.medicine-title-english {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--cuhk-classic-purple);
    margin: 0;
    line-height: 1.2;
}

.medicine-subtitle-english,
.medicine-subtitle-chinese {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--cuhk-classic-purple);
    margin: 0.25rem 0 0 0;
}

.medicine-right {
    display: flex;
    align-items: stretch;
    text-align: left;
    margin-right: 0;
}

.medicine-achievement {
    width: 100%;
    padding: 1rem 1.25rem;
    background: rgba(118, 67, 147, 0.06);
    border: 1px solid rgba(118, 67, 147, 0.16);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.achievement-line {
    font-size: 0.95rem;
    font-weight: normal;
    color: var(--cuhk-black);
    margin: 0.25rem 0 0 0;
    line-height: 1.35;
}

.achievement-number-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin: 0.35rem 0;
}

.achievement-number {
    font-size: 3.4rem;
    font-weight: 700;
    color: var(--cuhk-classic-purple);
    line-height: 0.95;
}

.achievement-unit {
    color: var(--cuhk-classic-purple);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.2;
}

.achievement-english {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--cuhk-black);
    line-height: 1.35;
}

/* Top Programmes */
.top-programmes {
    margin: 3rem auto;
}

.top-programmes-title {
    font-size: 1rem;
    font-weight: normal;
    color: #666;
    margin-bottom: 1rem;
    text-align: left;
}

.programmes-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 1rem;
    margin: 0 auto 2rem auto;
}

.programmes-column {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.programme-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    min-height: 92px;
    background: white;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
    transition: all 0.3s ease;
    position: relative;
}

.programme-item:hover {
    border-color: var(--cuhk-classic-purple);
    box-shadow: 0 2px 8px rgba(118, 67, 147, 0.1);
}

.programme-item:hover .delete-btn {
    opacity: 1;
}

.programme-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--cuhk-classic-purple), var(--cuhk-classic-purple));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.programme-text {
    flex: 1;
    min-width: 0;
}

.programmes-exchange-section .career-section {
    margin: 0 auto 3rem auto;
}

.programmes-exchange-section .career-content {
    padding: 2rem;
    grid-template-columns: minmax(300px, 0.95fr) minmax(0, 1.05fr);
    gap: 2rem;
    border-color: var(--cuhk-classic-purple);
}

.programmes-exchange-section .section-title .chinese,
.programmes-exchange-section .subsection-title,
.programmes-exchange-section .subsection-title .chinese,
.programmes-exchange-section .section-last-updated-date,
.programmes-exchange-section .section-print-btn:hover,
.programmes-exchange-section .section-print-btn:focus {
    color: var(--cuhk-classic-purple);
}

.programmes-exchange-section .section-last-updated,
.programmes-exchange-section .exchange-programs-section,
.programmes-exchange-section .white-card {
    border-color: var(--cuhk-classic-purple);
}

.programmes-exchange-section .section-print-btn:hover,
.programmes-exchange-section .section-print-btn:focus,
.programmes-exchange-section .add-career-item,
.programmes-exchange-section .add-career-item:hover {
    background: rgba(118, 67, 147, 0.05);
}

.programmes-exchange-section .add-career-item {
    border-color: var(--cuhk-classic-purple);
}

.programmes-exchange-section .add-career-item:hover {
    border-color: var(--cuhk-classic-purple);
}

.programmes-exchange-section .add-career-item .add-icon,
.programmes-exchange-section .add-career-item .add-text {
    color: var(--cuhk-classic-purple);
}

.programme-chinese {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.3;
    margin-bottom: 0.25rem;
}

.programme-english {
    font-weight: 600;
    color: #333;
    line-height: 1.3;
    margin-bottom: 0.25rem;
}

.programme-english[contenteditable="true"]:hover,
.programme-chinese[contenteditable="true"]:hover {
    outline: 1px dashed var(--cuhk-classic-purple);
    outline-offset: 2px;
    cursor: text;
}

.programme-english[contenteditable="true"]:focus,
.programme-chinese[contenteditable="true"]:focus {
    outline: 2px solid var(--cuhk-classic-purple);
    outline-offset: 2px;
    background: rgba(118, 67, 147, 0.05);
    border-radius: 3px;
}

.delete-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: #dc3545;
    border: 2px solid white;
    border-radius: 50%;
    color: white;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 10;
}

.delete-btn:hover {
    background: #c82333;
    transform: scale(1.1);
}

.add-programme-section {
    text-align: center;
    margin-top: 2rem;
}

.add-btn {
    background: linear-gradient(135deg, var(--cuhk-classic-purple), var(--cuhk-classic-purple));
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(118, 67, 147, 0.3);
}

.add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(118, 67, 147, 0.4);
}

/* Zhizhen Section */
.zhizhen-section {
    background: white;
    background-image:
        linear-gradient(rgba(118, 67, 147, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(118, 67, 147, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
    border-radius: 6px;
    padding: 2rem;
    margin: 2rem 0;
}

.zhizhen-text {
    font-size: 1rem;
    line-height: 1.6;
    color: #666;
    margin-bottom: 1rem;
}

.zhizhen-english {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.5;
}

/* Exchange and Enrichment Section */
.exchange-enrichment {
    margin: 3rem auto 2rem auto;
}

.exchange-enrichment>.subsection-title {
    margin-bottom: 2rem;
}

.programmes-exchange-section .exchange-enrichment .student-as-of,
.programmes-exchange-section .exchange-enrichment .student-as-of [data-field],
.programmes-exchange-section .exchange-enrichment .student-as-of .as-of-date-chinese {
    color: #6C7074;
    font-size: 12px;
    opacity: 1;
}

.exchange-card-notes {
    margin-top: -1rem;
    color: #6C7074;
    font-size: 12px;
}

.exchange-card-notes .student-as-of,
.exchange-source-note {
    color: #6C7074;
    font-size: 12px;
    margin-top: 0;
    opacity: 1;
}

.exchange-source-note p {
    color: #6C7074;
    font-size: 12px;
}

.exchange-header {
    text-align: center;
    margin-bottom: 3rem;
}

.exchange-title {
    font-size: 3rem;
    font-weight: normal;
    color: #666;
    margin: 0 0 0.5rem 0;
}

.exchange-title-english {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--cuhk-classic-purple);
    margin: 0;
}

/* Purple Card Base Style */
.purple-card {
    background: linear-gradient(135deg, var(--cuhk-classic-purple), var(--cuhk-classic-purple));
    color: white;
    border-radius: 6px;
    padding: 2rem;
    box-shadow: 0 8px 24px rgba(118, 67, 147, 0.3);
}

/* White Card Style with Royal Gold Numbers */
.white-card {
    background: white;
    color: #333;
    border-radius: 7px;
    /* match global-stat */
    padding: 1rem 1.5rem;
    /* reduced top/bottom padding */
    box-shadow: none;
    border: 1px solid var(--cuhk-classic-purple);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.white-card:hover {
    transform: translateY(-5px);
    /* match global-stat */
    box-shadow: 0 10px 25px rgba(118, 67, 147, 0.15);
    /* match global-stat */
    border-color: var(--cuhk-classic-purple);
}

.exchange-enrichment .white-card,
.exchange-enrichment .white-card:hover {
    transform: none;
    box-shadow: none;
    transition: none;
    border-color: var(--cuhk-classic-purple);
}

.white-card .card-big-number,
.white-card .nonlocal-big-number,
.white-card .scholarships-big-number,
.white-card .amount-number {
    color: var(--cuhk-royal-gold, #84754E);
}

.white-card .card-yearly-label,
.white-card .nonlocal-label,
.white-card .scholarships-label {
    color: #666;
}

.white-card .card-description,
.white-card .card-subdescription,
.white-card .description-english,
.white-card .description-chinese,
.white-card .stat-description,
.white-card .card-footer-text,
.white-card .nonlocal-description .description-english,
.white-card .nonlocal-description .description-chinese,
.white-card .scholarships-year,
.white-card .scholarships-description-line,
.white-card .scholarships-english-desc,
.white-card .total-amount,
.white-card .total-english,
.white-card .amount-text,
.white-card .amount-currency,
.white-card .scholarships-unit {
    color: #666;
}

.white-card .scholarships-divider {
    background: #e0e0e0;
}

/* Exchange Programs Section */
.exchange-programs-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #ffffff;
    border: 1px solid var(--cuhk-classic-purple);
    border-radius: 7px;
}

.exchange-programs-section>.subsection-title {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    /* Use margin on ::before instead of gap so we can reuse in calc() */
}

.exchange-programs-section>.subsection-title::before {
    content: '';
    display: inline-block;
    width: var(--bullet-size);
    height: var(--bullet-size);
    background: linear-gradient(135deg, var(--cuhk-classic-purple), var(--cuhk-classic-purple));
    border-radius: 50%;
    flex-shrink: 0;
    margin-right: var(--bullet-gap);
}

.exchange-programs-section .exchange-description {
    margin-bottom: 1.25rem;
    /* Align description start with the text after bullet */
    padding-left: calc(var(--bullet-size) + var(--bullet-gap));
}

.exchange-description .description-english {
    font-size: 0.95rem;
    line-height: 1.5;
    color: #333;
    margin-bottom: 0.25rem;
}

.exchange-description .description-chinese {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #666;
}

.exchange-footnotes {
    margin-top: 0.75rem;
    padding-left: calc(var(--bullet-size) + var(--bullet-gap));
}

.exchange-footnotes p {
    font-size: 0.78rem;
    color: #6D6E71;
    line-height: 1.5;
    margin: 0 0 0.2rem 0;
}

.exchange-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    max-width: 760px;
    margin: 0 auto;
}

.exchange-cards-grid-single {
    max-width: none;
}

.exchange-cards-grid-double {
    max-width: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.exchange-card {
    position: relative;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    text-align: center;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
}

.exchange-cards-grid-single .exchange-card {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(170px, 0.38fr) minmax(0, 1fr);
    column-gap: 1.5rem;
    row-gap: 0.35rem;
    align-items: center;
    justify-content: stretch;
    text-align: left;
    padding: 1.35rem 1.5rem;
}

.exchange-cards-grid-double .exchange-card {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(120px, 0.42fr) minmax(0, 0.58fr);
    column-gap: 1.25rem;
    row-gap: 0.35rem;
    align-items: center;
    justify-content: stretch;
    text-align: left;
    padding: 1.35rem 1.5rem;
}

.exchange-cards-grid-single .card-number-row,
.exchange-cards-grid-double .card-number-row {
    grid-column: 1;
    grid-row: 1 / span 2;
    justify-content: flex-start;
    margin: 0;
}

.exchange-cards-grid-single .card-prefix-gold,
.exchange-cards-grid-double .card-prefix-gold {
    font-size: 1.35rem;
}

.exchange-cards-grid-single .exchange-card .card-big-number,
.exchange-cards-grid-double .exchange-card .card-big-number {
    font-size: clamp(2.6rem, 5vw, 3.6rem);
}

.exchange-cards-grid-single .exchange-card .card-description-english,
.exchange-cards-grid-single .exchange-card .card-description-chinese,
.exchange-cards-grid-double .exchange-card .card-description-english,
.exchange-cards-grid-double .exchange-card .card-description-chinese {
    text-align: left;
}

.exchange-cards-grid-single .exchange-card .card-description-english,
.exchange-cards-grid-double .exchange-card .card-description-english {
    grid-column: 2;
    grid-row: 1;
    font-size: 1rem;
    font-weight: 600;
    color: #2F3133;
    margin-bottom: 0;
}

.exchange-cards-grid-single .exchange-card .card-description-chinese,
.exchange-cards-grid-double .exchange-card .card-description-chinese {
    grid-column: 2;
    grid-row: 2;
    font-size: 0.9rem;
    color: #666666;
}

.exchange-card .card-prefix {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.card-number-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    margin-bottom: 0.75rem;
}

.card-prefix-gold {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--cuhk-royal-gold, #84754E);
}

.card-suffix-gold {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--cuhk-royal-gold, #84754E);
}

.exchange-card .card-big-number {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
}

.exchange-card .card-description-english {
    font-size: 0.9rem;
    color: #333;
    margin-bottom: 0.25rem;
    line-height: 1.4;
}

.exchange-card .card-description-chinese {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.4;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.card-yearly-label {
    font-size: 1rem;
    opacity: 0.9;
    margin: 0;
}

.card-big-number {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
    margin: 0;
}

.card-description {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 0.25rem;
    flex-basis: 100%;
}

.card-subdescription {
    font-size: 0.85rem;
    opacity: 0.8;
    margin-bottom: 2rem;
    flex-basis: 100%;
}

.card-stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.card-stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}

.card-stat>div:first-child {
    font-size: 0.9rem;
    opacity: 0.9;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
    display: block;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

/* Make number and unit appear on the same line */
.card-stat .amount-number {
    display: inline-block !important;
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

.stat-unit {
    display: inline-block !important;
    font-size: 1rem;
    opacity: 0.9;
    margin-left: 0.25rem;
    vertical-align: baseline;
}

.stat-description {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-top: 0.5rem;
    display: block;
}

.stat-description {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-top: 0.5rem;
}

.card-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 1rem;
}

.card-footer-text {
    font-size: 0.85rem;
    opacity: 0.9;
    text-align: center;
}

/* Card divider - used in scholarships section */
.card-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 1.5rem 0;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .programmes-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .exchange-programs-section,
    .nonlocal-students-section,
    .scholarships-section {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .exchange-cards-grid {
        grid-template-columns: 1fr;
    }

    .exchange-cards-grid-single .exchange-card,
    .exchange-cards-grid-double .exchange-card {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .exchange-cards-grid-single .card-number-row,
    .exchange-cards-grid-single .exchange-card .card-description-english,
    .exchange-cards-grid-single .exchange-card .card-description-chinese,
    .exchange-cards-grid-double .card-number-row,
    .exchange-cards-grid-double .exchange-card .card-description-english,
    .exchange-cards-grid-double .exchange-card .card-description-chinese {
        grid-column: 1;
        grid-row: auto;
        justify-content: center;
        text-align: center;
    }

    .medicine-highlight {
        grid-template-columns: 1fr;
        text-align: left;
    }

    .medicine-right {
        text-align: left;
        margin-right: 0;
    }
}

@media (max-width: 768px) {
    .intro-english {
        white-space: normal;
    }

    .programmes-title {
        font-size: 2.5rem;
    }

    .programmes-title-english {
        font-size: 2rem;
    }

    .exchange-title {
        font-size: 2.5rem;
    }

    .exchange-title-english {
        font-size: 2rem;
    }

    .programmes-exchange-section .career-content {
        grid-template-columns: 1fr;
        padding: 1.5rem;
    }

    /* Fix text wrapping for subsection titles */
    .exchange-programs-section>.subsection-title {
        flex-wrap: wrap !important;
    }

    .exchange-programs-section>.subsection-title .chinese {
        flex-basis: 100%;
        width: 100%;
        display: block;
        margin-left: calc(var(--bullet-size) + var(--bullet-gap));
        margin-top: 0.2rem;
    }

    .card-stats-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .programmes-exchange-section .career-legend-percentage {
        color: var(--cuhk-classic-purple);
    }

    .nonlocal-number-section {
        flex-direction: column;
        gap: 0.25rem;
    }

    /* Hide medicine icon on tablet */
    .medicine-icon {
        display: none;
    }

    .total-amount {
        flex-direction: column;
        gap: 0.25rem;
        align-items: center;
    }

    .medicine-left {
        margin-bottom: 0;
    }

    .medicine-right {
        text-align: left;
    }
}

@media (max-width: 480px) {
    .programmes-title {
        font-size: 2rem;
    }

    .programmes-title-english {
        font-size: 1.5rem;
    }

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

    .exchange-title-english {
        font-size: 1.5rem;
    }

    /* Hide medicine icon on phone */
    .medicine-icon {
        display: none;
    }

    .medicine-left {
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 1rem;
    }

    .medicine-highlight {
        padding: 1rem;
    }

    .achievement-number {
        font-size: 2.8rem;
    }

    .medicine-title-english {
        font-size: 1.2rem;
    }

    .medicine-title {
        font-size: 1.1rem;
    }

    .achievement-number {
        font-size: 2.5rem;
    }

    .card-big-number {
        font-size: 3rem;
    }

    .nonlocal-big-number {
        font-size: 3rem;
    }

    .scholarships-big-number {
        font-size: 2.5rem;
    }

    .amount-number {
        font-size: 2rem;
    }

    .purple-card {
        padding: 1.5rem;
    }

    .purple-card {
        padding: 1.5rem;
        border-radius: 6px;
        /* match lab-card */
        box-shadow: none;
        border: 1px solid var(--cuhk-classic-purple);
        transition: all 0.3s ease;
        /* match lab-card */
    }

    .purple-card:hover {
        transform: translateY(-3px);
        /* match lab-card */
        box-shadow: 0 8px 20px rgba(118, 67, 147, 0.15);
        /* match lab-card */
        border-color: var(--cuhk-classic-purple);
    }

    .programme-item {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }

    .exchange-section-title-english {
        font-size: 1.1rem;
    }

    .scholarships-title-english {
        font-size: 1.1rem;
    }
}