:root {
    /* Light theme colors */
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-accent: rgba(255, 255, 255, 0.2);
    --text-primary: #333333;
    --text-secondary: #555555;
    --text-accent: #667eea;
    --border-color: #e1e5e9;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);
    --gradient-start: #667eea;
    --gradient-end: #764ba2;
    --card-border: #667eea;
    --expired-border: #dc3545;
    --expired-text: #dc3545;
    --success-color: #28a745;
}

[data-theme="dark"] {
    /* Dark theme colors */
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-accent: rgba(255, 255, 255, 0.1);
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-accent: #7c93ff;
    --border-color: #2d3748;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.4);
    --gradient-start: #4a5568;
    --gradient-end: #2d3748;
    --card-border: #7c93ff;
    --expired-border: #fc8181;
    --expired-text: #fc8181;
    --success-color: #68d391;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.header {
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    color: white;
    padding: 2rem 0;
    margin-bottom: 2rem;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.clickable-title {
    font-size: 2.5rem;
    margin: 0;
    cursor: pointer;
    transition: transform 0.2s ease;
    text-decoration: none;
    color: inherit;
}

.clickable-title:hover {
    transform: scale(1.05);
}

.theme-toggle {
    background: var(--bg-accent);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.5rem;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 1rem;
}

.stats {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.stat {
    background: var(--bg-accent);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    white-space: nowrap;
}

.filters {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px var(--shadow-color);
    margin-bottom: 2rem;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 1rem;
    transition: border-color 0.3s ease;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.search-input:focus {
    outline: none;
    border-color: var(--text-accent);
}

.filter-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--text-accent);
    color: white;
    border-color: var(--text-accent);
}

.jobs-container {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
}

.job-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px var(--shadow-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
    border-left: 4px solid var(--card-border);
}

.job-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--shadow-hover);
}

.job-card.expired {
    opacity: 0.7;
    border-left-color: var(--expired-border);
}

.job-header {
    margin-bottom: 1rem;
}

.job-title {
    font-size: 1.3rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.job-institution {
    color: var(--text-accent);
    font-weight: 500;
    font-size: 1.1rem;
}

.job-meta {
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.job-meta > div {
    margin-bottom: 0.3rem;
}

.deadline.expired-text {
    color: var(--expired-text);
    font-weight: bold;
}

.job-description {
    background: var(--bg-primary);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    max-width: 100%;
    overflow-x: hidden;
}

/* Ensure HTML content in job descriptions renders properly */
.job-description div {
    margin-bottom: 0.5rem;
}

.job-description div:last-child {
    margin-bottom: 0;
}

.job-description strong,
.job-description b {
    font-weight: 600;
}

.job-description a {
    color: var(--text-accent);
    text-decoration: none;
    word-break: break-all;
}

.job-description a:hover {
    text-decoration: underline;
}

.job-description ul,
.job-description ol {
    margin-left: 1.2rem;
    margin-bottom: 0.5rem;
}

.job-description li {
    margin-bottom: 0.2rem;
}

.job-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-apply,
.btn-contact {
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: inline-block;
}

.btn-apply {
    background: var(--text-accent);
    color: white;
    border: none;
}

.btn-apply:hover {
    background: var(--card-border);
    transform: translateY(-1px);
}

.btn-contact {
    background: transparent;
    color: var(--text-accent);
    border: 1px solid var(--text-accent);
}

.btn-contact:hover {
    background: var(--text-accent);
    color: white;
}

.no-jobs {
    text-align: center;
    padding: 3rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-color);
    color: var(--text-primary);
}

.footer {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 2rem 0;
    margin-top: 3rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.footer a {
    color: var(--text-accent);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer a:hover {
    text-decoration: underline;
}

.hidden {
    display: none !important;
}

/* ============================================ */
/* RESPONSIVE DESIGN */
/* ============================================ */

/* Large screens (desktops) */
@media (min-width: 1200px) {
    .container {
        max-width: 1400px;
    }
    
    .jobs-container {
        grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    }
}

/* Medium screens (tablets) */
@media (max-width: 1024px) {
    .container {
        padding: 0 15px;
    }
    
    .jobs-container {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 1rem;
    }
    
    .clickable-title {
        font-size: 2rem;
    }
    
    .header {
        padding: 1.5rem 0;
    }
    
    .stats {
        gap: 0.5rem;
    }
    
    .stat {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
}

/* Small tablets */
@media (max-width: 768px) {
    .header-top {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }
    
    .clickable-title {
        font-size: 1.8rem;
        text-align: center;
    }
    
    .theme-toggle {
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
    
    .jobs-container {
        grid-template-columns: 1fr;
    }
    
    .subtitle {
        font-size: 1rem;
        text-align: center;
    }
    
    .stats {
        justify-content: center;
        gap: 0.5rem;
    }
    
    .filters {
        padding: 1rem;
    }
    
    .filter-buttons {
        justify-content: center;
        gap: 0.5rem;
    }
    
    .filter-btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
}

/* Mobile phones */
@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
    
    .header {
        padding: 1rem 0;
        margin-bottom: 1rem;
    }
    
    .clickable-title {
        font-size: 1.5rem;
    }
    
    .theme-toggle {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
    
    .stats {
        flex-direction: column;
        align-items: center;
        gap: 0.3rem;
    }
    
    .stat {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
    }
    
    .search-input {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    .filter-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .filter-btn {
        width: 100%;
        max-width: 200px;
        text-align: center;
    }
    
    .job-card {
        padding: 1rem;
    }
    
    .job-title {
        font-size: 1.1rem;
    }
    
    .job-institution {
        font-size: 1rem;
    }
    
    .job-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .btn-apply,
    .btn-contact {
        width: 100%;
        text-align: center;
        padding: 0.8rem;
    }
    
    .footer {
        padding: 1.5rem 0;
        font-size: 0.9rem;
    }
}

/* Extra small screens */
@media (max-width: 360px) {
    .clickable-title {
        font-size: 1.3rem;
    }
    
    .job-meta {
        font-size: 0.8rem;
    }
    
    .job-description {
        font-size: 0.8rem;
        padding: 0.8rem;
        max-width: 100%;
        overflow-x: hidden;
    }
}