* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --accent-color: #ff6b6b;
    --success-color: #48bb78;
    --danger-color: #fed7d7;
    --text-dark: #2d3748;
    --text-medium: #4a5568;
    --text-light: #718096;
    --white: #ffffff;
    --card-shadow: 0 8px 25px rgba(0,0,0,0.1);
    --card-shadow-hover: 0 12px 35px rgba(0,0,0,0.15);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== NAVIGATION ===== */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
}

.logo {
    font-size: clamp(1.3rem, 4vw, 1.8rem);
    font-weight: bold;
    color: var(--text-medium);
    white-space: nowrap;
}

.nav-links {
    display: flex;
    gap: clamp(0.75rem, 2vw, 2rem);
    align-items: center;
}

.nav-link {
    text-decoration: none;
    color: var(--text-medium);
    font-weight: 500;
    transition: all 0.3s ease;
    font-size: clamp(0.85rem, 2vw, 1rem);
    padding: 0.5rem 0.75rem;
    border-radius: 5px;
    white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary-color);
    background: rgba(102, 126, 234, 0.1);
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-medium);
    cursor: pointer;
    padding: 0.5rem;
    min-width: 44px;
    min-height: 44px;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: clamp(0.5rem, 2vw, 2rem);
    width: 100%;
}

/* ===== HERO SECTION ===== */
.hero {
    text-align: center;
    padding: clamp(1.5rem, 4vw, 4rem) 0.5rem;
    color: var(--white);
    padding-bottom: 0px;
}

.hero-title {
    font-size: clamp(1.75rem, 6vw, 3rem);
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    line-height: 1.2;
    padding: 0 0.5rem;
}

.hero-subtitle {
    font-size: clamp(0.9rem, 3vw, 1.2rem);
    margin-bottom: 2rem;
    opacity: 0.9;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 1rem;
    line-height: 1.4;
}

/* ===== SEARCH ===== */
.search-container {
    display: flex;
    max-width: 600px;
    margin: 0 auto;
    gap: 0.5rem;
    width: 100%;
    padding: 0 0.5rem;
}

.search-input {
    flex: 1;
    padding: clamp(0.75rem, 2vw, 1rem);
    border: none;
    border-radius: 50px;
    font-size: clamp(0.9rem, 2vw, 1rem);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    min-width: 0;
    min-height: 50px;
}

.search-btn {
    padding: clamp(0.75rem, 2vw, 1rem) clamp(1rem, 3vw, 2rem);
    background: var(--accent-color);
    color: var(--white);
    border: none;
    border-radius: 50px;
    font-size: clamp(0.9rem, 2vw, 1rem);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    min-width: fit-content;
    min-height: 50px;
    white-space: nowrap;
}

.search-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

/* ===== RESULTS SECTION ===== */
.results-section {
    margin-top: 2rem;
    width: 100%;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: var(--white);
    font-size: clamp(1rem, 3vw, 1.2rem);
}

.hidden {
    display: none !important;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: clamp(0.75rem, 2vw, 1.5rem);
    margin-top: 2rem;
    width: 100%;
    padding: 0 0.25rem;
}

/* ===== UNIVERSITY CARDS - ENHANCED RESPONSIVENESS ===== */
.university-card {
    background: var(--white);
    border-radius: 12px;
    padding: clamp(0.75rem, 2vw, 1.25rem);
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
    border-left: 4px solid var(--primary-color);
    width: 100%;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    break-inside: avoid;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.university-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--card-shadow-hover);
}

.university-card h3 {
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    font-size: clamp(1rem, 3vw, 1.2rem);
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.uni-country, .uni-domain {
    color: var(--text-light);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    line-height: 1.3;
}

.uni-country span, .uni-domain span {
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.website-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: var(--white);
    padding: clamp(0.4rem, 1.5vw, 0.6rem) clamp(0.8rem, 2vw, 1.2rem);
    border-radius: 20px;
    text-decoration: none;
    margin: 0.4rem 0;
    transition: all 0.3s ease;
    text-align: center;
    font-size: clamp(0.8rem, 2vw, 0.85rem);
    min-height: 36px;
    width: fit-content;
    max-width: 100%;
}

.website-link:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

.no-website {
    color: var(--text-light);
    font-style: italic;
    font-size: clamp(0.8rem, 2vw, 0.85rem);
    margin: 0.5rem 0;
}

.btn-add, .btn-remove {
    width: 100%;
    padding: clamp(0.6rem, 1.5vw, 0.8rem);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-top: 0.5rem;
    font-size: clamp(0.8rem, 2vw, 0.85rem);
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-add {
    background: var(--success-color);
    color: var(--white);
}

.btn-add:hover {
    background: #38a169;
    transform: translateY(-1px);
}

.btn-remove {
    background: var(--danger-color);
    color: #c53030;
}

.btn-remove:hover {
    background: #feb2b2;
    transform: translateY(-1px);
}

/* ===== DASHBOARD ===== */
.dashboard-title {
    color: var(--white);
    text-align: center;
    margin-bottom: 2rem;
    font-size: clamp(1.5rem, 5vw, 2.2rem);
    padding: 0 0.5rem;
}

.empty-state {
    text-align: center;
    background: var(--white);
    padding: clamp(1.5rem, 3vw, 2.5rem);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin: 0 0.5rem;
}

.empty-state h2 {
    color: var(--text-dark);
    margin-bottom: 1rem;
    font-size: clamp(1.2rem, 4vw, 1.4rem);
}

.empty-state p {
    color: var(--text-light);
    margin-bottom: 1.5rem;
    font-size: clamp(0.85rem, 3vw, 1rem);
    line-height: 1.4;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: var(--white);
    padding: clamp(0.7rem, 2vw, 0.9rem) clamp(1.2rem, 3vw, 1.8rem);
    border-radius: 8px;
    text-decoration: none;
    margin-top: 1rem;
    transition: all 0.3s ease;
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    min-height: 44px;
    border: none;
    cursor: pointer;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.btn-primary:hover {
    background: #5a6fd8;
    transform: translateY(-2px);
}

.saved-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: clamp(0.75rem, 2vw, 1.5rem);
    width: 100%;
    padding: 0 0.25rem;
}

/* ===== AUTH PAGES ===== */
.auth-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
    padding: 1rem 0.5rem;
}

.auth-container {
    background: var(--white);
    padding: clamp(1.25rem, 3vw, 2.5rem);
    border-radius: 12px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    width: 100%;
    max-width: min(380px, 95vw);
    margin: 0 auto;
}

.auth-container h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-medium);
    font-size: clamp(1.3rem, 4vw, 1.8rem);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.form-group {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.form-group label {
    margin-bottom: 0.5rem;
    color: var(--text-medium);
    font-weight: 500;
    font-size: clamp(0.85rem, 2vw, 0.95rem);
}

.form-group input {
    padding: clamp(0.7rem, 2vw, 0.9rem);
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    transition: all 0.3s ease;
    width: 100%;
    min-height: 44px;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.error-message {
    background: var(--danger-color);
    color: #c53030;
    padding: clamp(0.7rem, 2vw, 0.9rem);
    border-radius: 6px;
    margin-bottom: 1rem;
    text-align: center;
    font-size: clamp(0.8rem, 2vw, 0.85rem);
    line-height: 1.3;
}

/* ===== FOOTER ===== */
.footer {
    text-align: center;
    padding: clamp(1rem, 2vw, 1.5rem);
    color: var(--white);
    margin-top: 3rem;
    border-top: 1px solid rgba(255,255,255,0.2);
    font-size: clamp(0.75rem, 2vw, 0.85rem);
    line-height: 1.4;
}

.footer a {
    color: var(--white);
    text-decoration: underline;
    transition: opacity 0.3s ease;
}

.footer a:hover {
    opacity: 0.8;
}

/* ===== ENHANCED RESPONSIVE BREAKPOINTS ===== */

/* Extra Large Screens */
@media (min-width: 1400px) {
    .results-grid,
    .saved-list {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Large Desktop */
@media (min-width: 1200px) and (max-width: 1399px) {
    .results-grid,
    .saved-list {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Desktop */
@media (min-width: 1024px) and (max-width: 1199px) {
    .results-grid,
    .saved-list {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Tablet Landscape */
@media (min-width: 769px) and (max-width: 1023px) {
    .results-grid,
    .saved-list {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .nav-links {
        gap: 1.25rem;
    }
}

/* Tablet Portrait */
@media (min-width: 601px) and (max-width: 768px) {
    .results-grid,
    .saved-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        padding: 0 0.5rem;
    }
    
    .university-card {
        padding: 1rem;
    }
}

/* Mobile Landscape & Small Tablets */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: row;
        justify-content: space-between;
        padding: 0 0.75rem;
    }
    
    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--white);
        flex-direction: column;
        padding: 1rem;
        box-shadow: 0 4px 15px rgba(0,0,0,0.1);
        gap: 0.5rem;
        z-index: 1001;
    }
    
    .nav-links.active {
        display: flex;
    }
    
    .nav-link {
        padding: 0.75rem 1rem;
        text-align: center;
        border-radius: 5px;
        width: 100%;
    }
    
    .hero-title {
        font-size: 1.8rem;
    }
    
    .search-container {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .search-btn {
        width: 100%;
    }
    
    .main-content {
        padding: 0.75rem;
    }
}

/* Small Mobile (481px - 600px) */
@media (max-width: 600px) {
    .results-grid,
    .saved-list {
        grid-template-columns: 1fr;
        gap: 1.4rem;
        padding: 0 0.25rem;
    }
    
    .university-card {
        margin: 0;
        padding: 1rem;
        min-height: 170px;
    }
    
    .university-card h3 {
        font-size: 1.1rem;
    }
    
    .website-link {
        min-height: 34px;
    }
}

/* Extra Small Mobile (421px - 480px) */
@media (max-width: 480px) {
    .nav-container {
        padding: 0 0.5rem;
    }
    
    .hero {
        padding: 1.25rem 0.25rem;
    }
    
    .hero-title {
        font-size: 1.6rem;
        padding: 0 0.25rem;
    }
    
    .hero-subtitle {
        font-size: 0.95rem;
        padding: 0 0.5rem;
    }
    
    .search-container {
        padding: 0 0.25rem;
    }
    
    .main-content {
        padding: 0.5rem;
    }
    
    .results-grid,
    .saved-list {
        gap: 0.6rem;
    }
    
    .university-card {
        padding: 0.9rem;
        min-height: 160px;
        border-radius: 10px;
    }
    
    .university-card h3 {
        font-size: 1.05rem;
    }
    
    .auth-container {
        padding: 1.25rem 1rem;
    }
    
    .empty-state {
        padding: 1.25rem 0.75rem;
        margin: 0 0.25rem;
    }
    
    .dashboard-title {
        font-size: 1.6rem;
    }
    
    .footer {
        padding: 1.25rem 0.5rem;
    }
}

/* Super Small Mobile (321px - 420px) */
@media (max-width: 420px) {
    .nav-container {
        padding: 0 0.4rem;
    }
    
    .logo {
        font-size: 1.2rem;
    }
    
    .hero {
        padding: 1rem 0.2rem;
    }
    
    .hero-title {
        font-size: 1.4rem;
    }
    
    .hero-subtitle {
        font-size: 0.9rem;
        padding: 0 0.4rem;
    }
    
    .search-input {
        min-height: 46px;
        font-size: 0.9rem;
    }
    
    .search-btn {
        min-height: 46px;
        font-size: 0.9rem;
    }
    
    .main-content {
        padding: 0.4rem;
    }
    
    .results-grid,
    .saved-list {
        gap: 0.5rem;
        padding: 0 0.1rem;
    }
    
    .university-card {
        padding: 0.8rem;
        min-height: 150px;
        border-radius: 8px;
    }
    
    .university-card h3 {
        font-size: 1rem;
        line-height: 1.25;
    }
    
    .uni-country, .uni-domain {
        font-size: 0.8rem;
        gap: 0.3rem;
    }
    
    .website-link {
        padding: 0.35rem 0.7rem;
        font-size: 0.78rem;
        min-height: 32px;
    }
    
    .btn-add, .btn-remove {
        padding: 0.5rem;
        font-size: 0.8rem;
        min-height: 38px;
    }
}

/* Ultra Small Mobile (320px and below) */
@media (max-width: 320px) {
    .nav-container {
        padding: 0 0.3rem;
    }
    
    .logo {
        font-size: 1.1rem;
    }
    
    .menu-toggle {
        min-width: 40px;
        min-height: 40px;
        font-size: 1.3rem;
    }
    
    .hero {
        padding: 0.8rem 0.1rem;
    }
    
    .hero-title {
        font-size: 1.3rem;
        padding: 0 0.2rem;
    }
    
    .hero-subtitle {
        font-size: 0.85rem;
        padding: 0 0.3rem;
        margin-bottom: 1.5rem;
    }
    
    .search-container {
        padding: 0 0.2rem;
        gap: 0.5rem;
    }
    
    .search-input {
        padding: 0.7rem;
        font-size: 0.85rem;
        min-height: 44px;
    }
    
    .search-btn {
        padding: 0.7rem 1rem;
        font-size: 0.85rem;
        min-height: 44px;
    }
    
    .main-content {
        padding: 0.3rem;
    }
    
    .results-section {
        margin-top: 1.5rem;
    }
    
    .results-grid,
    .saved-list {
        gap: 0.4rem;
        padding: 0;
    }
    
    .university-card {
        padding: 0.7rem;
        min-height: 140px;
        border-radius: 6px;
        border-left-width: 3px;
    }
    
    .university-card h3 {
        font-size: 0.95rem;
        margin-bottom: 0.4rem;
    }
    
    .uni-country, .uni-domain {
        font-size: 0.75rem;
        margin-bottom: 0.3rem;
        gap: 0.25rem;
    }
    
    .website-link {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
        min-height: 30px;
        border-radius: 15px;
        margin: 0.3rem 0;
    }
    
    .btn-add, .btn-remove {
        padding: 0.45rem;
        font-size: 0.75rem;
        min-height: 36px;
        border-radius: 4px;
        margin-top: 0.4rem;
    }
    
    .auth-container {
        padding: 1rem 0.8rem;
        border-radius: 8px;
    }
    
    .auth-container h1 {
        font-size: 1.3rem;
        margin-bottom: 1.25rem;
    }
    
    .form-group input {
        padding: 0.6rem;
        font-size: 0.85rem;
        min-height: 40px;
    }
    
    .empty-state {
        padding: 1rem 0.6rem;
        margin: 0 0.2rem;
        border-radius: 8px;
    }
    
    .empty-state h2 {
        font-size: 1.1rem;
    }
    
    .empty-state p {
        font-size: 0.8rem;
    }
    
    .btn-primary {
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
        min-height: 40px;
    }
    
    .footer {
        padding: 1rem 0.4rem;
        font-size: 0.75rem;
    }
}

/* Prevent horizontal scrolling on all devices */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

/* Improve touch scrolling for mobile */
@media (hover: none) and (pointer: coarse) {
    .university-card:hover {
        transform: none;
    }
    
    .search-btn:hover,
    .btn-add:hover,
    .btn-remove:hover,
    .btn-primary:hover,
    .website-link:hover {
        transform: none;
    }
    
    /* Better touch targets */
    .nav-link,
    .website-link,
    .btn-add,
    .btn-remove,
    .btn-primary,
    .search-btn {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* High contrast support for accessibility */
@media (prefers-contrast: high) {
    .university-card {
        border: 2px solid var(--primary-color);
    }
    
    .nav-link.active {
        background: var(--primary-color);
        color: var(--white);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
    
    .university-card:hover,
    .search-btn:hover,
    .btn-add:hover,
    .btn-remove:hover,
    .btn-primary:hover,
    .website-link:hover {
        transform: none;
    }
}

/* Print styles */
@media print {
    .navbar,
    .search-container,
    .btn-add,
    .btn-remove {
        display: none;
    }
    
    .university-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* ===== LOADER STYLES ===== */
.loading {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--white);
    font-size: clamp(1rem, 3vw, 1.2rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

.loading-text {
    font-weight: 500;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    animation: pulse 2s infinite ease-in-out;
}

/* Modern loading spinner */
.loading::before {
    content: '';
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid var(--white);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: block;
}

/* Alternative: Dots loading animation */
.loading.dots::before {
    content: '';
    animation: none;
    border: none;
    width: auto;
    height: auto;
}

.loading.dots .loading-text::after {
    content: '';
    animation: dots 1.5s infinite steps(4);
}

/* Loading animations */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* Fade in animation when showing */
.loading:not(.hidden) {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive loader sizes */
@media (max-width: 768px) {
    .loading {
        padding: 2rem 1rem;
        gap: 1.25rem;
    }
    
    .loading::before {
        width: 40px;
        height: 40px;
        border-width: 3px;
    }
}

@media (max-width: 480px) {
    .loading {
        padding: 1.5rem 0.75rem;
        gap: 1rem;
    }
    
    .loading::before {
        width: 35px;
        height: 35px;
        border-width: 3px;
    }
    
    .loading-text {
        font-size: 1rem;
    }
}

@media (max-width: 320px) {
    .loading {
        padding: 1.25rem 0.5rem;
        gap: 0.75rem;
    }
    
    .loading::before {
        width: 30px;
        height: 30px;
        border-width: 2px;
    }
    
    .loading-text {
        font-size: 0.9rem;
    }
}

/* Hidden state */
.hidden {
    display: none !important;
}