/* General Resets and Body Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: url('https://images.unsplash.com/photo-1492496913980-501348b61469?q=80&w=1887&auto=format&fit=crop') no-repeat center center/cover;
    min-height: 100vh;
    color: #f8f9fa;
    position: relative;
    display: flex;
}

body::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: -1;
}

/* Dashboard Layout */
.dashboard-layout {
    display: flex;
    width: 100%;
    height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
    width: 260px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    padding: 20px;
    flex-shrink: 0;
    transition: width 0.3s ease;
}

.sidebar-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 10px 0;
}

.sidebar-header .logo {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
}

.sidebar-header .logo i {
    margin-right: 15px;
    color: #4CAF50;
}

.sidebar-nav {
    list-style-type: none;
    flex-grow: 1;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    padding: 15px;
    margin-bottom: 8px;
    color: #e0e0e0;
    text-decoration: none;
    border-radius: 8px;
    transition: background-color 0.3s, color 0.3s;
    font-weight: 500;
}

.sidebar-nav li a i {
    width: 20px;
    margin-right: 20px;
    font-size: 1.1rem;
}

.sidebar-nav li a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-nav li a.active {
    background-color: #4CAF50;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.sidebar-footer {
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    padding: 30px;
    overflow-y: auto;
    /* FIX: Prevent horizontal scroll on the main container */
    overflow-x: hidden;
    height: 100vh;
}

.main-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.main-header-bar h2 {
    font-size: 2rem;
    font-weight: 600;
}

/* User Menu Styling */
.user-menu {
    display: flex;
    align-items: center;
    gap: 15px;
}

#user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 15px;
    border-radius: 50px;
}

.user-menu .username {
    font-weight: 600;
}

.user-menu .logout-btn {
    background: none;
    border: none;
    color: #ffcccc;
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.3s;
}

.user-menu .logout-btn:hover {
    color: #f44336;
}

#guest-menu {
    display: flex;
    gap: 10px;
}

.user-menu .btn {
    padding: 10px 22px;
    font-size: 0.9em;
    font-weight: 700;
    border-radius: 50px;
    border: none;
}

.user-menu .btn-login {
    background: rgba(255, 255, 255, 0.2);
    color: #f0f0f0;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.user-menu .btn-login:hover {
    background: rgba(255, 255, 255, 0.3);
    color: white !important;
}

.user-menu .btn-register {
    background: #4CAF50;
    color: white;
}

.user-menu .btn-register:hover {
    background: #55b758;
}

/* Content Sections & Cards */
.content-section {
    display: none;
}

.content-section.active {
    display: block;
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Universal Card Style */
.card {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#guest-welcome-message.card,
.stats-grid {
    margin-bottom: 30px;
}

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

.card p {
    margin-bottom: 20px;
    color: #dcdcdc;
    line-height: 1.6;
    /* FIX: Add word wrap for paragraphs inside cards */
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.card a {
    color: #a5d6a7;
    font-weight: bold;
    text-decoration: none;
}

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

/* Content Grid for Spacing */
.content-grid {
    display: grid;
    gap: 25px;
    grid-template-columns: 1fr;
}

.content-grid.two-column {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.stats-grid {
    display: grid;
    gap: 25px;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.stat-card {
    text-align: center;
}

.stat-card h3 {
    font-size: 2.5rem;
    color: #4CAF50;
    margin-bottom: 5px;
}

.stat-card p {
    color: #ccc;
    font-size: 0.9rem;
    margin-bottom: 0;
}

.course-card {
    display: flex;
    flex-direction: column;
}

.course-content {
    flex-grow: 1;
}

.course-card h3 {
    color: #e8f5e9;
    margin-bottom: 10px;
}

.course-action {
    margin-top: auto;
    padding-top: 15px;
    text-align: center;
}

.course-login-prompt {
    font-size: 0.9em;
    color: #e0e0e0;
    margin-bottom: 0 !important;
}

/* Forum Styles */
.forum-controls {
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.login-prompt-card {
    text-align: center;
    padding: 20px !important;
    width: 100%;
    /* Make it full width */
}

.login-prompt-card p {
    margin-bottom: 0;
}

.forum-post .post-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.forum-post .avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #2980b9;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.forum-post .avatar.color-1 {
    background-color: #1abc9c;
}

.forum-post .avatar.color-2 {
    background-color: #2ecc71;
}

.forum-post .avatar.color-3 {
    background-color: #3498db;
}

.forum-post .avatar.color-4 {
    background-color: #9b59b6;
}

.forum-post .avatar.color-5 {
    background-color: #f1c40f;
}

.forum-post .avatar.color-6 {
    background-color: #e67e22;
}

.forum-post .avatar.color-7 {
    background-color: #e74c3c;
}

.post-body-content {
    margin-top: 10px;
    margin-bottom: 15px;
}

.post-body-content h3 {
    color: #e8f5e9;
    margin-bottom: 10px;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* THÊM MỚI: Định dạng cho nội dung bài đăng và các nút Xem thêm/Ẩn đi */
.post-content-container {
    color: #dcdcdc;
    line-height: 1.6;
    margin: 0;
    /* Các thuộc tính này đảm bảo văn bản dài không có dấu cách sẽ được ngắt dòng */
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-all;
    white-space: pre-wrap;
    /* Tôn trọng các ký tự xuống dòng mà người dùng nhập */
}

.expand-link {
    color: #a5d6a7;
    font-weight: bold;
    cursor: pointer;
    text-decoration: none;
    margin-left: 5px;
    display: inline-block;
    /* Để tránh ngắt dòng không mong muốn */
}

.expand-link:hover {
    text-decoration: underline;
}


.forum-post .post-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    /* Allow buttons to wrap on small screens */
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 15px;
}

.vote-btn {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ccc;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.vote-btn:hover:not(:disabled) {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}

.vote-btn.liked {
    background-color: #2980b9;
    border-color: #3498db;
    color: white;
}

.vote-btn.disliked {
    background-color: #c0392b;
    border-color: #e74c3c;
    color: white;
}

.post-actions .btn-discuss {
    margin-left: auto;
    /* Push discuss button to the right */
}

#forum-posts-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 25px;
}

#forum-posts-container .forum-post {
    width: 100%;
}

/* --- START: UPDATED COMMENT STYLES --- */
.comments-section {
    padding: 20px;
    margin: 20px -25px -25px -25px;
    /* Extend to card edges */
    background-color: rgba(0, 0, 0, 0.25);
    border-radius: 0 0 15px 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: none;
    /* Hidden by default */
    animation: fadeInCommentSection 0.5s ease-out;
}

@keyframes fadeInCommentSection {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.comment-form {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    align-items: flex-start;
}

.comment-form .avatar {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
    margin-top: 5px;
    /* Align with textarea */
}

.comment-form .comment-input-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.comment-form textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-size: 1rem;
    background-color: rgba(255, 255, 255, 0.1);
    /* Glassy background */
    color: white;
    /* Light text color */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 50px;
    height: 50px;
    resize: vertical;
    transition: height 0.2s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.comment-form textarea::placeholder {
    color: rgba(255, 255, 255, 0.5);
    /* Lighter placeholder */
}

.comment-form textarea:focus {
    height: 80px;
    outline: none;
    border-color: #4CAF50;
    /* Highlight on focus */
    background-color: rgba(255, 255, 255, 0.15);
}

.comment-form .btn {
    align-self: flex-end;
    /* Align button to the right */
}

.comment-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.comment-item {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.comment-item .avatar {
    width: 35px;
    height: 35px;
    font-size: 1rem;
}

.comment-body {
    flex-grow: 1;
    background-color: rgba(255, 255, 255, 0.05);
    /* Lighter than section bg */
    padding: 12px 15px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    color: #ccc;
    font-size: 0.9em;
}

.comment-header .user-name {
    font-weight: 600;
    color: #a5d6a7;
    /* Highlight user name */
}

.comment-content {
    color: #dcdcdc;
    line-height: 1.5;
    margin: 0;
    /* Override default p margin */
    /* FIX: Add word wrap for long comments */
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    /* More aggressive for unbreakable strings */
}

/* --- END: UPDATED COMMENT STYLES --- */


/* CSS cho bộ chọn vị trí */
.location-changer {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 25px;
    padding: 15px 20px;
    align-items: center;
}

.select-group {
    flex: 1;
    min-width: 200px;
}

.location-select {
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 8px;
    padding: 12px 15px;
    font-size: 1em;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

.location-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: rgba(0, 0, 0, 0.2);
}

.location-select option {
    background-color: #3a3f44;
    color: white;
}

.button-group {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.button-group .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: 25px;
    font-weight: 600;
    font-size: 1em;
    border: none;
}

.location-data-note {
    width: 100%;
    text-align: center;
    font-size: 0.8em;
    color: #bdc3c7;
    margin-top: 8px;
    margin-bottom: 0;
    font-style: italic;
}

.location-data-note .note-icon {
    font-style: normal;
    font-weight: bold;
    margin-right: 2px;
}


.weather-widget {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.weather-main {
    margin-bottom: 25px;
}

.weather-main .fas {
    font-size: 7rem !important;
    color: #f1c40f;
    margin-bottom: 15px;
    text-shadow: 0 0 30px rgba(241, 196, 15, 0.5);
}

.weather-temp {
    font-size: 3.5rem;
    font-weight: 600;
}

.weather-location {
    font-size: 1.2rem;
    color: #ccc;
}

.weather-desc {
    font-size: 1.1rem;
    text-transform: capitalize;
}

.weather-forecast {
    display: flex;
    justify-content: space-around;
    width: 100%;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
}

.forecast-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.forecast-item i {
    font-size: 1.5rem;
    color: #bdc3c7;
}

/* General Button Spacing & Styling */
.btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #e0e0e0;
    padding: 8px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    /* Added gap for icons */
    font-size: 0.9em;
}

.btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.6);
}

.btn.btn-primary {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    color: white;
    border: none;
}

.btn.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
}

.btn.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #ccc;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}

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

.btn.btn-danger:hover {
    background-color: #e74c3c;
    border-color: #e74c3c;
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.4);
}


.btn.disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
    transform: none;
}

.card .btn {
    margin-top: auto;
}

.card>p+.btn,
.card>p+.post-actions {
    margin-top: 15px;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #ccc;
    font-weight: 600;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-size: 1rem;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.form-group textarea {
    min-height: 120px;
    resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #4CAF50;
    background-color: rgba(255, 255, 255, 0.15);
}

.form-group input[readonly] {
    background-color: rgba(0, 0, 0, 0.2);
    cursor: not-allowed;
}

/* News Grid */
.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 25px;
}

.news-card {
    padding: 0;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: #e0e0e0;
}

.news-card-image {
    height: 200px;
    overflow: hidden;
}

.news-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 15px 15px 0 0;
    transition: transform 0.4s ease;
}

.news-card:hover .news-card-image img {
    transform: scale(1.05);
}

.news-card-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.news-card-tag {
    display: inline-block;
    background-color: #4CAF50;
    color: white;
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 0.8em;
    font-weight: 600;
    margin-bottom: 15px;
    align-self: flex-start;
}

.news-card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: #f0f0f0;
    line-height: 1.4;
}

.news-card-excerpt {
    font-size: 0.95rem;
    color: #ccc;
    line-height: 1.6;
    margin-bottom: 0;
    flex-grow: 1;
}

.news-card-meta {
    margin-top: 20px;
    font-size: 0.85em;
    color: #999;
}

.news-card-meta i {
    margin-right: 5px;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeInModal 0.3s ease;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: #3a3f44;
    padding: 30px;
    border-radius: 15px;
    width: 100%;
    max-width: 500px;
    text-align: left;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: slideInModal 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

.modal-header h3 {
    font-size: 1.5rem;
    color: #f0f0f0;
    margin: 0;
}

.close-modal-btn {
    background: none;
    border: none;
    color: #aaa;
    font-size: 1.8rem;
    cursor: pointer;
    transition: color 0.3s, transform 0.3s;
}

.close-modal-btn:hover {
    color: white;
    transform: rotate(90deg);
}


.modal-box p {
    text-align: center;
    color: #dcdcdc;
    margin-bottom: 25px;
    line-height: 1.6;
}

#modal-close-btn {
    padding: 10px 30px;
    border-radius: 25px;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 25px;
}

.modal-actions .btn {
    padding: 10px 25px;
    border-radius: 25px;
}


@keyframes fadeInModal {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideInModal {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}


/* Responsive */
@media (max-width: 992px) {
    .sidebar {
        width: 70px;
    }

    .sidebar-header .logo span,
    .sidebar-nav span {
        display: none;
    }

    .sidebar-header .logo {
        font-size: 1.8rem;
    }

    .sidebar-nav li a {
        justify-content: center;
    }

    .sidebar-nav li a i {
        margin-right: 0;
    }
}

@media (max-width: 768px) {
    .dashboard-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding: 10px 15px;
        justify-content: space-between;
    }

    .sidebar-header {
        margin-bottom: 0;
    }

    .sidebar-nav {
        display: flex;
        flex-direction: row;
        justify-content: center;
        gap: 5px;
    }

    .sidebar-nav li a {
        padding: 10px 15px;
        margin-bottom: 0;
    }

    .sidebar-footer {
        display: none;
    }

    .main-content {
        height: calc(100vh - 71px);
        padding: 20px;
    }

    .main-header-bar {
        flex-direction: row;
        align-items: center;
        gap: 15px;
        margin-bottom: 25px;
    }

    .main-header-bar h2 {
        font-size: 1.5rem;
    }

    .user-menu .btn {
        padding: 8px 16px;
    }
}