/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: linear-gradient(135deg, #0D6E95 0%, #3db4e3 100%);
    min-height: 100vh;
    line-height: 1.6;
    color: #052C3C;
    font-weight: 400;
    position: relative;
}

/* Extended background for elastic scrolling */
body::before {
    content: '';
    position: fixed;
    top: -100vh;
    left: -100vw;
    right: -100vw;
    bottom: -100vh;
    background: linear-gradient(135deg, #0D6E95 0%, #3db4e3 100%);
    z-index: -1;
}

/* Container for responsive layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}



/* Filters section */
filters {
    display: block;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.90), rgba(255, 255, 255, 0.80));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 1.5rem 0;
    /*border-bottom: 1px solid #bdc3c7;*/
    border: 4px solid rgba(255, 255, 255, 0.2);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

filters.hidden {
    transform: translateY(-100%);
}

/* Add top padding to results to compensate for fixed header */
results {
    display: block;
    padding: 2rem 0;
    padding-top: 10rem;
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.logo-section {
    flex-shrink: 0;
}

.filter-logo {
    height: 60px;
    width: auto;
    max-width: 200px;
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    justify-content: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    min-width: 150px;
}

.filter-group label {
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    letter-spacing: 0.005em;
}

.filter-group select {
    padding: 1rem 3rem 1rem 1.25rem;
    border: 2px solid #1E87B1;
    border-radius: 2rem;
    background: transparent;
    color: #1E87B1;
    font-size: 1rem;
    font-weight: 400;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="8" viewBox="0 0 14 8"><path fill="%230D6E95" d="M1 1l6 6 6-6"/></svg>');
    background-repeat: no-repeat;
    background-position: right 1.25rem center;
    background-size: 14px 8px;
    transition: all 0.3s ease;
}

.filter-group select:focus {
    outline: none;
    border-color: #1E87B1;
    box-shadow: 0 0 0 3px rgba(30, 135, 177, 0.3);
}

.btn-primary, .btn-secondary {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 1.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    margin-right: 0.5rem;
    letter-spacing: 0.005em;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

/* Results section */

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.results-header h2 {
    color: #ffffff;
    font-size: 1.8rem;
    margin: 0;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.program-filters {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.program-filters .filter-group {
    display: flex;
    flex-direction: column;
    min-width: 180px;
    gap: 1.5rem;
}

.program-filters select {
    padding: 1rem 3rem 1rem 1.25rem;
    border: 2px solid white;
    border-radius: 2rem;
    background: transparent;
    color: white;
    font-size: 1rem;
    font-weight: 400;
    transition: all 0.3s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="8" viewBox="0 0 14 8"><path fill="white" d="M1 1l6 6 6-6"/></svg>');
    background-repeat: no-repeat;
    background-position: right 1.25rem center;
    background-size: 14px 8px;
}

.program-filters select:focus {
    outline: none;
    border-color: white;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.results-count {
    color: #ffffff;
    font-size: 1rem;
    margin: 1.5rem;
    text-align: left;
}

.item-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
}

.loading-indicator, .no-results {
    text-align: center;
    padding: 2rem;
    color: #ffffff;
}

.loading-indicator p, .no-results p {
    font-size: 1.1rem;
}

/* Template hiding */
template {
    display: none;
}

/* Card styling for items */
.item {
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.90) 0%, rgba(255, 255, 255, 0.80) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 1rem;
    padding: 1.5rem 2rem;
    /*box-shadow: 0 8px 16px rgba(0,0,0,0.2);*/
    /*border: 1px solid #fff;*/
    border: 4px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

.item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* Item title (school name) */
.item-title {
    flex: 1;
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}

.item-title span {
    font-size: 1.2rem;
    font-weight: 700;
    color: #052C3C;
    display: block;
    flex: 1;
    text-align: left;
    letter-spacing: -0.005em;
    line-height: 1.4;
}

/* Title with logo layout - logo right of title */
.title-with-logo {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    width: 100%;
}

/* School logo styling */
.school-logo {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    object-fit: contain;
    padding: 3px;
    display: none; /* Hidden by default, shown when loaded */
    flex-shrink: 0;
    margin-left: auto;
}

.school-logo.loaded {
    display: block;
}

/* Item fields container - pushes fields to bottom */
.item-fields {
    margin-top: auto;
}

/* Field with icon layout */
.field-with-icon {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    justify-content: flex-end;
}

.map-icon {
    background: none;
    border: none;
    color: #3498db;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-icon:hover {
    background-color: rgba(52, 152, 219, 0.1);
    color: #2980b9;
    transform: scale(1.1);
}

.map-icon svg {
    width: 1.5rem;
    height: 1.5rem;
}

.map-button {
    background: none;
    border: none;
    font-size: inherit;
    font-family: inherit;
    color: #3498db !important;
    cursor: pointer;
    padding: 0;
    /*text-decoration: none;*/
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.map-button:hover {
    text-decoration: underline;
    color: #3498db !important;
}

.detail-field .map-button {
    color: #3498db !important;
}

.detail-field .map-button:hover {
    text-decoration: underline;
    color: #3498db !important;
}

.map-button svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.item-field {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 0.5rem 0;
    /*border-bottom: 1px solid #ffffff;*/
}

.item-field[data-field="programs"] {
    justify-content: center;
    margin-top: 0.5rem;
}

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

.item-field span {
    text-align: left;
    flex: 1;
}

.item-field a {
    color: #3498db;
    text-decoration: none;
}

.item-field a:hover {
    text-decoration: underline;
}

/* Programs button styling */
.programs-button {
    background: #3498db;
    color: white;
    border: none;
    border-radius: 2rem;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.programs-button:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

.programs-count {
    font-weight: 600;
}

/* Program search button */
.program-search-container {
    display: flex;
    justify-content: flex-end;
    padding-top: 0.5rem;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
}

.program-search-btn {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.program-search-btn svg {
    flex-shrink: 0;
}

/* Show button on hover (desktop) */
.program-item:hover .program-search-container {
    max-height: 5rem;
    opacity: 1;
}

/* Show button on tap/touch (mobile) */
@media (hover: none) {
    .program-item.active .program-search-container {
        max-height: 5rem;
        opacity: 1;
    }
}

/* Scroll to top button */
.scroll-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 3.5rem;
    height: 3.5rem;
    background: linear-gradient(135deg, #0D6E95 0%, #1E87B1 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    /*box-shadow: 0 4px 12px rgba(5, 45, 60, 0.1);*/
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    z-index: 10001;
    -webkit-tap-highlight-color: transparent;
}

.scroll-to-top:hover {
    transform: translateY(-4px);
    /*box-shadow: 0 4px 12px rgba(5, 45, 60, 0.1);*/
}

.scroll-to-top:active {
    transform: translateY(-2px);
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
}

/* Responsive design */
@media (max-width: 768px) {
    .scroll-to-top {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 3rem;
        height: 3rem;
    }
    
    .scroll-to-top svg {
        width: 20px;
        height: 20px;
    }
    
    
    /* Remove fixed positioning on mobile */
    filters {
        position: static;
        background: linear-gradient(to bottom, rgba(255, 255, 255, 0.90), rgba(255, 255, 255, 0.80));
        border: 4px solid rgba(255, 255, 255, 0.2);
    }
    
    /* Remove top padding since filters are no longer fixed */
    results {
        padding-top: 2rem;
    }
    
    .filters-header {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }
    
    .filter-logo {
        height: 50px;
    }
    
    .filters-row {
        flex-direction: column;
        align-items: stretch;
        justify-content: center;
        width: 100%;
        gap: 1rem;
    }
    
    .filter-group {
        min-width: auto;
    }
    
    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }
    
    .results-count {
        text-align: center;
        align-self: center;
        width: 100%;
        margin: 0 auto;
        flex: 1;
    }
    
    .program-filters {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 1rem;
    }
    
    .program-filters .filter-group {
        min-width: auto;
        width: 100%;
    }
    
    .item-list {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Keep item-field as flex row on mobile to maintain layout */
    .item-field {
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        gap: 0.5rem;
    }

    .item-field label {
        flex-shrink: 0;
        min-width: 50px;
    }

    .item-field span {
        text-align: left;
        flex: 1;
    }

    /* Special handling for website field with map button */
    .item-field .field-with-icon {
        justify-content: space-between;
        width: 100%;
    }

    .item-field .field-with-icon span {
        text-align: left;
        flex: 1;
    }    .item-title span {
        font-size: 1.1rem;
    }
    
    .item-address span {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    .item {
        padding: 1rem;
    }
}

/* School Detail Overlay Styles */
.school-detail-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.overlay-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.detail-panel {
    position: relative;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.90) 0%, rgba(255, 255, 255, 0.80) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    max-width: 90vw;
    max-height: 90vh;
    width: 800px;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

.detail-header {
    padding: 1.5rem 2rem 1rem 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 2rem;
}

.detail-program-filters {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    margin: 2rem 0 1.5rem 0;
}

.detail-program-filters .filter-group {
    display: flex;
    flex-direction: column;
    min-width: 150px;
}

.detail-program-filters select {
    padding: 0.9rem 2.75rem 0.9rem 1.15rem;
    border: 2px solid #1E87B1;
    border-radius: 2rem;
    background: transparent;
    color: #1E87B1;
    font-size: 1rem;
    font-weight: 400;
    transition: all 0.3s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="8" viewBox="0 0 14 8"><path fill="%230D6E95" d="M1 1l6 6 6-6"/></svg>');
    background-repeat: no-repeat;
    background-position: right 1.15rem center;
    background-size: 12px 7px;
}

.detail-program-filters select:focus {
    outline: none;
    border-color: #1E87B1;
    box-shadow: 0 0 0 3px rgba(13, 110, 149, 0.3);
}

.back-button {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    transition: color 0.2s ease;
    position: relative;
    z-index: 10;
    -webkit-tap-highlight-color: transparent;
}

.back-button:hover {
    color: #3498db;
}

.detail-content {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
}

.school-info {
    margin-bottom: 2rem;
    
}

.school-header {
    margin-bottom: 1.5rem;
}

.school-title-with-logo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.detail-school-logo {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    object-fit: contain;
    padding: 4px;
}

.detail-school-name {
    font-size: 1.5rem;
    font-weight: 600;
    color: #052C3C;
    margin: 0;
    line-height: 1.3;
}

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

.detail-field {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 0rem 0;
}

.detail-field span, .detail-field a {
    color: #052C3C;
    text-align: left;
    flex: 1;
}

.detail-field a {
    color: #3498db;
    text-decoration: none;
}

.detail-field a:hover {
    text-decoration: underline;
}

.programs-section h3 {
    display: none;
}

.programs-section {
    margin-top: 2rem;
}

.faculty-section {
    margin: 1.5rem 0 1rem 0;
}

.faculty-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 1rem 0;
    padding: 0.5rem 0;
}

.program-item {
    /*background: #f8f9fa;*/
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.90) 0%, rgba(255, 255, 255, 0.80) 100%);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 1rem;
    /*border: 3px solid #1E87B1;*/
    border: 4px solid rgba(30, 135, 177, 0.2);
    transition: all 0.2s ease;
}

.program-item:hover {
    /*background: #f1f3f4;*/
    transform: translateX(2px);
    border: 4px solid rgba(30, 135, 177, 1);
}

/* Line 1: Program name (left) + type (right) */
.program-line-1 {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
    gap: 1rem;
}

.program-name {
    font-weight: 600;
    color: #052C3C;
    font-size: 1rem;
    line-height: 1.3;
    flex: 1;
}

.program-type {
    background: #3498db;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Line 2: Forms + study length (left) + language (right) */
.program-line-2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.program-line-2 .left-group {
    display: flex;
    gap: 1rem;
    flex: 1;
}

.study-length {
    color: #052C3C;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.6;
}

/* Line 3: Categories (left) */
.program-line-3 {
    margin-bottom: 0;
}

.program-forms {
    color: #052C3C;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.6;
}

.program-language {
    color: #052C3C;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.6;
}

.program-categories {
    color: #6c757d;
    font-size: inherit;
    font-family: inherit;
    font-style: italic;
}

.loading-programs, .no-programs {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design for Overlay */
@media (max-width: 768px) {
    .detail-panel {
        max-width: 95vw;
        max-height: 95vh;
        margin: 1rem;
    }
    
    .detail-header {
        padding: 1rem 1.5rem 0.5rem 1.5rem;
        position: sticky;
        top: 0;
        background: linear-gradient(to bottom, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.90) 100%);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        z-index: 20;
    }
    
    .back-button {
        z-index: 30;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    .detail-program-filters {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        margin: 1rem 0;
    }
    
    .detail-program-filters .filter-group {
        min-width: auto;
        width: 100%;
    }
    
    .detail-content {
        padding: 1.5rem;
    }
    
    .school-details {
        grid-template-columns: 1fr;
    }
    
    .program-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .program-meta {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .detail-panel {
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }
    
    .detail-header {
        padding: 1rem;
    }
    
    .detail-content {
        padding: 1rem;
    }
}