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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

/* Header styles */
header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

header .logo {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Удаляем старые стили поиска из header, так как поиск теперь только на главной странице */

.auth-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.user-greeting {
    color: #667eea;
    font-weight: 600;
    margin-right: 0.5rem;
}

.auth-btn {
    text-decoration: none;
    color: #667eea;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    transition: all 0.3s ease;
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.auth-btn:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: translateY(-1px);
}

.auth-btn.logout {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
    border-color: rgba(231, 76, 60, 0.2);
}

.auth-btn.logout:hover {
    background: rgba(231, 76, 60, 0.2);
}

/* Main content */
main {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

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

/* Search section */
.search-section {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
}

.page-title {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.page-subtitle {
    color: #666;
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

.search-form {
    display: flex;
    gap: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

.search-input {
    flex: 1;
    padding: 1rem 1.5rem;
    border: 2px solid #e1e5e9;
    border-radius: 25px;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
}

.search-button {
    padding: 1rem 2rem;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.search-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Main content grid */
.main-content {
    display: grid;
    grid-template-columns: 250px 1fr 300px;
    gap: 2rem;
    align-items: start;
}

/* Subjects navigation */
.subjects {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    height: fit-content;
}

.subjects h3 {
    color: #667eea;
    margin-bottom: 1rem;
    font-size: 1.3rem;
    font-weight: 600;
}

.subjects ul {
    list-style: none;
}

.subjects li {
    margin-bottom: 0.5rem;
}

.subjects li a {
    display: block;
    padding: 0.75rem 1rem;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    text-decoration: none;
    color: #333;
}

.subjects li a:hover {
    background: rgba(102, 126, 234, 0.1);
    border-left-color: #667eea;
    transform: translateX(5px);
}

.subjects li a.active {
    background: rgba(102, 126, 234, 0.15);
    border-left-color: #667eea;
    color: #667eea;
    font-weight: 600;
}

.category-count {
    color: #999;
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

/* Questions section */
.questions {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.questions h2 {
    color: #333;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
    font-weight: 600;
}

.question {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(102, 126, 234, 0.1);
    transition: all 0.3s ease;
}

.question:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border-color: rgba(102, 126, 234, 0.3);
}

.question h4 {
    margin-bottom: 0.75rem;
}

.question h4 a {
    color: #667eea;
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 600;
    transition: color 0.3s ease;
}

.question h4 a:hover {
    color: #764ba2;
}

.question p {
    color: #666;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.question small {
    color: #999;
    font-size: 0.9rem;
    background: rgba(102, 126, 234, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
}

.question-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: #666;
}

.question-meta span {
    background: rgba(102, 126, 234, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
}

.question-meta a {
    color: #667eea;
    text-decoration: none;
}

.question-meta a:hover {
    text-decoration: underline;
}

.no-questions {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 2rem;
}

/* AI Assistant sidebar */
.ai-assistant {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    position: sticky;
    top: 100px;
    height: fit-content;
}

.ai-assistant h3 {
    margin-bottom: 1rem;
    font-size: 1.4rem;
    font-weight: 600;
}

.ai-assistant p {
    margin-bottom: 1.5rem;
    opacity: 0.9;
    line-height: 1.5;
}

.ask-ai {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.ask-ai:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

/* Question page styles */
.question-full {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 2rem;
}

.question-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid rgba(102, 126, 234, 0.1);
}

.question-header h2 {
    color: #333;
    font-size: 1.8rem;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.question-content {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 15px;
    border-left: 4px solid #667eea;
}

.question-content p {
    color: #333;
    line-height: 1.6;
    font-size: 1.1rem;
}

.question-attachments {
    margin-bottom: 2rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.question-attachments h4 {
    color: #667eea;
    margin-bottom: 0.5rem;
}

.question-attachments ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.question-attachments li {
    margin-bottom: 0.5rem;
}

.question-attachments a {
    color: #667eea;
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 5px;
    font-size: 0.9rem;
}

.question-attachments a:hover {
    background: rgba(102, 126, 234, 0.2);
}

.answers {
    margin-top: 2rem;
}

.answers h3 {
    color: #333;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid rgba(102, 126, 234, 0.1);
}

.answer {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(102, 126, 234, 0.1);
    transition: all 0.3s ease;
}

.answer:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border-color: rgba(102, 126, 234, 0.3);
}

.answer-content {
    margin-bottom: 1rem;
}

.answer-content p {
    color: #333;
    line-height: 1.6;
}

.answer-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #666;
}

.answer-meta span {
    background: rgba(102, 126, 234, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
}

.answer-attachments {
    margin-bottom: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.answer-attachments h5 {
    color: #667eea;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.answer-attachments ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.answer-attachments li {
    margin-bottom: 0.5rem;
}

.answer-attachments a {
    color: #667eea;
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 5px;
    font-size: 0.9rem;
}

.answer-attachments a:hover {
    background: rgba(102, 126, 234, 0.2);
}

.answer-rating {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.rate-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #e1e5e9;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 600;
}

.rate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.rate-btn.good {
    border-color: #27ae60;
    color: #27ae60;
}

.rate-btn.good:hover {
    background: #27ae60;
    color: white;
}

.rate-btn.bad {
    border-color: #e74c3c;
    color: #e74c3c;
}

.rate-btn.bad:hover {
    background: #e74c3c;
    color: white;
}

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

.no-answers {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 2rem;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 15px;
}

/* Category page styles */
.category-page {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.category-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid rgba(102, 126, 234, 0.1);
}

.category-header h1 {
    color: #667eea;
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.category-count {
    color: #666;
    font-size: 1.1rem;
}

.tasks-list {
    margin-bottom: 2rem;
}

.task-item {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(102, 126, 234, 0.1);
    transition: all 0.3s ease;
}

.task-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border-color: rgba(102, 126, 234, 0.3);
}

.task-header h3 {
    margin-bottom: 1rem;
}

.task-header h3 a {
    color: #667eea;
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 600;
}

.task-header h3 a:hover {
    color: #764ba2;
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.9rem;
    color: #666;
}

.task-meta span {
    background: rgba(102, 126, 234, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
}

.no-tasks {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 2rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(102, 126, 234, 0.1);
}

.pagination a {
    padding: 0.75rem 1.5rem;
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    text-decoration: none;
    border-radius: 25px;
    transition: all 0.3s ease;
    font-weight: 600;
}

.pagination a:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
}

.pagination .current {
    padding: 0.75rem 1.5rem;
    background: rgba(102, 126, 234, 0.2);
    color: #667eea;
    border-radius: 25px;
    font-weight: 600;
}

/* Search results */
.search-results {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.search-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid rgba(102, 126, 234, 0.1);
}

.search-header h1 {
    color: #667eea;
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.search-query {
    color: #666;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.results-count {
    color: #999;
    font-size: 1rem;
}

.search-results-list {
    margin-bottom: 2rem;
}

.search-result-item {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(102, 126, 234, 0.1);
    transition: all 0.3s ease;
}

.search-result-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border-color: rgba(102, 126, 234, 0.3);
}

.result-header h3 {
    margin-bottom: 1rem;
}

.result-header h3 a {
    color: #667eea;
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 600;
}

.result-header h3 a:hover {
    color: #764ba2;
}

.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #666;
}

.result-meta span {
    background: rgba(102, 126, 234, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
}

.result-meta a {
    color: #667eea;
    text-decoration: none;
}

.result-meta a:hover {
    text-decoration: underline;
}

.result-excerpt {
    color: #666;
    line-height: 1.6;
    font-style: italic;
    padding: 1rem;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 10px;
    border-left: 3px solid #667eea;
}

.no-results {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 2rem;
}

/* Responsive design */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 200px 1fr 250px;
        gap: 1.5rem;
    }
    
    main {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .main-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    header {
        padding: 1rem;
    }
    
    .search-form {
        flex-direction: column;
        gap: 1rem;
    }
    
    .auth-links {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .auth-links .social-auth {
        display: flex;
        gap: 0.5rem;
        margin-top: 0.5rem;
    }
    
    .ai-assistant {
        position: static;
    }
    
    .subjects {
        order: 2;
    }
    
    .questions {
        order: 1;
    }
    
    .ai-assistant {
        order: 3;
    }
    
    .question-meta, .task-meta, .result-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .page-title {
        font-size: 2rem;
    }
    
    .page-subtitle {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    main {
        padding: 1rem;
    }
    
    .questions, .subjects, .ai-assistant, .category-page, .search-results {
        padding: 1rem;
    }
    
    header .logo {
        font-size: 1.5rem;
    }
    
    .page-title {
        font-size: 1.8rem;
    }
    
    .category-header h1, .search-header h1 {
        font-size: 2rem;
    }
    
    .subjects ul {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 0.5rem;
    }
    
    .auth-links .social-auth {
        flex-direction: row;
        gap: 0.25rem;
        width: 100%;
        justify-content: center;
    }
    
    .auth-links .social-btn {
        min-width: 50px;
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
}

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

.question, .task-item, .search-result-item {
    animation: fadeInUp 0.6s ease forwards;
}

.question:nth-child(1), .task-item:nth-child(1), .search-result-item:nth-child(1) { animation-delay: 0.1s; }
.question:nth-child(2), .task-item:nth-child(2), .search-result-item:nth-child(2) { animation-delay: 0.2s; }
.question:nth-child(3), .task-item:nth-child(3), .search-result-item:nth-child(3) { animation-delay: 0.3s; }
.question:nth-child(4), .task-item:nth-child(4), .search-result-item:nth-child(4) { animation-delay: 0.4s; }

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #667eea;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.5);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.7);
}

/* Tooltip styles */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
    z-index: 1000;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: tooltipFadeIn 0.2s ease;
}

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

/* Loading animation for questions */
.question.loading, .task-item.loading, .search-result-item.loading {
    position: relative;
    overflow: hidden;
}

.question.loading::before, .task-item.loading::before, .search-result-item.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: loadingShimmer 1.5s infinite;
}

@keyframes loadingShimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}
