/* ==========================================================================
   MERIT LISTS SPECIFIC STYLES
   ========================================================================== */

.merit-header h2 {
    color: white;
    letter-spacing: -0.05em;
    font-weight: 800;
}

.merit-header p {
    color: rgba(255,255,255,0.86);
    font-size: 1.1rem;
}

#dropdowns-container {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px !important;
}

.selection-card, .merit-card {
    border-radius: 32px !important;
    overflow: visible !important;
}

.selection-card {
    position: relative;
    z-index: 999;
}

.merit-card {
    position: relative;
    z-index: 998;
    margin-bottom: 80px;
}

.selection-card:hover, .merit-card:hover {
    transform: none !important;
}

/* Ensure global fonts are applied to controls */
.custom-select, .pill-select, .list-btn, .page-btn, .merit-table {
    font-family: "Space Grotesk", system-ui, sans-serif !important;
}

/* Form Controls */
.dropdown-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--slate-500);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dropdown-label svg {
    color: var(--blue-500);
}

.custom-select {
    width: 100%;
    appearance: none;
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: 14px;
    padding: 14px 44px 14px 16px;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
    color: var(--slate-800);
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    animation: bounceSelect 2s infinite ease-in-out;
}

.custom-select:hover {
    border-color: var(--blue-300);
    background-color: white;
}

.custom-select:focus {
    outline: none;
    border-color: var(--blue-500);
    box-shadow: 0 0 0 4px var(--blue-50);
}

.custom-select option, .pill-select option {
    background: white;
    color: var(--blue-700);
    padding: 12px;
}

/* Custom Dropdown Component */
.custom-dropdown {
    position: relative;
    width: 100%;
}

.custom-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--blue-100);
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.1);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 146px;
    overflow-y: auto;
}

.custom-dropdown.open .custom-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-dropdown-option {
    padding: 14px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--slate-700);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    border-bottom: 1px solid var(--slate-50);
}

.custom-dropdown-option:last-child {
    border-bottom: none;
}

.custom-dropdown-option:hover, .custom-dropdown-option.selected {
    background: var(--blue-50);
    color: var(--blue-700);
}

.custom-dropdown-option.disabled {
    color: var(--slate-400);
    cursor: not-allowed;
    background: var(--slate-50);
}

.custom-dropdown-menu::-webkit-scrollbar {
    width: 8px;
}
.custom-dropdown-menu::-webkit-scrollbar-track {
    background: transparent;
    margin: 8px;
}
.custom-dropdown-menu::-webkit-scrollbar-thumb {
    background: var(--slate-200);
    border-radius: 4px;
}
.custom-dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: var(--slate-300);
}

/* Card 2 Header */
.merit-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 32px 32px 24px;
    border-bottom: 1px solid var(--slate-100);
    flex-wrap: wrap;
    gap: 20px;
}

.uni-info-wrap {
    display: flex;
    align-items: center;
    gap: 16px;
}

.uni-logo-box {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: white;
    border: 1px solid var(--slate-100);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

.uni-logo-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.uni-details h3 {
    margin: 0 0 8px 0;
    font-size: 1.4rem;
    color: var(--slate-900);
    font-weight: 800;
}

.uni-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.badge-campus {
    background: var(--slate-100);
    color: var(--slate-600);
}

.badge-year {
    background: var(--blue-50);
    color: var(--blue-600);
}

.badge svg {
    width: 12px;
    height: 12px;
}

.last-updated {
    text-align: right;
}

.last-updated span {
    display: block;
    font-size: 0.75rem;
    color: var(--slate-400);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.last-updated strong {
    font-size: 0.95rem;
    color: var(--slate-800);
    font-weight: 700;
}

/* Filters row inside Merit Card */
.merit-filters {
    display: flex;
    gap: 16px;
    padding: 20px 32px;
    background: var(--slate-50);
    border-bottom: 1px solid var(--slate-100);
    align-items: flex-end;
    flex-wrap: wrap;
    border-radius: 32px 32px 0 0;
}

.filter-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.filter-group label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--slate-500);
}

.pill-select {
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid var(--blue-500);
    background: white;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--slate-800);
    cursor: pointer;
    appearance: none;
    height: 44px;
    display: inline-flex;
    align-items: center;
    padding-right: 40px;
    padding-left: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s ease;
}

.pill-select:hover {
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
}

.pill-select:focus {
    outline: none;
    border-color: var(--blue-600);
    box-shadow: 0 0 0 4px var(--blue-50);
}

.list-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.list-btn {
    padding: 0 16px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: 1px solid var(--slate-200);
    background: white;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--slate-600);
    cursor: pointer;
    transition: all 0.2s ease;
}

.list-btn:hover {
    background: var(--blue-50);
    border-color: var(--blue-300);
}

.list-btn.active {
    background: var(--blue-600);
    color: white;
    border-color: var(--blue-600);
}

/* Table styling */
.merit-table-container {
    padding: 0 32px;
    min-height: 400px;
}

.merit-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
}

.merit-table th {
    padding: 16px 12px;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--slate-400);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 2px solid var(--slate-100);
}

.merit-table th:last-child {
    text-align: right;
}

.merit-table td {
    padding: 16px 12px;
    font-size: 0.95rem;
    color: var(--slate-700);
    font-weight: 600;
    border-bottom: 1px solid var(--slate-50);
    transition: background 0.2s ease;
}

.merit-table tbody tr:hover td {
    background: var(--slate-50);
}

.merit-table td:last-child {
    text-align: right;
}

.score-badge {
    display: inline-block;
    padding: 6px 12px;
    background: var(--blue-50);
    color: var(--blue-600);
    border: 1px solid var(--blue-100);
    border-radius: 8px;
    font-weight: 800;
    font-size: 0.95rem;
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    border-top: 1px solid var(--slate-100);
    background: var(--slate-50);
}

.page-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 12px;
    border: 1px solid var(--slate-200);
    background: white;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--slate-700);
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    background: var(--slate-100);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-info {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--slate-500);
}

/* Footer Actions */
.merit-actions {
    padding: 24px 32px;
    background: white;
    border-top: 1px solid var(--slate-100);
    border-radius: 0 0 28px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.disclaimer {
    font-size: 0.8rem;
    color: var(--slate-400);
    margin: 0;
    flex: 1;
    min-width: 250px;
}

.action-buttons {
    display: flex;
    gap: 12px;
    margin-left: auto;
}

/* Dropup specific adjustments */
.dropup .custom-dropdown-menu {
    top: auto;
    bottom: calc(100% + 8px);
    left: auto;
    right: 0;
    width: max-content;
    min-width: 220px;
    white-space: nowrap;
    transform: translateY(10px);
}
.dropup.open .custom-dropdown-menu {
    transform: translateY(0);
}

.btn-whatsapp {
    background: #25D366;
    color: white;
    box-shadow: 0 10px 20px rgba(37, 211, 102, 0.2);
}

.btn-whatsapp:hover {
    background: #20bd5a;
    box-shadow: 0 14px 28px rgba(37, 211, 102, 0.3);
}

.animated-btn {
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.animated-btn:hover {
    transform: translateY(-2px) scale(1.02);
}

.animated-btn:active {
    transform: translateY(1px) scale(0.98);
}

.animated-btn svg {
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.animated-btn:hover svg {
    transform: scale(1.15) rotate(-5deg);
}

/* Download Template Wrapper - Hidden from view but used for HTML2Canvas */
.export-wrapper {
    position: absolute;
    left: -9999px;
    top: 0;
    width: 800px;
    background: white;
    padding: 40px;
    z-index: -100;
    font-family: "Space Grotesk", system-ui, sans-serif;
    color: #0f172a;
}

.export-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.1;
    pointer-events: none;
    width: 60%;
    z-index: 0;
}

.export-content {
    position: relative;
    z-index: 1;
}

.export-footer-brand {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
    color: #64748b;
    font-size: 0.9rem;
    font-weight: 700;
}

.select-container {
    position: relative;
    width: 100%;
}

.select-arrow {
    position: absolute;
    right: 16px;
    top: 50%;
    margin-top: -8px;
    width: 16px;
    height: 16px;
    pointer-events: none;
    background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' xml:space='preserve' id='dropdown' x='0' y='0' version='1.1' viewBox='0 0 24 24'%3E%3Cpath fill='%23039BE5' d='M21.856 1L12 1.001 2.144 1A2.153 2.153 0 0 0 .22 4.096c1.597 3.279 9.044 16.203 9.887 17.742.4.727 1.107 1.162 1.894 1.162.786 0 1.493-.435 1.893-1.162.842-1.538 8.288-14.462 9.886-17.74A2.153 2.153 0 0 0 21.856 1z'/%3E%3ClinearGradient id='g1' x1='-.547' x2='19.531' y1='3.849' y2='13.211' gradientUnits='userSpaceOnUse'%3E%3Cstop offset='0' stop-color='%23FFF' stop-opacity='.2'/%3E%3Cstop offset='1' stop-color='%23FFF' stop-opacity='0'/%3E%3C/linearGradient%3E%3Cpath fill='url(%23g1)' d='M21.856 1L12 1.001 2.144 1A2.153 2.153 0 0 0 .22 4.096c1.597 3.279 9.044 16.203 9.887 17.742.4.727 1.107 1.162 1.894 1.162.786 0 1.493-.435 1.893-1.162.842-1.538 8.288-14.462 9.886-17.74A2.153 2.153 0 0 0 21.856 1z'/%3E%3C/svg%3E");
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.3s ease;
}

.pill-select + .select-arrow {
    right: 12px;
}

.select-container select:focus + .select-arrow,
.custom-dropdown.open .select-arrow {
    transform: rotate(180deg);
}

/* Animations */
.smooth-fade {
    animation: smoothFade 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes smoothFade {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Empty State / Loading State */
.state-container {
    padding: 60px 20px;
    text-align: center;
    color: var(--slate-500);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.state-container svg {
    margin-bottom: 16px;
    color: var(--slate-300);
}

.state-container h4 {
    font-size: 1.2rem;
    color: var(--slate-800);
    margin: 0 0 8px 0;
}

/* Skeleton */
.skeleton {
    background: linear-gradient(90deg, var(--slate-100) 25%, var(--slate-200) 50%, var(--slate-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.sk-row {
    height: 48px;
    margin-bottom: 12px;
    width: 100%;
}

/* Responsive */
@media (max-width: 768px) {
    .merit-card-header {
        padding: 24px;
        flex-direction: column;
    }
    
    .last-updated {
        text-align: left;
    }

    .merit-table-container {
        padding: 0 16px;
    }

    .merit-table td, .merit-table th {
        padding: 12px 8px;
        font-size: 0.85rem;
    }

    .score-badge {
        font-size: 0.85rem;
        padding: 4px 8px;
    }

    .merit-actions {
        padding: 20px 16px;
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .btn {
        width: 100%;
    }
    
    .pagination-container {
        padding: 16px;
    }
    
    .page-btn span {
        display: none; /* Hide 'Previous' / 'Next' text on mobile */
    }
}

.menu-icon { width: 22px; height: 22px; }
.dropdown-arrow-icon { width: 16px; height: 16px; transition: transform 0.3s ease; }
@media (max-width: 768px) {
    .menu-icon { width: 24px; height: 24px; }
    .dropdown-arrow-icon { width: 20px; height: 20px; }
}

.dropup.open .dropdown-arrow-icon {
    transform: rotate(180deg);
}
