/* ===== BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: #f5f5f5;
    font-family: 'Roboto', Helvetica, Arial, sans-serif;
}

.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px 5%;
}

/* ===== HEADER STYLES ===== */
header {
    color: #333;
    padding: 20px 5%;
    text-align: left;
}

header h2 {
    font-family: 'Roboto', Helvetica, Arial, sans-serif;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 10px;
    margin-top: 20px;
}

header p {
    font-family: 'Roboto', Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    padding-bottom: 10px;
    padding-right: 10%;
}

header a {
    text-decoration: none;
    font-weight: 600;
    color: #333;
}

h1 {
    margin-bottom: 10px;
}

/* ===== FILTER SYSTEM STYLES ===== */
.desktop-filter-container {
    padding: 0px 0px 20px 0px;
    margin-bottom: 20px;
    border-bottom: 1px solid #ddd;
    display: block;
    background-color: transparent;
}

.filter-title {
    text-align: left;
    margin-bottom: 15px;
    font-size: .875rem;
    font-weight: 600;
    color: #333;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    max-width: 1200px;
    margin: 0 auto;
}

.filter-link {
    display: block;
    text-decoration: none;
    color: #3b3b3b;
    border-radius: 0;
    font-size: 14px;
    text-align: left;
    transition: all 0.2s ease;
    background-color: transparent;
    border-bottom: 1px solid transparent;
}

.filter-link:hover {
    background-color: transparent;
    color: #333;
    border-bottom: 1px solid #333;
}

.filter-link.active {
    background-color: transparent;
    color: #333;
    font-weight: bold;
    border-bottom: 2px solid #f36e21;
}

.mobile-filter-container {
    display: none;
    margin-bottom: 20px;
}

.mobile-filter-select {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    border: 1px solid #ddd;
    border-radius: 0;
    background-color: white;
    cursor: pointer;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin-top: 30px;
}

/* ===== CARD STYLES ===== */
.card {
    background-color: white;
    border-radius: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    border-bottom: 3px solid transparent;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.12);
    border-bottom: 3px solid #F76902;
}

/* Card image container and image */
.card-image-container {
    position: relative;
    width: 100%;
    padding-top: 75%;
    overflow: hidden;
    background-color: #ffffff;
}

.card-image-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.card:hover .card-image-container img {
    transform: scale(1.1);
}

.card-image-container img[src*="placeholder.jpg"] {
    object-fit: contain;
    padding: 10%;
}

.card:hover .card-image-container img[src*="placeholder.jpg"] {
    transform: none;
}

.card-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

/* Card content */
.card-content {
    padding: 16px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    position: relative;
    padding-bottom: 60px; /* Make room for the button */
}

.card-title {
    font-size: 1.25rem;
    margin: 0 0 4px 0;
    color: #222;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.card-description-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0px;
}

.card-description {
    color: #333;
    line-height: 1.5;
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 0;
}

.current-year {
    color: #3b3b3b;
    font-size: 13px;
    text-align: right;
}

.current-year strong {
    font-weight: 700;
}

.program-level-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 2px;
}

.program-level {
    color: #3b3b3b;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.4;
    margin-bottom: 0;
}

.graduation-row {
    margin-bottom: 2px;
}

.expected-grad {
    color: #3b3b3b;
    font-size: 13px;
    text-align: left;
    margin-bottom: 12px;
}

.expected-grad strong {
    font-weight: 700;
}

/* Card metadata */
.card-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 0;
}

.email-item {
    font-size: 13px;
    color: #3b3b3b;
    line-height: 1.5;
    margin-bottom: 4px;
}

.email-item a {
    color: #F76902;
    text-decoration: none;
    font-weight: 400;
}

.interests-item {
    font-size: 13px;
    color: #3b3b3b;
    line-height: 1.5;
    padding-bottom: 10px;
}

.card-meta-item strong {
    font-weight: 700;
}

/* Card link button */
.card-link {
    display: inline-block;
    color: #F76902;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 0;
    border-style: solid;
    border-width: thin;
    border-color: #F76902;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-align: center;
    transition: all 0.2s ease;
    position: absolute;
    bottom: 16px;
    left: 16px;
    right: 16px;
}

.card-link:hover {
    background-color: #F76902;
    color: white;
}

/* ===== STATUS STYLES ===== */
.loading {
    text-align: center;
    padding: 50px;
    font-size: 1.2rem;
    color: #666;
}

#status {
    margin: 20px 0;
    padding: 15px;
    border-radius: 5px;
    text-align: center;
}

.success {
    color: #155724;
}

.error {
    background-color: #f8d7da;
    color: #721c24;
}

/* ===== BUTTONS ===== */
.btn {
    -webkit-border-radius: 0;
    -moz-border-radius: 0;
    border-radius: 0;
    font-family: 'Roboto', Arial;
    color: #ffffff;
    font-size: 13px;
    background: #f36e21;
    padding: 10px 15px 5px 10px;
    text-decoration: none;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    display: inline-block;
    margin-top: 20px;
}

.btn:hover {
    background: #D85A00;
    text-decoration: none;
}

/* ===== IMAGE LOADING STYLES ===== */
.image-loader-container {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: #f5f5f5;
}

.image-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top: 3px solid #F76902;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Lazy loading image states */
.lazy-image {
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.lazy-image.loading {
    opacity: 0.3; /* Slightly visible while loading */
}

.lazy-image.loaded {
    opacity: 1;
}

/* ===== BROWSER-SPECIFIC FIXES ===== */
/* Firefox-specific fixes */
@-moz-document url-prefix() {
    .card-image-container {
        height: 0; /* Force proper aspect ratio in Firefox */
    }
}

/* Microsoft Edge fixes */
@supports (-ms-ime-align: auto) {
    .card-image-container {
        height: 0; /* Force proper aspect ratio in Edge */
    }
}

/* Forced Colors mode support */
@media (forced-colors: active) {
    .card-image-container {
        height: 0; /* Maintain aspect ratio */
        forced-color-adjust: none; /* Preserve visual presentation */
    }
    
    .card-image-container img {
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
    
    /* Ensure buttons remain visible */
    .card-link {
        border: 1px solid CanvasText;
        color: CanvasText;
    }
    
    .btn {
        border: 1px solid CanvasText;
        color: Canvas;
        background: CanvasText;
    }
}

/* ===== RESPONSIVE BREAKPOINTS ===== */
@media (max-width: 1200px) {
    .card-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
    .filter-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .filter-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .desktop-filter-container {
        display: none !important;
    }
    .mobile-filter-container {
        display: block !important;
    }
    .card-grid {
        grid-template-columns: 1fr;
    }
    .card-content {
        padding: 15px;
        padding-bottom: 70px; /* Increase bottom padding in mobile view */
    }
    .interests-item {
        margin-bottom: 10px; /* Add margin below interests for better spacing */
        max-height: none; /* Ensure text isn't artificially constrained */
        overflow: visible; /* Make sure text isn't cut off */
    }
    /* Ensure there's space before the button */
    .card-meta {
        margin-bottom: 14px; /* Add space between meta info and the button */
    }
    
    /* Updated Mobile Filter Dropdown */
    .mobile-filter-select {
        width: 100%;
        padding: 16px; /* Increased from 12px for more height */
        font-size: 1.1rem; /* Increased from 1rem for larger text */
        border: 1px solid #ddd;
        border-radius: 0;
        background-color: white;
        cursor: pointer;
        color: #3b3b3b; /* Same dark grey used elsewhere in the design */
        font-family: 'Roboto', Helvetica, Arial, sans-serif;
        -webkit-appearance: none; /* Removes default styling on iOS */
        -moz-appearance: none;
        appearance: none;
        background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%233b3b3b'><polygon points='0,0 12,0 6,8'/></svg>");
        background-repeat: no-repeat;
        background-position: right 16px center;
        background-size: 12px;
        padding-right: 40px; /* Space for the custom dropdown arrow */
    }
    
    /* Add focus state for better accessibility */
    .mobile-filter-select:focus {
        outline: none;
        border-color: #F76902;
    }
}