/* Community Messenger Styles */

:root {
    --community-bg-light: #f5f5f7;
    --community-bg-dark: #1c1c1e;
    --community-card-light: #ffffff;
    --community-card-dark: #2a2a2e;
    --community-text-light: #1d1d1f;
    --community-text-dark: #f5f5f7;
    --community-accent: #007aff;
    --community-accent-light: #34c759;
    --community-accent-orange: #ff9500;
    --community-accent-red: #ff3b30;
    --message-own-bg: #007aff;
    --message-other-bg: #e5e5ea;
    --message-own-text: #ffffff;
    --message-other-text: #1d1d1f;
}

/* Community Styles */
@keyframes slideInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Dark mode color overrides */
body.dark-mode-community {
    --community-bg-light: #1c1c1e;
    --community-bg-dark: #000000;
    --community-card-light: #2a2a2e;
    --community-card-dark: #1c1c1e;
    --community-text-light: #f5f5f7;
    --community-text-dark: #1d1d1f;
    --message-other-bg: #44454a;
    --message-other-text: #f5f5f7;
}

/* Ocean theme */
body.ocean-theme-community {
    --community-bg-light: #e0f7fa;
    --community-bg-dark: #01579b;
    --community-card-light: #b3e5fc;
    --community-accent: #0277bd;
    --message-own-bg: #0277bd;
}

/* Forest theme */
body.forest-theme-community {
    --community-bg-light: #e8f5e9;
    --community-bg-dark: #1b5e20;
    --community-card-light: #c8e6c9;
    --community-accent: #2e7d32;
    --message-own-bg: #2e7d32;
}

/* Community Wrapper */
.community-wrapper {
    display: flex;
    height: calc(100vh - 120px);
    background: var(--community-bg-light);
    gap: 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Sidebar */
.community-sidebar {
    width: 300px;
    background: var(--community-card-light);
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideInLeft 0.4s ease-out;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.community-header {
    padding: 16px 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.search-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.community-search {
    width: 100%;
    padding: 8px 12px 8px 32px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    background: var(--community-bg-light);
    color: var(--community-text-light);
    font-size: 14px;
    transition: all 0.2s ease;
}

.community-search:focus {
    outline: none;
    border-color: var(--community-accent);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.search-icon {
    position: absolute;
    left: 10px;
    font-size: 14px;
    color: var(--community-text-light);
    opacity: 0.6;
}

.community-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: var(--community-bg-light);
    color: var(--community-text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
}

.community-action-btn:hover {
    background: rgba(0, 122, 255, 0.1);
    color: var(--community-accent);
}

.community-action-btn:active {
    transform: scale(0.95);
}

/* Sections */
.community-section {
    display: flex;
    flex-direction: column;
    padding: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    overflow-y: auto;
    position: relative;
}

.community-section:last-child {
    border-bottom: none;
    flex: 1;
    position: relative;
    overflow-y: auto;
    padding-bottom: 60px;
}

.community-section:nth-child(2) {
    position: relative;
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--community-text-light);
    opacity: 0.6;
    padding: 8px 8px 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 8px 4px;
    margin-bottom: 4px;
    position: relative;
}

.section-action-btn {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--community-accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
}

.section-action-btn:hover {
    background: rgba(0, 122, 255, 0.1);
}

/* Floating create group button */
#create-group-btn {
    position: fixed;
    bottom: 40px;
    left: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--community-accent);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
    z-index: 100;
    transition: all 0.2s ease;
}

#create-group-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 122, 255, 0.4);
}

#create-group-btn:active {
    transform: scale(0.95);
}

/* Community Group Item */
.community-group-item,
.group-item,
.dm-item {
    padding: 8px;
    margin: 2px 0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    color: inherit;
    font-size: 14px;
}

.community-group-item:hover,
.group-item:hover,
.dm-item:hover {
    background: rgba(0, 122, 255, 0.1);
}

.community-group-item.active,
.group-item.active,
.dm-item.active {
    background: rgba(0, 122, 255, 0.15);
    border-left: 3px solid var(--community-accent);
    padding-left: 5px;
}

.group-avatar,
.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--community-bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.group-info,
.chat-header-info {
    flex: 1;
    overflow: hidden;
}

.group-name,
.chat-header-info h3 {
    font-weight: 500;
    color: var(--community-text-light);
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-preview,
.group-info p {
    font-size: 12px;
    color: var(--community-text-light);
    opacity: 0.6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background: var(--community-accent-red);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

/* Lists */
.groups-list,
.dms-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Main Chat Area */
.community-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--community-bg-light);
    animation: slideInRight 0.4s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.community-chat-header {
    padding: 12px 20px;
    background: var(--community-card-light);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.chat-header-info {
    min-width: 0;
}

.chat-header-info h3 {
    margin: 0;
}

.chat-header-info p {
    margin: 2px 0 0;
    font-size: 12px;
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

/* Messages Area */
.community-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.community-messages::-webkit-scrollbar {
    width: 6px;
}

.community-messages::-webkit-scrollbar-track {
    background: transparent;
}

.community-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.community-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.messages-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--community-text-light);
    opacity: 0.6;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.4;
}

/* Message Styles */
.message-group {
    display: flex;
    margin-bottom: 12px;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message-group.own {
    justify-content: flex-end;
}

.message-group.other {
    justify-content: flex-start;
}

.message-sender {
    font-size: 12px;
    font-weight: 500;
    color: var(--community-text-light);
    opacity: 0.7;
    margin-bottom: 4px;
}

.message-group.own .message-sender {
    text-align: right;
}

.message-bubble {
    max-width: 70%;
    padding: 8px 12px;
    border-radius: 18px;
    word-wrap: break-word;
    animation: messageBubbleIn 0.3s ease-out;
    position: relative;
}

@keyframes messageBubbleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.message-bubble.own {
    background: var(--message-own-bg);
    color: var(--message-own-text);
    border-bottom-right-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 122, 255, 0.2);
}

.message-bubble.other {
    background: var(--message-other-bg);
    color: var(--message-other-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message-time {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 4px;
}

.message-group.own .message-time {
    text-align: right;
}

.message-actions {
    display: none;
    position: absolute;
    background: var(--community-card-light);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding: 4px;
    gap: 4px;
    z-index: 10;
}

.message-bubble:hover .message-actions {
    display: flex;
}

.message-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--community-text-light);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
}

.message-action-btn:hover {
    background: rgba(0, 122, 255, 0.1);
    color: var(--community-accent);
}

/* Input Area */
.community-input-area {
    padding: 12px 20px 20px;
    background: var(--community-bg-light);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.input-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

.community-message-input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    background: var(--community-card-light);
    color: var(--community-text-light);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
    max-height: 100px;
    resize: none;
}

.community-message-input:focus {
    outline: none;
    border-color: var(--community-accent);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.send-button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--community-accent);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.send-button:active {
    transform: scale(0.95);
}

/* Info Panel */
.community-info-panel {
    width: 280px;
    background: var(--community-card-light);
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    animation: slideInRight 0.3s ease-out;
}

.community-info-panel.show {
    transform: translateX(0);
}

.info-header {
    padding: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--community-text-light);
}

.close-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--community-text-light);
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
}

.info-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.info-section {
    margin-bottom: 20px;
}

.info-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--community-text-light);
    opacity: 0.6;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.members-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.member-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 8px;
    background: var(--community-bg-light);
}

.member-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--community-accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.member-info {
    flex: 1;
}

.member-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--community-text-light);
}

.member-email {
    font-size: 12px;
    color: var(--community-text-light);
    opacity: 0.6;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9000;
}

.modal-overlay.show {
    display: flex;
    animation: fadeInOverlay 0.3s ease-out;
}

@keyframes fadeInOverlay {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(4px);
    }
}

.modal-content {
    background: var(--community-card-light);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--community-text-light);
}

.modal-close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--community-text-light);
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-input {
    padding: 10px 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    background: var(--community-bg-light);
    color: var(--community-text-light);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--community-accent);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--community-text-light);
    opacity: 0.6;
    margin: 4px 0 8px;
    text-transform: uppercase;
}

.users-list,
.create-group-members {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 300px;
    overflow-y: auto;
}

.user-item {
    padding: 12px;
    border-radius: 8px;
    background: var(--community-bg-light);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-item:hover {
    background: rgba(0, 122, 255, 0.1);
}

.user-item.selected {
    background: rgba(0, 122, 255, 0.15);
    border: 2px solid var(--community-accent);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--community-accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
}

.user-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--community-text-light);
}

.user-email {
    font-size: 12px;
    color: var(--community-text-light);
    opacity: 0.6;
}

.checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkbox.checked {
    background: var(--community-accent);
    border-color: var(--community-accent);
    color: white;
}

/* Theme Selector */
.themes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.theme-option {
    cursor: pointer;
    border-radius: 8px;
    border: 2px solid transparent;
    overflow: hidden;
    transition: all 0.2s ease;
}

.theme-option:hover {
    border-color: var(--community-accent);
    transform: scale(1.05);
}

.theme-preview {
    width: 100%;
    height: 80px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.theme-preview.light-preview {
    background: linear-gradient(135deg, #f5f5f7 0%, #e5e5ea 100%);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.theme-preview.dark-preview {
    background: linear-gradient(135deg, #1c1c1e 0%, #000000 100%);
}

.theme-preview.ocean-preview {
    background: linear-gradient(135deg, #0277bd 0%, #01579b 100%);
}

.theme-preview.forest-preview {
    background: linear-gradient(135deg, #2e7d32 0%, #1b5e20 100%);
}

.theme-name {
    padding: 8px;
    text-align: center;
    font-weight: 500;
    font-size: 14px;
    color: var(--community-text-light);
    background: var(--community-bg-light);
}

.theme-option.selected {
    border-color: var(--community-accent);
}

.btn-primary {
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    background: var(--community-accent);
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
}

.btn-primary:hover {
    background: #0051d5;
    transform: scale(1.02);
}

.btn-primary:active {
    transform: scale(0.98);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .community-wrapper {
        height: calc(100vh - 100px);
    }

    .community-sidebar {
        width: 260px;
    }

    .community-info-panel {
        width: 240px;
    }

    .message-bubble {
        max-width: 80%;
    }
}

@media (max-width: 768px) {
    .community-wrapper {
        flex-direction: column;
    }

    .community-sidebar {
        width: 100%;
        height: 150px;
        border-right: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }

    .community-main {
        flex: 1;
    }

    .community-info-panel {
        width: 100%;
        height: auto;
        border-left: none;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
    }

    .message-bubble {
        max-width: 85%;
    }
}

@media (max-width: 480px) {
    .community-messages {
        padding: 12px 16px;
    }

    .community-input-area {
        padding: 8px 16px 16px;
    }

    .message-bubble {
        max-width: 90%;
        padding: 6px 10px;
        font-size: 13px;
    }

    .community-header {
        padding: 12px;
    }

    .community-chat-header {
        padding: 10px 16px;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Loading animation */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading {
    animation: spin 1s linear infinite;
}

/* Smooth transitions */
* {
    --transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}