/* Reset some default styles */
body, h1, h2, p, ul, label, input, button {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* General body styles */
body {
    font-family: 'Arial', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    padding: 20px;
}

/* Header styles */
header {
    background-color: #2d572c;
    color: #fff;
    padding: 15px 20px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0;
}

/* Navigation styles */
nav ul {
    list-style-type: none;
    padding: 0;
    display: flex;
    justify-content: center;
    background-color: #2d572c;
    border-radius: 8px;
    margin-bottom: 20px;
}

nav ul li {
    margin: 0 15px;
}

nav ul li a {
    color: #fff;
    text-decoration: none;
    padding: 10px 15px;
    display: block;
}

nav ul li a:hover {
    background-color: #1e3d1e;
    border-radius: 4px;
}

/* Main section styles */
main {
    margin-top: 20px;
}

.intro, .features, .error-message, .login-form, .registration-form, .verification-form {
    background-color: #ffffff;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.intro h2, .features h2, .error-message h2, .login-form h2, .registration-form h2, verification-form h2 {
    color: #2d572c;
    margin-bottom: 10px;
}

.intro p, .features ul, .error-message p, .login-form p, .login-form label, .login-form input, .registration-form p, .registration-form label, .registration-form input,
.verification-form p, .verification-form label, .verification-form input
 {
    font-size: 1.1rem;
}

.features ul {
    list-style-type: none;
}

.features li {
    margin-bottom: 10px;
}

/* Form styles */
.login-form form, .registration-form form, .verification-form form {
    display: flex;
    flex-direction: column;
}

.login-form label, .registration-form label, .verification-form label {
    margin-bottom: 5px;
}

.login-form input, .registration-form input, .verification-form input {
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
}

.login-form .btn, .registration-form .btn, .verification-form .btn {
    display: inline-block;
    padding: 10px 20px;
    font-size: 1.1rem;
    color: #fff;
    background-color: #2d572c;
    border: none;
    border-radius: 5px;
    text-decoration: none;
    transition: background-color 0.3s ease;
}

.login-form .btn:hover, .registration-form .btn:hover, .verification-form .btn:hover {
    background-color: #1e3d1e;
}

.login-form p#message, .registration-form p#message, .verification-form p#message {
    margin-top: 15px;
    color: red;
}

/* Footer styles */
footer {
    text-align: center;
    padding: 10px 0;
    background-color: #2d572c;
    color: #fff;
    border-radius: 8px;
    margin-top: 20px;
}

footer p {
    font-size: 0.9rem;
}

/* App container styles */
.app-container {
    display: flex;
    height: 70vh;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Sidebar styles */
.sidebar {
    width: 300px;
    background-color: #f8f9fa;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
}

.back-btn {
    display: none;
}

@media (max-width: 600px) {
    .app-container {
        height: calc(100vh - 140px);
        border-radius: 0;
    }

    /* On mobile, sidebar and chat each take full width and toggle */
    .sidebar {
        width: 100%;
        border-right: none;
    }

    /* Hide sidebar when a chat is open: target via sibling selector trick using CSS */
    /* We use v-show style via a class toggled by Vue instead */
    .sidebar.chat-open {
        display: none;
    }

    .chat-container {
        width: 100%;
    }

    .back-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        font-size: 1.4rem;
        color: #2d572c;
        cursor: pointer;
        padding: 0 10px 0 0;
        vertical-align: middle;
    }
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    margin: 0;
    color: #2d572c;
}

.new-chat-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 1.2rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    transition: background-color 0.2s;
}

.chat-item:hover {
    background-color: #e9ecef;
}

.chat-item.active {
    background-color: #2d572c;
    color: white;
}

.chat-name {
    font-weight: bold;
    margin-bottom: 5px;
}

.chat-participants {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* Chat container styles */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #ffffff;
}

.chat-header h3 {
    margin: 0;
    color: #2d572c;
}

.no-chat {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 1.1rem;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #f9f9f9;
    min-height: 0;
}

.message {
    margin-bottom: 15px;
    display: flex;
}

.message.sent {
    justify-content: flex-end;
}

.message.received {
    justify-content: flex-start;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
}

.message.sent .message-content {
    background-color: #2d572c;
    color: white;
}

.message.received .message-content {
    background-color: #e5e5ea;
    color: #333;
}

.message-text {
    display: block;
    word-wrap: break-word;
}

.message-time {
    font-size: 0.8rem;
    opacity: 0.7;
    display: block;
    margin-top: 4px;
}

.chat-input {
    display: flex;
    padding: 20px;
    background-color: #ffffff;
    border-top: 1px solid #e0e0e0;
    gap: 10px;
}

.chat-input input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ccc;
    border-radius: 25px;
    font-size: 1rem;
    outline: none;
}

.chat-input input:focus {
    border-color: #2d572c;
}

.send-btn {
    padding: 12px 20px;
    border-radius: 25px;
    min-width: 70px;
}

.send-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.send-btn:disabled:hover {
    background-color: #ccc;
}

/* Auth links styles */
.auth-links {
    text-align: center;
    margin-top: 20px;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 8px;
}

.auth-links p {
    margin: 0;
    color: #666;
}

.auth-links a {
    color: #2d572c;
    text-decoration: none;
    font-weight: bold;
}

.auth-links a:hover {
    text-decoration: underline;
}

/* Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    min-width: 400px;
}

.modal h3 {
    margin: 0 0 20px 0;
    color: #2d572c;
}

.modal-input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1rem;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-secondary {
    background-color: #6c757d;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

/* User search styles */
.user-search-results {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ccc;
    border-radius: 5px;
    margin-bottom: 15px;
}

.user-search-item {
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.15s;
}

.user-search-item:last-child {
    border-bottom: none;
}

.user-search-item:hover, .user-search-item.selected {
    background-color: #e8f5e9;
}

.user-search-name {
    font-weight: bold;
    color: #333;
}

.user-search-username {
    font-size: 0.85rem;
    color: #888;
}

.selected-user-badge {
    background-color: #e8f5e9;
    border: 1px solid #2d572c;
    border-radius: 5px;
    padding: 8px 12px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
}

.clear-selection {
    cursor: pointer;
    color: #888;
    padding: 0 4px;
}

.clear-selection:hover {
    color: #333;
}

/* Chat type tabs */
.chat-type-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid #ccc;
    background-color: #f9f9f9;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background-color: #2d572c;
    color: white;
    border-color: #2d572c;
}

.tab-btn:hover {
    background-color: #e8f5e9;
}

.tab-btn.active:hover {
    background-color: #1e3d1e;
}

/* Selected users list for group chat */
.selected-users-list {
    margin-bottom: 15px;
}

.selected-users-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 8px;
}

/* Member list in chat header */
.member-toggle {
    font-size: 0.85rem;
    color: #2d572c;
    cursor: pointer;
    margin-top: 5px;
    text-decoration: underline;
}

.member-toggle:hover {
    color: #1e3d1e;
}

.member-list {
    margin-top: 10px;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 5px;
    max-height: 150px;
    overflow-y: auto;
}

.member-item {
    padding: 5px 0;
    font-size: 0.9rem;
    color: #333;
}

/* Message sender name */
.message-sender {
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 2px;
    font-weight: bold;
}

/* Media attach button */
.attach-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    font-size: 1.3rem;
    cursor: pointer;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background-color 0.2s;
}

.attach-btn:hover {
    background-color: #e8f5e9;
}

.attach-btn.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Media preview panel */
.media-preview {
    padding: 10px 20px;
    background-color: #f0f0f0;
    border-top: 1px solid #e0e0e0;
}

.media-preview-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.media-preview-img {
    max-height: 80px;
    max-width: 120px;
    border-radius: 6px;
    object-fit: cover;
}

.media-preview-info {
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    color: #555;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.media-preview-size {
    color: #888;
    font-size: 0.8rem;
}

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

/* Inline media in messages */
.message-media {
    display: block;
    max-width: 240px;
    max-height: 200px;
    border-radius: 10px;
    cursor: pointer;
    object-fit: cover;
    margin-bottom: 4px;
}

@media (max-width: 600px) {
    .message-media {
        max-width: 180px;
    }
    .media-preview-img {
        max-width: 80px;
    }
}