/* Learning Page Styles */

/* User Profile Mini */
.user-profile-mini {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-profile-mini img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
}

.user-profile-mini span {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-profile-mini .points-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    background: linear-gradient(to right, #ffd700, #ffcc00);
    color: #333;
    padding: 3px 8px;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: bold;
}

.user-profile-mini .points-badge i {
    color: #ff9900;
}

/* Hero Section */
.learning-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 40px 0;
    margin-bottom: 30px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(240, 240, 240, 0.8) 100%);
    border-radius: 10px;
    box-shadow: var(--box-shadow);
    overflow: hidden;
}

.learning-hero .hero-content {
    flex: 1;
    padding: 0 30px;
}

.learning-hero .hero-content h2 {
    font-size: 2.5rem;
    margin-bottom: 15px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.learning-hero .hero-content p {
    font-size: 1.1rem;
    margin-bottom: 25px;
    color: var(--dark-color);
    max-width: 500px;
}

.learning-hero .hero-image {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.learning-hero .hero-image img {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
}

/* Learning Section */
.learning-section {
    background-color: white;
    border-radius: 10px;
    box-shadow: var(--box-shadow);
    padding: 30px;
    margin-bottom: 30px;
}

.learning-section h2 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.search-and-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 15px;
}

.search-container {
    display: flex;
    flex: 1;
    min-width: 250px;
}

.search-container input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 5px 0 0 5px;
    font-size: 0.9rem;
}

.search-container button {
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 0 5px 5px 0;
    cursor: pointer;
}

.exercise-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.filter-btn {
    padding: 8px 15px;
    background-color: #f0f0f0;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    background-color: #e0e0e0;
}

.filter-btn.active {
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
}

/* Exercises Container */
.exercises-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.exercise-card {
    background-color: white;
    border-radius: 1px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.exercise-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.exercise-card-header {
    padding: 15px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
}

.exercise-card-header h3 {
    margin: 0;
    font-size: 1.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.exercise-card-body {
    padding: 15px;
    flex: 1;
}

.exercise-card-body p {
    margin: 0 0 10px;
    color: var(--dark-color);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.9rem;
}

.exercise-card-footer {
    padding: 10px 15px;
    background-color: #f9f9f9;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.exercise-card-footer .category {
    background-color: #e0e0e0;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
}

.exercise-card-footer .solutions-count {
    display: flex;
    align-items: center;
    gap: 5px;
}

.exercise-card-footer .solutions-count i {
    color: var(--primary-color);
}

.exercise-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-bottom: 1px solid #eee;
}

/* Leaderboard Section */
.leaderboard-section {
    background-color: white;
    border-radius: 10px;
    box-shadow: var(--box-shadow);
    padding: 30px;
    margin-bottom: 30px;
}

.leaderboard-section h2 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.leaderboard-container {
    overflow-x: auto;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.leaderboard-table th {
    background-color: #f5f5f5;
    font-weight: 600;
    color: var(--dark-color);
}

.leaderboard-table tr:hover {
    background-color: #f9f9f9;
}

.leaderboard-table .rank {
    font-weight: 700;
    text-align: center;
    width: 60px;
}

.leaderboard-table .rank-1 {
    color: gold;
}

.leaderboard-table .rank-2 {
    color: silver;
}

.leaderboard-table .rank-3 {
    color: #cd7f32; /* bronze */
}

.leaderboard-table .user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.leaderboard-table .user img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
}

.leaderboard-table .score {
    font-weight: 600;
    color: var(--primary-color);
}

/* Modal Styles */
.modal-large {
    width: 90%;
    max-width: 1400px;
    height: 90vh;
    max-height: 900px;
    margin: 5vh auto;
}

.modal-large .modal-content {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 25px;
    margin: 0 auto;
    max-height: 100%;
}

.modal-large #exerciseDetailContent {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    background-color: #f9f9f9;
    border-radius: 8px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
    margin: 0;
    height: calc(100% - 50px);
}

#exerciseDetailContent h3 {
    color: var(--primary-color);
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

#exerciseDetailContent .exercise-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    color: #666;
    font-size: 0.9rem;
}

#exerciseDetailContent .exercise-content {
    line-height: 1.6;
    margin-bottom: 20px;
}

.image-preview {
    margin-top: 10px;
    max-width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.image-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 5px;
    object-fit: contain;
}

/* Exercise Detail Styles */
.exercise-detail {
    padding: 20px 0;
}

.exercise-detail-header {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eaeaea;
}

.exercise-detail h2 {
    margin-bottom: 15px;
    color: var(--primary-color);
    font-size: 1.8rem;
}

.exercise-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 15px;
}

.exercise-detail-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.exercise-detail-content {
    margin-bottom: 30px;
    line-height: 1.6;
    padding: 25px;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    overflow-x: auto;
}

.exercise-detail-image {
    max-width: 100%;
    max-height: 400px;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.solutions-section {
    margin-top: 30px;
    padding: 20px;
    background-color: #f5f7fa;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
}

.solutions-section h3 {
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary-color);
    color: var(--primary-color);
    font-size: 1.4rem;
}

.solution-card {
    background-color: #f9f9f9;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    border: 1px solid #eaeaea;
    max-width: 100%;
}

.solution-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.solution-author {
    display: flex;
    align-items: center;
    gap: 10px;
}

.solution-author img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
}

.solution-meta {
    font-size: 0.85rem;
    color: #666;
}

.solution-content {
    margin-bottom: 10px;
    line-height: 1.2;
    padding: 8px 12px;
    background-color: #ffffff;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    overflow-x: auto;
    min-height: auto;
}

.solution-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 6px;
    margin: 8px 0 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    display: block;
}

.solution-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    padding-top: 5px;
    border-top: 1px solid #eee;
}

.solution-rating {
    display: flex;
    align-items: center;
    gap: 3px;
}

.solution-rating .stars {
    color: gold;
}

.solution-actions {
    display: flex;
    gap: 8px;
}

.solution-actions button {
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background-color 0.3s ease;
}

.rate-btn {
    background-color: #f0f0f0;
    color: var(--dark-color);
}

.rate-btn:hover {
    background-color: #e0e0e0;
}

.submit-solution-btn {
    margin-top: 15px;
    margin-bottom: 15px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.submit-solution-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* Rating System */
.rating {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
}

.rating input {
    display: none;
}

.rating label {
    cursor: pointer;
    width: 30px;
    height: 30px;
    margin-right: 5px;
    position: relative;
    background: #f0f0f0;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.rating label:before {
    content: '\f005';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    font-size: 1.2rem;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ccc;
}

.rating input:checked ~ label,
.rating input:checked ~ label ~ label {
    background: var(--primary-color);
}

.rating input:checked ~ label:before,
.rating input:checked ~ label ~ label:before {
    color: white;
}

.rating label:hover,
.rating label:hover ~ label {
    background: var(--secondary-color);
}

.rating label:hover:before,
.rating label:hover ~ label:before {
    color: white;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .learning-hero {
        flex-direction: column;
        text-align: center;
    }

    .learning-hero .hero-content {
        padding: 20px;
    }

    .learning-hero .hero-content p {
        margin: 0 auto 20px;
    }

    .search-and-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .exercise-filters {
        justify-content: center;
    }

    .exercises-container {
        grid-template-columns: 1fr;
    }

    .modal-large {
        width: 95%;
    }
}

/* No Exercises Message */
.no-exercises {
    text-align: center;
    padding: 30px;
    color: #666;
    font-style: italic;
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px;
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: var(--primary-color);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Badge for New Solutions */
.new-badge {
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 5px;
}

/* Points Badge */
.points-badge {
    background-color: #f0f0f0;
    color: var(--primary-color);
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.points-badge i {
    font-size: 0.7rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-state i {
    font-size: 3rem;
    color: #ddd;
    margin-bottom: 15px;
}

.empty-state p {
    margin-bottom: 20px;
}

/* Three Column Layout */
.learning-content-wrapper {
    display: grid;
    grid-template-columns: 250px 1fr 300px;
    gap: 20px;
    margin-bottom: 30px;
}

/* Left Sidebar - Subject List */
.subjects-sidebar {
    background-color: white;
    border-radius: 10px;
    box-shadow: var(--box-shadow);
    padding: 20px;
    height: fit-content;
}

.subjects-sidebar h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    font-size: 1.2rem;
}

.subject-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.subject-item {
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.subject-item:hover {
    background-color: #f5f5f5;
}

.subject-item.active {
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
}

.subject-item i {
    width: 20px;
    text-align: center;
}

/* Right Sidebar - Leaderboard */
.leaderboard-sidebar {
    height: fit-content;
}

.leaderboard-sidebar .leaderboard-section {
    margin-bottom: 0;
}

/* Center Column - Learning Section */
.learning-content-wrapper .learning-section {
    margin-bottom: 0;
}

/* Chat Mini Button */
.chat-mini-button {
    position: fixed;
    bottom: 0;
    right: 340px; /* Đặt nút cách xa chat panel */
    width: 60px;
    height: 60px;
    border-radius: 50% 50% 0 0;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transition: all 0.3s ease;
}

.chat-mini-button:hover {
    transform: scale(1.05);
}

.chat-mini-button i {
    font-size: 1.5rem;
}

.chat-notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    background-color: #ff3b30;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 5px;
}

/* Chat Mini Panel */
.chat-mini-panel {
    position: fixed;
    right: 20px;
    bottom: 0;
    width: 300px;
    max-height: 400px;
    background-color: white;
    border-radius: 10px 10px 0 0;
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-mini-header {
    padding: 15px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-mini-header-actions {
    display: flex;
    gap: 10px;
}

.chat-mini-create-room {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
}

.chat-mini-header h3 {
    margin: 0;
    font-size: 1rem;
}

.chat-mini-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1rem;
}

.chat-mini-list {
    overflow-y: auto;
    max-height: 350px;
}

.chat-mini-list .chat-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.chat-mini-list .chat-item:hover {
    background-color: #f5f5f5;
}

.chat-mini-list .chat-item-avatar {
    position: relative;
    margin-right: 10px;
}

.chat-mini-list .chat-item-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-mini-list .chat-item-status {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
}

.chat-mini-list .chat-item-status.online {
    background-color: #4cd964;
}

.chat-mini-list .chat-item-status.offline {
    background-color: #8e8e93;
}

.chat-mini-list .chat-item-info {
    flex: 1;
}

.chat-mini-list .chat-item-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.chat-mini-list .chat-item-last-message {
    font-size: 0.8rem;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.chat-mini-list .chat-item-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

.chat-mini-list .chat-item-time {
    font-size: 0.7rem;
    color: #999;
}

.chat-mini-list .chat-item-badge {
    background-color: var(--primary-color);
    color: white;
    font-size: 0.7rem;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 5px;
}

/* Chat Mini Window */
/* Chat Mini Windows Container */
.chat-mini-windows-container {
    position: fixed;
    bottom: 0;
    right: 380px;
    z-index: 1000;
    display: flex;
    flex-direction: row;
    gap: 10px;
    max-width: calc(100vw - 400px);
    overflow-x: auto;
    padding-bottom: 0;
}

/* Định nghĩa này đã được di chuyển xuống dưới */

.chat-mini-window-header {
    padding: 10px 15px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-mini-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-mini-user-info img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-mini-window-actions {
    display: flex;
    gap: 5px;
}

.chat-mini-window-actions .change-bg-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
    width: 24px;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.chat-mini-window-actions .change-bg-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.bg-image-input {
    display: none;
}

.chat-mini-window-actions button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
    width: 24px;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.chat-mini-window-actions button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.chat-mini-window-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background-color: #f5f5f5;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
}

.chat-mini-window-messages::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.7);
    z-index: -1;
    pointer-events: none;
}

.chat-mini-window-input {
    display: flex;
    padding: 10px;
    border-top: 1px solid #eee;
    flex-wrap: wrap;
}

.chat-mini-window-icons {
    display: flex;
    width: 100%;
    margin-bottom: 8px;
    gap: 5px;
}

.chat-mini-icon-btn {
    background: none;
    border: none;
    color: #666;
    font-size: 1rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.chat-mini-icon-btn:hover {
    background-color: #f0f0f0;
    color: var(--primary-color);
}

.chat-mini-window-input input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 0.9rem;
}

.chat-mini-window-input button.chat-mini-send-btn {
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin-left: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Message Styles */
.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    margin-bottom: 10px;
    position: relative;
}

.message.outgoing {
    align-self: flex-end;
    margin-left: auto;
}

.message.incoming {
    align-self: flex-start;
    margin-right: auto;
}

.message-content {
    padding: 8px 12px;
    border-radius: 18px;
    font-size: 0.9rem;
    word-break: break-word;
}

.message.outgoing .message-content {
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
    border-bottom-right-radius: 4px;
}

.message.incoming .message-content {
    background-color: white;
    color: var(--dark-color);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 0.65rem;
    color: #aaa;
    margin-top: 2px;
    align-self: flex-end;
    opacity: 0;
    transition: opacity 0.2s ease;
    position: absolute;
    right: -65px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(240, 240, 240, 0.8);
    padding: 2px 5px;
    border-radius: 3px;
    white-space: nowrap;
    z-index: 10;
}

.message-bubble:hover .message-time {
    opacity: 1;
}

.message.outgoing .message-time {
    right: auto;
    left: -65px;
}

.message.incoming .message-time {
    right: -65px;
    left: auto;
}

/* Responsive Styles for Three Column Layout */
@media (max-width: 1200px) {
    .learning-content-wrapper {
        grid-template-columns: 200px 1fr 250px;
    }
}

@media (max-width: 992px) {
    .learning-content-wrapper {
        grid-template-columns: 1fr;
    }
    
    .subjects-sidebar,
    .leaderboard-sidebar {
        display: none;
    }
}

/* Mini Chat Styles */
.chat-mini-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    display: none;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chat-mini-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

.chat-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #ff3b30;
    color: white;
    font-size: 12px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: none;
    justify-content: center;
    align-items: center;
    font-weight: bold;
}

.chat-mini-panel {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 300px;
    height: 400px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    z-index: 999;
    overflow: hidden;
}

.chat-mini-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
}

.chat-mini-header h3 {
    margin: 0;
    font-size: 16px;
}

.chat-mini-close {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
}

.chat-mini-search {
    padding: 10px;
    background-color: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
}

.chat-mini-search i {
    color: #888;
    margin-right: 8px;
}

.chat-mini-search input {
    border: none;
    background: transparent;
    width: 100%;
    padding: 5px;
    outline: none;
    font-size: 14px;
}

.chat-mini-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.chat-user {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    position: relative;
}

.chat-user:hover {
    background-color: #f5f5f5;
}

.chat-user.active {
    background-color: #f0f0f0;
}

/* Chat Settings Modal */
#chatSettingsModal {
    display: none;
    position: fixed;
    z-index: 1100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    width: 900px;
    max-width: 90%;
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
}

.chat-settings-container {
    margin-top: 20px;
}

/* Room creation styles */
.room-members-container {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
    margin-top: 10px;
}

.room-member-item {
    display: flex;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid #eee;
}

.room-member-item:last-child {
    border-bottom: none;
}

.room-member-item img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 10px;
}

.room-member-item .member-name {
    flex-grow: 1;
}

.room-member-item .member-checkbox {
    margin-left: 10px;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group h3 {
    margin-bottom: 10px;
    font-size: 16px;
    color: var(--dark-color);
}

.background-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.background-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.bg-preview {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    margin-bottom: 5px;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.background-option.selected .bg-preview {
    border-color: var(--primary-color);
}

.background-option span {
    font-size: 12px;
    color: var(--dark-color);
}

.default-bg {
    background-color: #f5f5f5;
}

.custom-bg-upload {
    background-color: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-bg-upload i {
    font-size: 24px;
    color: #6c757d;
}

.bg-preview-container {
    margin-top: 10px;
    max-width: 100%;
    height: 120px;
    border-radius: 8px;
    overflow: hidden;
    background-color: #f8f9fa;
    border: 1px dashed #ced4da;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bg-preview-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.gradient1-bg {
    background: linear-gradient(135deg, #f5f7fa, #c3cfe2);
}

.gradient2-bg {
    background: linear-gradient(135deg, #e0f7fa, #b2ebf2);
}

.pattern1-bg {
    background-color: #f5f5f5;
    background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23dddddd' fill-opacity='0.4' fill-rule='evenodd'%3E%3Ccircle cx='3' cy='3' r='3'/%3E%3Ccircle cx='13' cy='13' r='3'/%3E%3C/g%3E%3C/svg%3E");
}

.btn {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--secondary-color);
}

.btn-danger {
    background-color: #ff3b30;
    color: white;
}

.btn-danger:hover {
    background-color: #d63530;
}

#saveSettingsBtn {
    display: block;
    margin: 20px auto 0;
    width: 100%;
}

/* Chat background options */
.chat-mini-window.bg-default .chat-mini-window-messages {
    background-color: #f5f5f5;
}

.chat-mini-window.bg-gradient1 .chat-mini-window-messages {
    background: linear-gradient(135deg, #f5f7fa, #c3cfe2);
}

.chat-mini-window.bg-gradient2 .chat-mini-window-messages {
    background: linear-gradient(135deg, #e0f7fa, #b2ebf2);
}

.chat-mini-window.bg-pattern1 .chat-mini-window-messages {
    background-color: #f5f5f5;
    background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23dddddd' fill-opacity='0.4' fill-rule='evenodd'%3E%3Ccircle cx='3' cy='3' r='3'/%3E%3Ccircle cx='13' cy='13' r='3'/%3E%3C/g%3E%3C/svg%3E");
}

.chat-mini-window.bg-custom .chat-mini-window-messages {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.chat-user img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 10px;
}

.chat-user-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-user-name {
    font-weight: 600;
    font-size: 14px;
}

.profile-link {
    transition: all 0.2s ease;
}

.profile-link:hover {
    color: #ff5e62;
    text-decoration: underline;
}

img.profile-link:hover {
    transform: scale(1.05);
    border: 2px solid #ff5e62;
    box-shadow: 0 0 5px rgba(255, 94, 98, 0.5);
}

.chat-user-status {
    font-size: 12px;
    color: #999;
}

.chat-user-status.online {
    color: #4CAF50;
}

.unread-badge {
    min-width: 18px;
    height: 18px;
    background-color: #ff3b30;
    border-radius: 10px;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 4px;
}

.chat-mini-window {
    position: relative;
    width: 320px;
    height: 500px;
    background-color: white;
    border-radius: 10px 10px 0 0;
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    z-index: 998;
    overflow: hidden;
    margin-left: 10px;
}

.chat-mini-window.open {
    display: flex;
}

.chat-mini-window-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
}

.chat-mini-window-header .chat-user-info {
    display: flex;
    align-items: center;
    flex-direction: row;
}

.chat-mini-window-header .chat-user-info img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 10px;
}

.chat-mini-window-actions {
    display: flex;
    gap: 5px;
}

.chat-mini-window-minimize,
.chat-mini-window-close {
    background: none;
    border: none;
    color: white;
    font-size: 14px;
    cursor: pointer;
}

.chat-mini-window-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background-color: #f5f5f5;
    display: flex;
    flex-direction: column;
}

.chat-message {
    max-width: 80%;
    margin-bottom: 4px;
    display: flex;
    flex-direction: column;
}

.chat-message.sent {
    align-self: flex-end;
}

.chat-message.received {
    align-self: flex-start;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.chat-message.message-continuation {
    margin-top: 1px;
}

.chat-message.message-continuation.received .message-content {
    border-top-left-radius: 10px;
}

.chat-message.message-continuation.sent .message-content {
    border-top-right-radius: 10px;
}

.sender-name {
    font-size: 13px;
    color: #444;
    margin-bottom: 4px;
    font-weight: 600;
    display: block;
    width: 100%;
}

.sender-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: default; /* Thay đổi từ pointer thành default */
    transition: all 0.2s ease;
    margin-right: 8px;
}

.message-content {
    padding: 8px 12px;
    border-radius: 18px;
    font-size: 14px;
    word-break: break-word;
}

.chat-message.sent .message-content {
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.received .message-content {
    background-color: white;
    color: var(--dark-color);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 0.65rem;
    color: #aaa;
    margin-top: 2px;
    align-self: flex-end;
    opacity: 0;
    transition: opacity 0.2s ease;
    position: absolute;
    right: -65px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(240, 240, 240, 0.8);
    padding: 2px 5px;
    border-radius: 3px;
    white-space: nowrap;
    z-index: 10;
}

.chat-message:hover .message-time,
.message-bubble:hover .message-time {
    opacity: 1;
}

/* Message actions */
.message-actions {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: -25px;
    display: none;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.sent .message-actions {
    left: -25px;
    right: auto;
}

.chat-message:hover .message-actions {
    display: block;
    opacity: 1;
}

.recall-button {
    background-color: #f0f2f5;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #65676b;
    transition: background-color 0.2s;
    font-size: 10px;
}

.recall-button:hover {
    background-color: #e4e6eb;
    color: #1877f2;
}

/* Recalled message */
.message-recalled {
    font-style: italic;
    color: #65676b;
    display: inline-block;
    padding: 8px 12px;
    border-radius: 18px;
    margin-bottom: 4px;
}

.sent .message-recalled {
    background-color: rgba(0, 132, 255, 0.3);
    color: rgba(255, 255, 255, 0.7);
    border-top-right-radius: 4px;
}

.received .message-recalled {
    background-color: rgba(228, 230, 235, 0.5);
    color: #65676b;
    border-top-left-radius: 4px;
}

.date-separator {
    text-align: center;
    margin: 6px 0;
    font-size: 11px;
    color: #999;
    position: relative;
}

.date-separator:before,
.date-separator:after {
    content: '';
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background-color: #ddd;
}

.date-separator:before {
    left: 0;
}

.date-separator:after {
    right: 0;
}

.chat-mini-window-input {
    display: flex;
    padding: 10px;
    border-top: 1px solid #eee;
}

.chat-mini-window-input input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
}

.chat-mini-window-input button {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 18px;
    margin-left: 10px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.chat-mini-window-input button:hover {
    color: var(--secondary-color);
}

.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

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

.error-message {
    text-align: center;
    color: #ff3b30;
    padding: 20px;
}
#chatMiniButton,
#chatMiniPanel,
#chatMiniWindowsContainer,
#createChatRoomModal,
#chatSettingsModal {
    display: none !important;
}
@media (max-width: 768px) {
  /* Cho layout chính 1 cột */
  .learning-content-wrapper {
    grid-template-columns: 1fr;
  }

  /* Cho phép tiêu đề bài tập xuống dòng thay vì bị cắt */
  .exercise-card-header h3 {
    white-space: normal;
  }

  /* Chỉnh text hero cho dễ đọc */
  .learning-hero .hero-content h2 {
    font-size: 1.8rem;
  }
  .learning-hero .hero-content p {
    font-size: 1rem;
  }
}
.modal-large {
    width: 90%;
    max-width: 1400px;
    height: 90vh;
    max-height: 900px;
    margin: 5vh auto;
}
@media (max-width: 768px) {
  /* Ẩn modal không cần thiết trên mobile */
  #chatSettingsModal,
  #createChatRoomModal,
  #rateSolutionModal {
    display: none !important;
  }

  /* Biến modal chính thành dạng full-screen */
  .modal-content,
  .modal-large {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    margin: 0 !important;
    padding: 10px !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  /* Nội dung modal hiển thị thoáng */
  .modal-large #exerciseDetailContent,
  .solution-card,
  .solution-content {
    padding: 10px;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: normal !important;
    word-break: break-word;
    overflow-wrap: break-word;
    overflow-x: hidden;
  }

  /* Nút đóng modal to và dễ bấm hơn */
  .modal-content .close {
    font-size: 24px;
    top: 10px;
    right: 15px;
  }
}
@media (max-width: 768px) {
  header {
    padding: 0 8px;
    height: 50px;               /* Chiều cao tối đa */
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  /* Logo nhỏ gọn */
  header .logo h1 {
    font-size: 1rem;
    margin: 0;
    line-height: 1;
  }

  /* Menu nav thành thanh icon ngang */
  header nav ul {
    display: flex;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  header nav ul li a {
    padding: 0;
    font-size: 1.2rem;          /* Chỉ giữ icon */
  }

  /* Ẩn text, chỉ giữ icon */
  header nav ul li a span {
    display: none !important;
  }

  /* Nút đăng nhập/đăng ký nhỏ lại */
  .auth-buttons {
    display: flex;
    gap: 5px;
  }

  .auth-buttons .btn {
    padding: 2px 6px;
    font-size: 0.75rem;
  }
}
/* Thu nhỏ icon, ảnh, văn bản, nút khi mobile */
@media (max-width: 768px) {
    /* Icon nhỏ hơn */
    i, .fas, .far, .fab {
        font-size: 0.85rem !important;
    }

    /* Ảnh nhỏ hơn */
    img {
        max-width: 80%;
        height: auto;
    }

    /* Văn bản nhỏ hơn */
    body, p, span, a, li, button, input, textarea {
        font-size: 0.85rem !important;
    }

    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.2rem; }
    h3 { font-size: 1rem; }

    /* Nút gọn lại */
    .btn, button {
        padding: 6px 12px;
        font-size: 0.8rem !important;
    }

    /* Các badge nhỏ lại */
    .points-badge, .filter-btn, .category {
        font-size: 0.75rem !important;
        padding: 3px 6px;
    }

    /* Ảnh trong card gọn hơn */
    .exercise-image {
        height: 100px;
    }
}




