/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden; /* Prevent horizontal scroll */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ADDED: Alert/Notification Styles */
.alert-container {
    position: fixed;
    top: 80px; /* Position below header */
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.alert {
    padding: 15px 25px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert.show {
    opacity: 1;
    transform: translateY(0);
}

.alert-success {
    background-color: #28a745;
}

.alert-error {
    background-color: #dc3545;
}


/* Optimized Header Styles */
.header {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    min-height: 60px;
}

.nav-brand h1 {
    color: #2563eb;
    font-size: 24px;
    font-weight: 700;
    white-space: nowrap;
}

.nav {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
    justify-content: flex-end;
}

.nav-links {
    display: flex;
    gap: 20px;
}

.nav-link {
    text-decoration: none;
    color: #666;
    font-weight: 500;
    transition: color 0.2s;
    white-space: nowrap;
}

.nav-link:hover {
    color: #2563eb;
}

/* Authentication Section */
.auth-section {
    display: flex;
    align-items: center;
    gap: 15px; 
    flex-shrink: 0;
}

.auth-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* User Menu Styles */
.user-menu {
    position: relative; /* For dropdown positioning */
}

.user-info-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.user-info-wrapper:hover {
    background-color: #f3f4f6;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #e0e0e0;
    flex-shrink: 0;
    object-fit: cover;
}

.user-reputation {
    font-size: 12px;
    color: #666;
    font-weight: 500;
    white-space: nowrap;
}

.dropdown-arrow {
    font-size: 12px;
    color: #666;
    transition: transform 0.2s;
}

.user-menu-dropdown {
    display: none; /* Initially hidden */
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 110;
    min-width: 160px;
    padding: 8px 0;
    overflow: hidden;
}

.user-menu-link {
    display: block;
    padding: 10px 20px;
    text-decoration: none;
    color: #333;
    font-size: 14px;
    white-space: nowrap;
}

.user-menu-link:hover {
    background-color: #f3f4f6;
}


/* Notifications Styles */
.notifications-container {
    position: relative;
}

.notifications-bell {
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    color: #555;
    padding: 4px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.notifications-bell:hover {
    background-color: #f3f4f6;
    color: #2563eb;
}

.notifications-bell svg {
    width: 24px;
    height: 24px;
}

.notifications-count {
    position: absolute;
    top: 0;
    right: 0;
    background-color: #dc3545;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translate(30%, -30%);
}

.notifications-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 350px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    z-index: 120;
    overflow: hidden;
}

.notifications-header {
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
}

.notifications-header h3 {
    font-size: 16px;
    margin: 0;
}

.notifications-list {
    max-height: 400px;
    overflow-y: auto;
}

.notification-item {
    padding: 12px 15px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background-color 0.2s, opacity 0.3s, transform 0.3s;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.notification-item.deleting {
    opacity: 0;
    transform: translateX(-20px);
}


.notification-item:last-child {
    border-bottom: none;
}

.notification-item:hover {
    background-color: #f8f9fa;
}

.notification-item.unread {
    background-color: #eef2ff;
}

.notification-content {
    flex-grow: 1;
}

.notification-text {
    font-size: 14px;
    color: #333;
    margin: 0 0 5px 0;
}
.notification-text strong {
    color: #2563eb;
}

.notification-time {
    font-size: 12px;
    color: #666;
}

.delete-notification-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
    padding: 5px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: color 0.2s, background-color 0.2s;
}
.delete-notification-btn:hover {
    color: #dc3545;
    background-color: #fce8ea;
}


/* Button Styles */
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid transparent;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
    white-space: nowrap;
}
.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

.btn-primary {
    background: #2563eb;
    color: white;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-outline {
    background: transparent;
    color: #2563eb;
    border-color: #2563eb;
}

.btn-outline:hover {
    background: #eef2ff;
}

.btn-google {
    background: white;
    color: #333;
    border: 1px solid #dadce0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
}

.btn-google:hover {
    background: #f8f9fa;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
    border-color: #dc3545;
}

.btn-danger:hover {
    background-color: #c82333;
    border-color: #bd2130;
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}


/* Main Content */
.main {
    padding: 30px 0;
    min-height: calc(100vh - 70px);
}

.page {
    min-height: 500px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-header h2 {
    font-size: 28px;
    color: #333;
}

/* Filters */
.filters {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 15px;
}

.filter-btn {
    padding: 8px 16px;
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    border-radius: 4px;
    font-weight: 500;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: #f3f4f6;
    color: #333;
}

.filter-btn.active {
    background: #2563eb;
    color: white;
}

/* Questions List */
.questions-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.question-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    transition: box-shadow 0.2s;
    cursor: pointer;
}

.question-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.question-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    font-size: 14px;
    color: #666;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-number {
    font-weight: 600;
    color: #333;
}

.question-title {
    font-size: 18px;
    font-weight: 600;
    color: #2563eb;
    margin-bottom: 10px;
    text-decoration: none;
}

.question-title:hover {
    color: #1d4ed8;
}

.question-excerpt {
    color: #666;
    margin-bottom: 15px;
    line-height: 1.5;
}

.question-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #666;
}

.question-author {
    display: flex;
    align-items: center;
    gap: 8px;
}

.author-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
}

/* Forms */
.question-form, .answer-form, .profile-form {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 30px;
}

.profile-form {
    max-width: 700px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 12px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 30px;
}

/* Profile Page specific styles */
.profile-picture-section {
    display: flex;
    align-items: center;
    gap: 20px;
}

.profile-avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e0e0e0;
    background-color: #f8f9fa;
    flex-shrink: 0;
}

input:disabled {
    background-color: #f3f4f6;
    color: #6b7280;
    cursor: not-allowed;
}

/* Question Detail */
.question-detail {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 30px;
    margin-bottom: 30px;
}

.question-header {
    margin-bottom: 20px;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 20px;
}

.question-meta-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}


.question-header h1 {
    font-size: 24px;
    color: #333;
    margin-bottom: 10px;
}

.vote-body-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

.content-body {
    flex: 1;
    min-width: 0;
}

.question-votes {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.vote-btn {
    background: transparent;
    border: 1px solid #d1d5db;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #666;
    transition: all 0.2s;
}

.vote-btn:hover:not(:disabled) {
    background: #f3f4f6;
    border-color: #2563eb;
    color: #2563eb;
}

.vote-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.vote-btn.voted {
    background: #2563eb;
    border-color: #2563eb;
    color: white;
}

.vote-count {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

/* Answers Section */
.answers-section {
    margin-top: 40px;
}

.answers-section h3 {
    margin-bottom: 20px;
    color: #333;
}

.answer-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    position: relative; 
}

.answer-body {
    margin-bottom: 15px;
    line-height: 1.6;
}

/* Reply Feature Styles */
.replies-container {
    margin-top: 20px;
    padding-left: 50px; /* Indent replies */
    border-left: 2px solid #e9ecef;
}

.replies-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 15px;
}

.reply-card {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    font-size: 14px;
    position: relative;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.reply-card.deleting {
    opacity: 0;
    transform: translateX(-20px);
}


.reply-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    width: 100%; /* ADDED: Ensure the container takes full width */
}

.reply-author {
    font-weight: 600;
    color: #2563eb;
}

.reply-time {
    font-size: 12px;
    color: #666;
}

.reply-body {
    color: #333;
}

.reply-form {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-top: 10px;
}

.reply-form textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
}

.reply-button {
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s;
}

.reply-button:hover {
    background: #f3f4f6;
    color: #2563eb;
}

.answer-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Delete Buttons */
.delete-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.delete-btn:hover {
    background-color: #fce8eA;
    color: #a51220;
}


.delete-reply-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    margin-left: 8px;
    border-radius: 50%;
    color: #666;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left:auto; /* Pushes button to the far right */
}

.delete-reply-btn:hover {
    background-color: #fce8eA;
    color: #a51220;
}

.answer-form-section {
    margin-top: 40px;
}

.answer-form-section h3 {
    margin-bottom: 20px;
    color: #333;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid #e0e0e0;
}

.modal-header h3 {
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #333;
}

.modal-body {
    padding: 30px;
}

/* ADDED: Confirmation Modal Styles */
#confirm-modal .modal-content {
    max-width: 450px;
}
#confirm-modal-confirm-btn {
    background-color: #dc3545; /* Red for destructive actions */
    border-color: #dc3545;
}
#confirm-modal-confirm-btn:hover {
    background-color: #c82333;
    border-color: #bd2130;
}


.divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #e0e0e0;
}

.divider span {
    background: white;
    padding: 0 15px;
    color: #666;
    font-size: 14px;
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: #666;
}

.auth-switch a {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

/* Loading States */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}

/* Mention/Tagging Styles */
.mentions-popup {
    display: none;
    position: absolute;
    z-index: 1100;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 200px;
    overflow-y: auto;
    min-width: 150px;
}

.mention-item {
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.mention-item:hover, .mention-item.selected {
    background-color: #f3f4f6;
}

.mention-item img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.mention-item .mention-name {
    font-weight: 600;
    color: #333;
}

.mention-item .mention-rep {
    font-size: 12px;
    color: #666;
    margin-left: auto;
}

.mention-highlight {
    color: #1d4ed8;
    font-weight: 600;
    background-color: #eef2ff;
    padding: 2px 5px;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}

.mention-highlight:hover {
    background-color: #dbeafe;
    color: #1c3d8a;
    text-decoration: none;
}


/* Mobile Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .profile-form {
        padding: 20px;
    }

    .profile-picture-section {
        flex-direction: column;
        align-items: flex-start;
    }

    .header .container {
        padding: 10px 15px;
        min-height: 56px;
        gap: 10px;
    }
    
    .nav-brand h1 {
        font-size: 20px;
        margin-right: auto;
    }
    
    .nav {
        gap: 12px;
        flex-shrink: 0;
    }
    
    .nav-links {
        gap: 12px;
    }
    
    .nav-link {
        font-size: 14px;
        padding: 4px 0;
    }
    
    .auth-buttons {
        gap: 6px;
    }
    
    .auth-buttons .btn {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .user-menu {
        gap: 8px;
    }
    
    .user-info {
        gap: 6px;
    }
    
    .user-avatar {
        width: 28px;
        height: 28px;
    }
    
    #user-name {
        display: none;
    }
    
    .main {
        padding: 20px 0;
    }
    
    .page-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .page-header h2 {
        font-size: 24px;
    }
    
    .filters {
        flex-wrap: wrap;
        gap: 8px;
        padding-bottom: 15px;
        white-space: nowrap;
    }
    
    .filter-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .question-card, .question-detail, .answer-card {
        padding: 15px;
    }
    
    .question-title {
        font-size: 16px;
    }
    
    .question-meta {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
    
    .question-form, .answer-form, .profile-form {
        padding: 20px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }

    .question-header h1 {
        font-size: 20px;
    }
    
    .vote-body-wrapper {
        flex-direction: column;
    }

    .vote-body-wrapper .content-body {
        order: 1; /* Puts content at the top */
    }

    .vote-body-wrapper .question-votes {
        order: 2; /* Puts votes at the bottom */
        flex-direction: row;
        gap: 15px;
        margin: 15px 0 0 0;
        padding-top: 15px;
        border-top: 1px solid #e9ecef;
        width: 100%;
        justify-content: flex-start;
    }
    
    .vote-btn {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .vote-count {
        font-size: 16px;
    }
    
    .modal-content {
        margin: 20px;
        width: calc(100% - 40px);
    }
    
    .replies-container {
        padding-left: 20px;
    }

    /* **UPDATED**: Mobile styles for notification dropdown */
    .notifications-dropdown {
        position: fixed; /* Position relative to the viewport */
        top: 65px; /* Position below the header */
        left: 50%;
        transform: translateX(-50%);
        width: 95vw; /* Almost full screen width */
        right: auto;
    }

    /* **UPDATED**: Mobile styles for notification bell */
    .notifications-bell svg {
        width: 22px;
        height: 22px;
    }

    .notifications-count {
        width: 16px;
        height: 16px;
        font-size: 10px;
    }

    .auth-section {
        gap: 10px;
    }
}
