/* Program Explorer CSS - Redesigned UI */
:root {
    --primary-blue: #0077B6;
    --secondary-teal: #20B2AA;
    --dentist-blue: #2193b0;
    --dentist-light-blue: #6dd5ed;
    --dentist-orange: #ff7e5f;
    --text-dark: #2d3748;
    --text-medium: #4a5568;
    --text-light: #718096;
    --bg-white: #ffffff;
    --bg-light: #f7fafc;
    --bg-gray: #edf2f7;
    --border-light: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --gradient-blue: linear-gradient(135deg, #2193b0 0%, #6dd5ed 100%);
    --transition-normal: all 0.3s ease;
    --scale-factor: 0.8; /* 20% smaller */
}

/* ===== Minimal Page Header (matches Personal Statements / Dashboard style) ===== */
.explorer-page-header {
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f2ff 50%, #ddeeff 100%);
    padding: 2rem 2rem 1.5rem;
    position: relative;
    overflow: hidden;
    margin-bottom: 1.5rem;
    width: 100%;
}

/* Subtle top accent line */
.explorer-page-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(0, 119, 182, 0.3) 20%,
        rgba(0, 119, 182, 0.5) 50%,
        rgba(0, 119, 182, 0.3) 80%,
        transparent 100%
    );
}

.explorer-header-content {
    max-width: 1400px;
    margin: 0 auto;
    text-align: center;
}

.explorer-header-title {
    font-size: 1.75rem;
    font-weight: 300;
    letter-spacing: -0.02em;
    color: #1E2A3A;
    margin: 0 0 0.4rem;
    line-height: 1.2;
}

.explorer-header-subtitle {
    font-size: 0.9rem;
    color: #546E7A;
    font-weight: 400;
    margin: 0 0 1rem;
    line-height: 1.5;
}

.explorer-header-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-stat {
    font-size: 0.85rem;
    color: #546E7A;
    font-weight: 400;
}

.header-stat strong {
    font-weight: 700;
    color: #0077B6;
}

.header-stat-divider {
    width: 1px;
    height: 14px;
    background: #CBD5E0;
}

/* Responsive */
@media (max-width: 768px) {
    .explorer-page-header {
        padding: 1.5rem 1.25rem 1.25rem;
    }

    .explorer-header-title {
        font-size: 1.4rem;
    }

    .explorer-header-subtitle {
        font-size: 0.8rem;
    }

    .explorer-header-stats {
        gap: 0.75rem;
    }

    .header-stat {
        font-size: 0.78rem;
    }
}

@media (max-width: 480px) {
    .explorer-header-title {
        font-size: 1.2rem;
    }

    .explorer-header-stats {
        flex-direction: column;
        gap: 0.25rem;
    }

    .header-stat-divider {
        display: none;
    }
}



.program-explorer-wrapper {
    display: flex;
    width: 100%;
    flex-wrap: nowrap;
    gap: calc(1.5rem * var(--scale-factor));
    margin-bottom: calc(2rem * var(--scale-factor));
}

/* Filter sidebar */
.filter-sidebar {
    width: calc(320px * var(--scale-factor));
    flex-shrink: 0;
    position: sticky;
    top: calc(95px * var(--scale-factor)); /* Account for navbar height */
    align-self: flex-start;
    height: calc(100vh - 100px);
    overflow-y: auto;
    padding-right: calc(1rem * var(--scale-factor));
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.filter-sidebar::-webkit-scrollbar {
    width: 4px;
}

.filter-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.filter-sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.filter-sidebar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Main content area */
.main-content {
    flex: 1;
    min-width: 0; /* Prevents flex items from overflowing */
}

/* ===== Card Containers ===== */
.dashboard-card {
    background: #ffffff;
    border: 1px solid #e8ecf1;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.2s ease;
}

.dashboard-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Results card — no extra padding, children handle their own */
.results-card {
    padding: 0;
}

/* Favorites wrapper */
.favorites-wrapper {
    width: 100%;
    margin: 0 0 2rem 0;
    padding: 0;
}

/* ===== Card Header (shared by both cards) ===== */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #eef1f5;
    background: #fafbfd;
}

.card-header-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1E2A3A;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.01em;
}

.card-header-title .fav-icon {
    color: #e53e3e;
    font-size: 0.8rem;
}

.program-count {
    font-size: 0.75rem;
    font-weight: 400;
    color: #94a3b8;
    white-space: nowrap;
}

/* Legacy h2 inside dashboard-card (fallback for JS-generated) */
.dashboard-card > h2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #1E2A3A;
    border-bottom: 1px solid #eef1f5;
    background: #fafbfd;
}

.dashboard-card > h2::after {
    display: none;
}

/* Filter sidebar card */
.filter-sidebar .dashboard-card {
    width: 100%;
    height: auto;
}


/* ===== Programs Grid ===== */
.programs-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
}

/* ===== Program Item ===== */
.program-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 16px;
    align-items: center;
    padding: 16px 20px;
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s ease;
    position: relative;
}

.program-item:last-child {
    border-bottom: none;
}

.program-item:hover {
    background: #f8fafc;
}

/* Subtle left accent on hover */
.program-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: #0077B6;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.program-item:hover::before {
    opacity: 1;
}

/* ===== Program Info ===== */
.program-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0; /* allow text truncation */
}

.program-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: #1E2A3A;
    margin: 0;
    line-height: 1.3;
    text-decoration: none;
    transition: color 0.15s ease;
}

a.program-name {
    cursor: pointer;
}

a.program-name:hover {
    color: #0077B6;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
}

a.program-name:visited {
    color: #1E2A3A;
}

.program-location {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: #64748b;
}

.program-location i {
    color: #0077B6;
    font-size: 0.7rem;
}

.program-details {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.program-duration {
    font-size: 0.8rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== Badges ===== */
.specialty-badge,
.duration-badge,
.foreign-badge,
.stipend-badge,
.positions-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
    background: #f1f5f9;
    color: #475569;
}

.specialty-badge {
    background: #f0f7ff;
    color: #0077B6;
}

/* ===== Competitiveness Score (compact pill) ===== */
.competitiveness-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
}

.competitiveness-container .score-number {
    font-size: 0.8rem;
    font-weight: 700;
    color: #475569;
    min-width: 22px;
    text-align: right;
    line-height: 1;
}

.competitiveness-container .score-bar {
    width: 56px;
    height: 6px;
    background: #eef1f5;
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}

.competitiveness-container .score-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* Legacy wrappers (kept for competitiveness-api.js compatibility) */
.competitiveness-score {
    display: contents;
}

.score-info {
    display: contents;
}

.score-title {
    display: none;
}

.score-details {
    display: contents;
}

/* ===== Program Actions ===== */
.program-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.heart-btn {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #d1d5db;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.heart-btn:hover {
    color: #fb7185;
    background: rgba(251, 113, 133, 0.08);
    transform: scale(1.15);
}

.heart-btn.active {
    color: #ef4444;
    background: transparent;
}

.heart-btn.active:hover {
    color: #dc2626;
    background: rgba(239, 68, 68, 0.06);
}

/* ===== Pagination ===== */
.carousel-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-top: 1px solid #eef1f5;
    background: #fafbfd;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
}

.page-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e2e8f0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.page-indicator:hover {
    background: #cbd5e1;
}

.page-indicator.active {
    background: #0077B6;
    transform: scale(1.25);
}

.carousel-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #ffffff;
    color: #0077B6;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.75rem;
}

.carousel-btn:hover:not(:disabled) {
    background: #0077B6;
    color: #ffffff;
    border-color: #0077B6;
}

.carousel-btn:disabled {
    color: #cbd5e1;
    cursor: not-allowed;
    border-color: #eef1f5;
}

/* ===== Favorites Section ===== */
#favorites-list {
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Favorites use same program-item row style */
.favorites-wrapper .program-item {
    grid-template-columns: 1fr auto;
    border-radius: 0;
    box-shadow: none;
    border: none;
    border-bottom: 1px solid #f1f5f9;
}

.favorites-wrapper .program-item:last-child {
    border-bottom: none;
}

.favorite-apply-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 7px 14px;
    background: #0077B6;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.favorite-apply-btn:hover {
    background: #005f8f;
    box-shadow: 0 2px 8px rgba(0, 119, 182, 0.25);
}

.favorite-apply-btn.active {
    background: #16a34a;
}

.remove-favorite {
    background: none;
    border: 1px solid #e2e8f0;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.remove-favorite:hover {
    color: #ef4444;
    border-color: #fecaca;
    background: #fef2f2;
}

.empty-favorites {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
    color: #94a3b8;
}

.empty-favorites i {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    color: #e2e8f0;
}

.empty-favorites p {
    margin: 0.25rem 0;
    max-width: 300px;
    font-size: 0.8rem;
    line-height: 1.5;
}

/* Mobile toggle for filter visibility */
.mobile-filter-toggle {
    display: none;
    width: 100%;
    padding: 10px 16px;
    margin: 0 0 12px 0;
    background: #ffffff;
    color: #0077B6;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.8125rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.mobile-filter-toggle:hover {
    border-color: #0077B6;
    background: #f0f7ff;
}

/* Filter backdrop for mobile */
.filter-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.filter-backdrop.show {
    display: block;
    opacity: 1;
}

/* Loading States */
.loading, 
.error, 
.no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--text-light);
}

.loading i,
.error i,
.no-results i {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.error {
    color: #e53e3e;
}


/* ===================================================================
   Responsive Breakpoints
   =================================================================== */

/* Large screens — sidebar narrower */
@media (max-width: 1200px) {
    .filter-sidebar {
        width: 260px;
    }
}

@media (max-width: 1024px) {
    .filter-sidebar {
        width: 240px;
    }
}

/* Tablets — sidebar becomes mobile drawer */
@media (max-width: 900px) {
    .program-explorer-wrapper {
        display: block;
    }
    
    .filter-sidebar {
        position: fixed;
        left: -300px;
        top: 0;
        bottom: 0;
        width: 280px;
        height: 100vh;
        overflow-y: auto;
        padding: 1rem;
        margin: 0;
        background: white;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: none;
    }
    
    .filter-sidebar.show {
        left: 0;
        box-shadow: 2px 0 15px rgba(0, 0, 0, 0.1);
    }
    
    .mobile-filter-toggle {
        display: flex;
    }
    
    .main-content {
        padding: 0;
        width: 100%;
    }
}

/* Small tablets / landscape phones */
@media (max-width: 768px) {
    /* Card header stacks on small screens */
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        padding: 12px 16px;
    }

    .program-count {
        font-size: 0.7rem;
    }

    /* Program items: info takes full row, score + heart sit below */
    .program-item {
        grid-template-columns: 1fr auto auto;
        gap: 8px 12px;
        padding: 14px 16px;
    }

    .program-info {
        grid-column: 1 / -1;
    }

    /* Favorites also stack */
    .favorites-wrapper .program-item {
        grid-template-columns: 1fr;
    }
    
    .favorites-wrapper .program-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    /* Pagination tighter */
    .carousel-controls {
        padding: 12px 16px;
        gap: 8px;
    }

    .carousel-btn {
        width: 28px;
        height: 28px;
        font-size: 0.65rem;
    }
}

/* Portrait phones */
@media (max-width: 576px) {
    .program-item {
        padding: 12px 14px;
    }

    .program-name {
        font-size: 0.8rem;
    }

    .program-location {
        font-size: 0.75rem;
    }

    .program-details {
        gap: 4px;
    }

    .specialty-badge,
    .duration-badge,
    .foreign-badge,
    .stipend-badge,
    .positions-badge {
        font-size: 0.65rem;
        padding: 2px 8px;
    }

    .favorite-apply-btn {
        padding: 6px 10px;
        font-size: 0.7rem;
    }

    .heart-btn {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .remove-favorite {
        width: 30px;
        height: 30px;
        font-size: 0.7rem;
    }

    .competitiveness-container .score-number {
        font-size: 0.75rem;
    }
    
    .competitiveness-container .score-bar {
        width: 40px;
        height: 5px;
    }
}

/* Very small phones */
@media (max-width: 400px) {
    .card-header {
        padding: 10px 12px;
    }

    .card-header-title {
        font-size: 0.8rem;
    }

    .program-item {
        padding: 10px 12px;
    }

    .program-actions {
        gap: 6px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) {
    .heart-btn:active,
    .favorite-apply-btn:active,
    .remove-favorite:active,
    .carousel-btn:active:not(:disabled) {
        transform: scale(0.95);
    }
}