/* Chat Container */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh; /* Change to fixed height */
    width: 100%;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden; /* Prevent container overflow */
    position: relative; /* For absolute positioning of input container */
}

.chat-container.full-width {
    max-width: 100%;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}

/* Chat Header */
.chat-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.chat-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    text-align: center;
    flex: 1;
}

.online-users {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.home-button {
    display: none; /* Hidden by default */
    padding: 0.5rem;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
}

.home-button:hover {
    background-color: var(--background-color);
}

.home-button .icon {
    width: 24px;
    height: 24px;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    padding-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 4.5rem;
    height: calc(100vh - 4.5rem);
    position: relative;
}

/* Remove the spacer */
.chat-messages::before {
    display: none;
}

.message {
    display: flex;
    gap: 0.75rem;
    max-width: 80%;
    animation: fadeIn 0.3s ease-in-out;
}

.message.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.received {
    align-self: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.message-content {
    background: var(--background-color);
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    max-width: calc(100% - 40px); /* Account for avatar width and gap */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message.sent .message-content {
    background: var(--primary-color);
    color: white;
}

.message-username {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.message.sent .message-username {
    color: rgba(255, 255, 255, 0.8);
}

.message.received .message-username {
    color: var(--text-secondary);
}

.message-text {
    word-wrap: break-word;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

.message-time {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.message.sent .message-time {
    color: rgba(255, 255, 255, 0.7);
}

.message.received .message-time {
    color: var(--text-secondary);
}

/* Chat Input */
.chat-message-input-container {
    position: relative;
    padding: 1rem;
    background: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.chat-message-input-container.dragover {
    background-color: var(--background-color);
    border: 2px dashed var(--primary-color);
}

.chat-message-input-container.dragover::after {
    content: 'Drop image here';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.25rem;
    color: var(--primary-color);
    pointer-events: none;
    z-index: 1;
}

.chat-message-input {
    flex: 1;
    min-width: 0;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    margin-right: 0.5rem;
    resize: none;
    min-height: 40px;
    font-size: 16px; /* Prevent zoom on iOS */
    -webkit-text-size-adjust: 100%; /* Prevent font size adjustment */
}

/* Prevent zoom on iOS for all input elements */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="url"],
textarea {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

#chat-image-preview {
    width: 100%;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#chat-image-preview.hidden {
    display: none;
}

#chat-preview-img {
    max-width: 100px;
    max-height: 100px;
    border-radius: 4px;
}

#remove-chat-image {
    padding: 0.25rem 0.5rem;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.875rem;
}

#remove-chat-image:hover {
    background: var(--danger-hover);
}

.chat-send-button {
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    white-space: nowrap;
}

.send-button:disabled {
    background: var(--border-color);
    cursor: not-allowed;
}

/* No messages state */
.no-messages {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

/* Error message */
.error-message {
    text-align: center;
    color: var(--danger-color);
    padding: 2rem;
}

.youtube-embed {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    margin: 0.5rem 0;
    border-radius: 0.5rem;
    overflow: hidden;
}

.youtube-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Image Modal */
.image-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    overflow: auto;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-modal.show {
    display: flex;
    opacity: 1;
}

.image-modal-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 90%;
    position: relative;
}

.image-modal-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    display: block;
    margin: auto;
}

.image-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

/* Make message images clickable */
.message-image {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.message-image:hover {
    opacity: 0.9;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .home-button {
        display: block; /* Show on mobile */
        position: absolute;
        left: 1rem;
        top: 50%;
        transform: translateY(-50%);
    }

    .chat-header h1 {
        margin-left: 2.5rem; /* Make space for the home button */
    }

    .chat-messages {
        margin-bottom: 4.5rem; /* Space for input container */
    }

    .message {
        max-width: 90%;
    }

    .message-content {
        padding: 0.5rem 0.75rem;
    }

    .chat-message-input-container {
        padding: 0.5rem;
    }

    .chat-message-input {
        margin-right: 0;
    }

    .message-image {
        max-width: 100% !important;
        height: auto !important;
    }

    .image-modal-content {
        max-width: 95%;
    }

    .image-modal-close {
        top: -35px;
        font-size: 35px;
    }
} 