/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #8b5cf6;
    --bg-color: #0f172a;
    --bg-light: #1e293b;
    --bg-lighter: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --success: #10b981;
    --error: #ef4444;
    --border-color: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--bg-color) 0%, #1a1f3a 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

/* Welcome Screen */
.welcome-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-color) 0%, #1a1f3a 100%);
    z-index: 1000;
    animation: fadeIn 0.8s ease-in;
}

.welcome-content {
    text-align: center;
    animation: slideUp 1s ease-out;
}

.avatar-container {
    position: relative;
    margin: 0 auto 2rem;
    width: 150px;
    height: 150px;
}

.avatar-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    color: white;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
    animation: scaleIn 0.8s ease-out, float 3s ease-in-out infinite;
    position: relative;
    z-index: 2;
}

.avatar-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: var(--primary-color);
    opacity: 0.3;
    animation: pulse 2s ease-in-out infinite;
}

.welcome-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: fadeInUp 1s ease-out 0.3s both;
}

.welcome-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    animation: fadeInUp 1s ease-out 0.5s both;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

@keyframes pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.3;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Registration Form */
.registration-form {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-color) 0%, #1a1f3a 100%);
    z-index: 999;
    animation: fadeIn 0.5s ease-in;
}

.form-container {
    background: var(--bg-light);
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 400px;
    animation: slideUp 0.5s ease-out;
}

.form-container h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    text-align: center;
}

.form-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-group label i {
    margin-right: 0.5rem;
    color: var(--primary-color);
}

.form-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg-lighter);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.error-message {
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    border-radius: 8px;
    color: var(--error);
    text-align: center;
    font-size: 0.9rem;
}

/* Chat Container */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-light);
}

.chat-header {
    background: var(--bg-lighter);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.header-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.header-info h3 {
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-light);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--bg-lighter);
    border-radius: 3px;
}

.message {
    display: flex;
    gap: 0.75rem;
    animation: fadeInUp 0.3s ease-out;
    max-width: 75%;
}

.message.admin {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-content {
    background: var(--bg-lighter);
    padding: 0.875rem 1.125rem;
    border-radius: 18px;
    word-wrap: break-word;
}

.message.admin .message-content {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.message-text {
    margin-bottom: 0.25rem;
    line-height: 1.5;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 0.25rem;
}

.loading-messages {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.chat-input-container {
    padding: 1rem 1.5rem;
    background: var(--bg-lighter);
    border-top: 1px solid var(--border-color);
}

.attachment-preview {
    padding: 0.75rem;
    background: var(--bg-light);
    border-radius: 8px;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background: var(--bg-lighter);
    border-radius: 6px;
    flex: 1;
}

.attachment-name {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-remove {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg-color);
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.attachment-remove:hover {
    background: var(--error);
    color: white;
}

.chat-input-form {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.input-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-light);
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

.audio-recording {
    padding: 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    border-radius: 8px;
    margin-top: 0.75rem;
}

.recording-indicator {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.recording-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--error);
    animation: pulse-dot 1s ease-in-out infinite;
}

#recording-time {
    flex: 1;
    font-weight: 600;
    color: var(--error);
}

.stop-recording-btn {
    padding: 0.5rem 1rem;
    background: var(--error);
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.stop-recording-btn:hover {
    background: #dc2626;
    transform: translateY(-2px);
}

#messageInput {
    flex: 1;
    padding: 0.875rem 1rem;
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: 25px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

#messageInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.send-button {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.send-button:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.4);
}

.send-button:active {
    transform: scale(0.95);
}

/* Posts Toggle Button */
.posts-toggle-btn {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    height: 52px;
    padding: 0 14px;
    border-radius: 9999px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    z-index: 100;
}

.posts-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.posts-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--error);
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Posts Sidebar */
.posts-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.posts-overlay.active {
    opacity: 1;
    visibility: visible;
}

.posts-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 90%;
    max-width: 450px;
    height: 100vh;
    background: var(--bg-light);
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.3);
    z-index: 999;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.posts-sidebar.active {
    transform: translateX(0);
}

.posts-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-lighter);
}

.posts-header h3 {
    font-size: 1.5rem;
}

.close-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--bg-lighter);
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: var(--bg-color);
    transform: rotate(90deg);
}

.posts-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.posts-content::-webkit-scrollbar {
    width: 6px;
}

.posts-content::-webkit-scrollbar-track {
    background: var(--bg-light);
}

.posts-content::-webkit-scrollbar-thumb {
    background: var(--bg-lighter);
    border-radius: 3px;
}

.post-item {
    background: var(--bg-lighter);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.post-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.post-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
}

.post-author {
    flex: 1;
}

.post-author-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.post-time {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.post-content {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.post-image {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 1rem;
    transition: transform 0.3s ease;
}

.post-image:hover {
    transform: scale(1.02);
}

.post-attachment {
    margin-bottom: 1rem;
}

.post-attachment.video {
    width: 100%;
}

.post-video {
    width: 100%;
    border-radius: 8px;
    max-height: 500px;
    background: var(--bg-color);
}

.post-attachment.audio {
    padding: 1rem;
    background: var(--bg-lighter);
    border-radius: 8px;
}

.post-audio {
    width: 100%;
    height: 40px;
}

.post-attachment.file {
    padding: 1rem;
    background: var(--bg-lighter);
    border-radius: 8px;
}

.post-file-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.3s ease;
}

.post-file-link:hover {
    color: var(--primary-color);
}

.post-file-link .file-icon {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.post-file-link .file-info {
    flex: 1;
}

.post-file-link .file-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.post-file-link .file-size {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.post-actions {
    display: flex;
    gap: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.post-action {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.post-action:hover {
    color: var(--primary-color);
}

.post-action.liked {
    color: var(--error);
}

.post-comments {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.comment-item {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.comment-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.comment-content {
    flex: 1;
    background: var(--bg-color);
    padding: 0.75rem;
    border-radius: 12px;
}

.comment-author {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.comment-text {
    font-size: 0.9rem;
    line-height: 1.5;
}

.comment-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.comment-form {
    display: block;
    margin-top: 1rem;
    position: relative;
}

.comment-input {
    flex: 1;
    padding: 0.625rem 0.875rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.comment-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.comment-submit {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--primary-color);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.comment-submit:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

.loading-posts {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

/* Emoji Picker */
.emoji-picker {
    position: absolute;
    bottom: 70px;
    left: 1.5rem;
    width: 320px;
    max-height: 400px;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.emoji-categories {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-lighter);
}

.emoji-category {
    width: 35px;
    height: 35px;
    border-radius: 8px;
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-category:hover {
    background: var(--bg-color);
}

.emoji-category.active {
    background: var(--primary-color);
}

.emoji-grid {
    padding: 0.75rem;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.emoji-grid::-webkit-scrollbar {
    width: 6px;
}

.emoji-grid::-webkit-scrollbar-track {
    background: var(--bg-light);
}

.emoji-grid::-webkit-scrollbar-thumb {
    background: var(--bg-lighter);
    border-radius: 3px;
}

.emoji-item {
    width: 35px;
    height: 35px;
    border-radius: 8px;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.emoji-item:hover {
    background: var(--bg-lighter);
    transform: scale(1.2);
}

/* Message Attachments */
.message-attachment {
    margin-top: 0.5rem;
    border-radius: 8px;
    overflow: hidden;
}

.message-attachment img {
    max-width: 300px;
    max-height: 300px;
    width: 100%;
    height: auto;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.message-attachment img:hover {
    transform: scale(1.05);
}

.message-attachment.audio {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-color);
    border-radius: 8px;
}

.audio-player {
    flex: 1;
    height: 40px;
}

.audio-player audio {
    width: 100%;
    height: 40px;
    outline: none;
}

.audio-icon {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.message-attachment.file {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-color);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.message-attachment.file:hover {
    background: var(--bg-lighter);
}

.file-icon {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.file-size {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 768px) {
    .welcome-title {
        font-size: 2rem;
    }
    
    .form-container {
        padding: 2rem 1.5rem;
    }
    
    .posts-sidebar {
        width: 100%;
        max-width: 100%;
    }
    
    .posts-toggle-btn {
        bottom: 1rem;
        left: 1rem;
        height: 44px;
        padding: 0 12px;
        font-size: 1.1rem;
        gap: 0.4rem;
    }
}
    
    .message {
        max-width: 85%;
    }
/* fix stray brace removed to ensure rules apply */
.comment-input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    flex-wrap: nowrap;
    width: 100%;
    box-sizing: border-box;
}


.comment-form {
    position: relative;
}

.comment-form .emoji-picker {
    position: absolute;
    top: calc(100% + 8px);
    bottom: auto;
    left: 0;
    width: 100%;
    max-width: 100%;
    z-index: 1000;
}
.comment-form .comment-input {
    flex: 1 1 0;
    min-width: 0;
    box-sizing: border-box;
}

.comment-input-row .comment-input {
    height: 40px;
    padding: 0 12px;
}

.comment-input-row .action-btn,
.comment-input-row .comment-submit {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
}
.posts-toggle-text {
    font-size: 0.95rem;
    font-weight: 600;
}
