* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --dark-color: #343a40;
    --light-color: #f8f9fa;
    --border-color: #dee2e6;
    --bg-color: #ffffff;
    --sidebar-bg: #2c3e50;
    --sidebar-hover: #34495e;
    --message-bg: #e9ecef;
    --message-own-bg: #007bff;
    --message-own-text: #ffffff;
    --text-color: #212529;
    --text-light: #6c757d;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-color);
}

/* Auth Styles */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    padding: 40px;
    width: 100%;
    max-width: 450px;
}

.auth-card h1 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 30px;
    font-size: 2rem;
}

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: var(--light-color);
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s;
    font-weight: 500;
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

.form-group label i {
    margin-right: 5px;
    color: var(--primary-color);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
    justify-content: center;
}

.btn-primary:hover {
    background: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 123, 255, 0.3);
}

.message {
    margin-top: 15px;
    padding: 12px;
    border-radius: 5px;
    text-align: center;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Chat Container */
.chat-container {
    display: flex;
    height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.1);
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.user-info {
    flex: 1;
}

.username {
    font-weight: 600;
    margin-bottom: 4px;
}

.user-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
}

.user-status.offline .status-dot {
    background: var(--secondary-color);
}

.user-status.away .status-dot {
    background: var(--warning-color);
}

.user-status.busy .status-dot {
    background: var(--danger-color);
}

.btn-icon {
    background: transparent;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 5px;
    transition: background 0.3s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.room-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.room-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.room-list-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.room-item {
    padding: 12px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.room-item:hover {
    background: var(--sidebar-hover);
}

.room-item:hover .room-item-actions {
    opacity: 1;
    visibility: visible;
}

.room-item.active {
    background: var(--primary-color);
}

.room-item-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.room-item-preview {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.room-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.room-item-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
}

.room-item-avatar {
    position: relative;
}

.status-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--sidebar-bg);
}

.status-indicator.online {
    background: var(--success-color);
}

.status-indicator.away {
    background: var(--warning-color);
}

.unread-badge {
    background: var(--primary-color);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.total-unread-badge {
    background: var(--primary-color);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
    margin-left: 8px;
    display: inline-block;
    vertical-align: middle;
}

.room-item-content {
    flex: 1;
    min-width: 0;
}

.room-item-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.btn-room-delete {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-room-delete:hover {
    background: rgba(220, 53, 69, 0.2);
    color: #dc3545;
}

.btn-room-delete:active {
    transform: scale(0.95);
}

.room-list-search {
    position: relative;
    margin-bottom: 15px;
}

.room-list-search input {
    width: 100%;
    padding: 10px 35px 10px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    font-size: 14px;
    outline: none;
    transition: all 0.3s;
}

.room-list-search input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.room-list-search input:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.room-list-search i {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
}

.room-list-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    gap: 10px;
}

.btn-pagination {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-pagination:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
}

.btn-pagination:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    flex: 1;
    text-align: center;
}

.online-users-container {
    padding: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.online-users-container h4 {
    font-size: 14px;
    margin-bottom: 10px;
    color: rgba(255, 255, 255, 0.8);
}

.online-user {
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

.online-user:hover {
    background: rgba(255, 255, 255, 0.1);
}

.online-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

/* Chat Main Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

.chat-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
}

.chat-placeholder i {
    font-size: 80px;
    margin-bottom: 20px;
    color: var(--border-color);
}

.chat-active {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.room-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.room-details h3 {
    margin-bottom: 4px;
    font-size: 18px;
}

.typing-indicator {
    font-size: 12px;
    color: var(--text-light);
    font-style: italic;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    background: #f8f9fa;
    padding: 20px;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Date Separator Styles */
.date-separator {
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.date-label {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    margin: 0 auto;
    position: relative;
}

.date-label::before,
.date-label::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background: var(--border-color);
}

.date-label::before {
    left: -35%;
}

.date-label::after {
    right: -35%;
}

.messages-by-date {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Chat Pagination Styles */
.chat-pagination {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 1px solid var(--border-color);
}

.chat-pagination .btn-pagination {
    background: var(--primary-color);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-pagination .btn-pagination:hover:not(:disabled) {
    background: #0056b3;
    transform: translateY(-1px);
}

.chat-pagination .btn-pagination:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--secondary-color);
}

.chat-pagination .pagination-info {
    font-size: 12px;
    color: var(--text-light);
    text-align: center;
}

.message-item {
    display: flex;
    gap: 12px;
    max-width: 70%;
}

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

.message-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.message-content {
    background: var(--message-bg);
    padding: 12px 16px;
    border-radius: 12px;
    position: relative;
}

.message-item.own .message-content {
    background: var(--message-own-bg);
    color: var(--message-own-text);
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.message-sender {
    font-weight: 600;
    font-size: 14px;
}

.message-time {
    font-size: 11px;
    color: var(--text-light);
}

.message-item.own .message-time {
    color: rgba(255, 255, 255, 0.8);
}

.message-text {
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message-input-container {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    background: white;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--light-color);
    border-radius: 25px;
    padding: 8px 15px;
}

.input-wrapper input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
}

.btn-send {
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-send:hover {
    background: #0056b3;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
}

.modal-body {
    padding: 20px;
}

.loading {
    text-align: center;
    padding: 20px;
    color: var(--text-light);
}

/* Responsive */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 300px;
    }

    .message-item {
        max-width: 85%;
    }
}

