* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

:root {
    --primary-color: #2b6cb0;
    --primary-gradient: linear-gradient(135deg, #4299e1, #2b6cb0);
    --secondary-color: #6b46c1;
    --secondary-gradient: linear-gradient(135deg, #805ad5, #6b46c1);
    --accent-color: #38b2ac;
    --accent-gradient: linear-gradient(135deg, #4fd1c5, #38b2ac);
    --text-color: #2d3748;
    --light-text: #f7fafc;
    --card-bg: white;
    --hover-shadow: 0 10px 30px rgba(66, 153, 225, 0.25);
    --card-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

body {
    background-color: #f9fafc;
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    overflow-x: hidden;
}

.desktop-optimized {
    width: 100%;
}

/* Header Styles */
header {
    text-align: center;
    margin-bottom: 2.5rem;
    padding: 2.5rem 1rem;
    position: relative;
    overflow: hidden;
    border-radius: var(--border-radius);
    background: var(--primary-gradient);
    color: var(--light-text);
    box-shadow: var(--card-shadow);
    background-size: 300% 300%;
    animation: gradientShift 10s ease infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

header h1 {
    margin-bottom: 1rem;
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header .subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* Subject Selector Tabs */
.subject-selector {
    margin-bottom: 2.5rem;
}

.subject-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.subject-tab {
    padding: 1rem 2rem;
    border: none;
    border-radius: var(--border-radius);
    background-color: white;
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 10px;
}

.subject-tab i {
    font-size: 1.2rem;
}

.subject-tab:hover {
    transform: translateY(-3px);
    box-shadow: var(--hover-shadow);
}

.subject-tab.active {
    background: var(--primary-gradient);
    color: white;
}

/* Topics Container */
.topics-container,
.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
    width: 100%;
}

/* Force at least 2 per row on medium screens */
@media (min-width: 768px) {
    .topics-container,
    .topics-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        justify-content: center;
    }
}

/* Ideal layout for desktop (consistently 2–3 per row depending on width) */
@media (min-width: 992px) {
    .topics-container,
    .topics-grid {
        grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
        max-width: 1100px;
        margin: 0 auto;
    }
}

/* Optional: Wider monitors — allow 3-4 per row */
@media (min-width: 1400px) {
    .topics-container,
    .topics-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        max-width: 1400px;
    }
}

/* Topic Card Styles */
.topic-card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.8rem;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    transform-origin: center;
    animation: fadeInUp 0.5s forwards;
    opacity: 0;
    min-height: 300px;
    width: 100%;
}

@media (min-width: 992px) {
    .topic-card {
        min-height: 400px;
        padding: 2.5rem;
        max-width: 100%;
    }
}

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

.topic-card:hover:not(.locked) {
    transform: translateY(-5px);
    box-shadow: var(--hover-shadow);
}

.topic-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: var(--primary-gradient);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.topic-card:hover::before {
    transform: scaleX(1);
}

.topic-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-color);
    position: relative;
    padding-bottom: 10px;
    line-height: 1.3;
}

.topic-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50px;
    height: 3px;
    background: var(--secondary-gradient);
    border-radius: 10px;
}

.topic-content {
    margin-bottom: 1.5rem;
    font-size: 1rem;
    color: #555;
    flex-grow: 1;
    line-height: 1.7;
}

@media (min-width: 992px) {
    .topic-content {
        font-size: 1.25rem;
        margin-bottom: 2.5rem;
        line-height: 1.8;
    }
    
    .topic-title {
        font-size: 1.8rem;
        margin-bottom: 1.8rem;
        padding-bottom: 15px;
    }
    
    .topic-title::after {
        height: 4px;
        width: 70px;
    }
}

.topic-status {
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 1.2rem;
    display: flex;
    align-items: center;
}

.topic-status.available {
    color: #27ae60;
}

.topic-status.available::before {
    content: '•';
    margin-right: 8px;
    font-size: 1.5rem;
}

.locked {
    background-color: #f9fafc;
    border: 1px solid #e9ecef;
    opacity: 0.9;
}

.locked .topic-title {
    color: #6c757d;
}

.locked-by {
    font-weight: 600;
    color: #e74c3c;
}

.select-btn {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
    margin-top: 0.5rem;
}

.select-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    transition: 0.5s;
}

.select-btn:hover::before {
    left: 100%;
}

.select-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(58, 123, 213, 0.4);
}

.view-details-btn {
    background: var(--secondary-gradient);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 0.8rem;
    position: relative;
    overflow: hidden;
}

/* Style for View Details button on locked topics */
.locked-view-details {
    background: linear-gradient(135deg, #6c5ce7, #4834d4);
    margin-bottom: 1rem;
}

.view-details-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(142, 45, 226, 0.4);
}

.add-link-btn {
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 1rem;
}

.add-link-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(56, 178, 172, 0.4);
}

@media (min-width: 992px) {
    .view-details-btn,
    .select-btn,
    .add-link-btn {
        padding: 1.2rem 2.2rem;
        font-size: 1.15rem;
        margin-bottom: 1rem;
    }
    
    .view-details-btn {
        margin-bottom: 1.2rem;
    }
}

.locked-indicator {
    position: absolute;
    top: 15px;
    right: 15px;
    background-color: #e74c3c;
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(231, 76, 60, 0.3);
}

/* Presentation link styles */
.presentation-link {
    margin-top: 1rem;
    text-align: center;
}

.presentation-link-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.6rem 1.2rem;
    background-color: #38b2ac;
    color: white;
    text-decoration: none;
    border-radius: 50px;
    font-size: 0.9rem;
    gap: 8px;
    transition: all 0.3s ease;
}

.presentation-link-btn:hover {
    background-color: #319795;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(56, 178, 172, 0.3);
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 100;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    padding: 2.5rem;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
    position: relative;
}

.modal-lg {
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal h2 {
    margin-bottom: 1.5rem;
    color: var(--text-color);
    font-size: 1.8rem;
    position: relative;
    padding-bottom: 10px;
}

.modal h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50px;
    height: 3px;
    background: var(--secondary-gradient);
    border-radius: 10px;
}

.modal p {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

.modal-input {
    width: 100%;
    padding: 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid #e6e6e6;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
}

.modal-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(58, 123, 213, 0.2);
}

.modal input {
    width: 100%;
    padding: 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid #e6e6e6;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
}

.modal input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(58, 123, 213, 0.2);
}

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

.modal-buttons button {
    flex: 1;
    padding: 0.9rem 1.2rem;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

#confirmBtn, #selectTopicBtn, #saveLinkBtn {
    background: linear-gradient(to right, #27ae60, #2ecc71);
    color: white;
}

#cancelBtn, #closeDetailBtn, #cancelLinkBtn {
    background: linear-gradient(to right, #e74c3c, #c0392b);
    color: white;
}

#confirmBtn:hover, #selectTopicBtn:hover, #saveLinkBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(46, 204, 113, 0.4);
}

#cancelBtn:hover, #closeDetailBtn:hover, #cancelLinkBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.4);
}

/* Topic detail content */
.topic-detail-content {
    margin-bottom: 2rem;
    line-height: 1.8;
}

.topic-detail-content h3 {
    margin: 1.5rem 0 1rem;
    color: var(--text-color);
}

.topic-detail-content p {
    margin-bottom: 1rem;
}

.topic-detail-content ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.topic-detail-content li {
    margin-bottom: 0.5rem;
}

/* Code block styling */
.code-block {
    background-color: #f1f1f1;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    font-family: 'Courier New', Courier, monospace;
    overflow-x: auto;
    border-left: 4px solid var(--primary-color);
}

/* Animation classes */
.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

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

.slide-up {
    animation: slideUp 0.5s ease forwards;
}

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

/* Real-time update animations */
.card-updated {
    animation: highlight 1.5s ease;
}

@keyframes highlight {
    0% { box-shadow: 0 0 0 rgba(66, 153, 225, 0); }
    20% { box-shadow: 0 0 20px rgba(66, 153, 225, 0.7); }
    100% { box-shadow: var(--card-shadow); }
}

/* Real-time sync notification */
.sync-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 15px;
    border-radius: 20px;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.sync-notification-content {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.sync-notification i {
    animation: spin 1s infinite linear;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .subject-tabs {
        flex-direction: column;
    }
    
    .container {
        padding: 1rem;
    }
    
    header {
        padding: 1.5rem 1rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .modal-content {
        padding: 1.5rem;
    }
}

/* Desktop enhancements */
@media (min-width: 1024px) {
    .container {
        padding: 2rem 3rem;
        max-width: 1200px;
    }
    
    header {
        padding: 3.5rem;
        margin-bottom: 3.5rem;
    }
    
    header h1 {
        font-size: 3.5rem;
        margin-bottom: 1.8rem;
    }
    
    header .subtitle {
        font-size: 1.4rem;
    }
    
    .subject-selector {
        margin-bottom: 4rem;
    }
    
    .subject-tabs {
        gap: 3rem;
    }
    
    .subject-tab {
        padding: 1.5rem 4rem;
        font-size: 1.3rem;
        border-radius: 15px;
    }
    
    .subject-tab i {
        font-size: 1.4rem;
    }
    
    .topic-status {
        font-size: 1.2rem;
        margin-bottom: 2rem;
    }
    
    .topic-status.available::before {
        font-size: 1.8rem;
    }
    
    /* Improve spacing between topics */
    .topics-grid {
        gap: 3rem;
    }
}