:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #48bb78;
    --danger-color: #f56565;
    --warning-color: #ed8936;
    --dark-bg: #1a202c;
    --light-bg: #2d3748;
    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
    --border-color: #4a5568;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    --gradient: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

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

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    overflow-x: hidden;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--dark-bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s;
}

.loader {
    width: 60px;
    height: 60px;
    border: 5px solid var(--border-color);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

.auth-card {
    background: rgba(26, 32, 44, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 450px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h1 {
    font-size: 2.5rem;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-form h2 {
    margin-bottom: 25px;
    text-align: center;
    color: var(--text-primary);
}

.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.input-group input,
.input-group textarea,
.input-group select {
    width: 100%;
    padding: 12px 15px 12px 45px;
    background: var(--light-bg);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.3s;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.remember-forgot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.remember-forgot label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.remember-forgot a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s;
}

.remember-forgot a:hover {
    color: var(--secondary-color);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--gradient);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.switch-auth {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.switch-auth a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.terms {
    margin-bottom: 20px;
}

.terms label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.terms a {
    color: var(--primary-color);
    text-decoration: none;
}

/* Chat Container */
.chat-container {
    display: flex;
    height: 100vh;
    background: var(--dark-bg);
}

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

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.user-info img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid var(--primary-color);
}

.user-info h3 {
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
}

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

.status i {
    font-size: 0.6rem;
}

.sidebar-actions {
    display: flex;
    gap: 10px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--dark-bg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-icon:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

.search-bar {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

.search-bar input {
    width: 100%;
    padding: 10px 15px;
    background: var(--dark-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
}

.groups-section {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.groups-section h4 {
    margin-bottom: 15px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
}

.group-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 8px;
}

.group-item:hover {
    background: var(--dark-bg);
}

.group-item.active {
    background: var(--gradient);
}

.group-item img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.group-info {
    flex: 1;
}

.group-name {
    font-weight: 500;
    margin-bottom: 3px;
}

.group-preview {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-badge {
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
}

.social-links {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.social-links h4 {
    margin-bottom: 15px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.social-icons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.social-icons a {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--dark-bg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.social-icons a:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-3px);
}

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

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

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

.chat-info img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.chat-info h3 {
    margin-bottom: 5px;
}

.chat-info span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.chat-actions {
    display: flex;
    gap: 10px;
}

.messages-area {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: var(--dark-bg);
}

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

.welcome-message i {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.welcome-message h3 {
    margin-bottom: 10px;
}

.welcome-message p {
    color: var(--text-secondary);
}

.message {
    display: flex;
    margin-bottom: 20px;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.message-content {
    max-width: 60%;
}

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

.message-header img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
}

.message-header .username {
    font-weight: 500;
    font-size: 0.9rem;
}

.message-header .time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.message-bubble {
    background: var(--light-bg);
    padding: 12px 16px;
    border-radius: 15px;
    word-wrap: break-word;
}

.message.own .message-bubble {
    background: var(--gradient);
}

.message-input-container {
    padding: 20px;
    background: var(--light-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 15px;
}

.input-actions {
    display: flex;
    gap: 10px;
}

.message-input-container input {
    flex: 1;
    padding: 12px 16px;
    background: var(--dark-bg);
    border: 1px solid var(--border-color);
    border-radius: 25px;
    color: var(--text-primary);
}

.btn-send {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--gradient);
    border: none;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-send:hover {
    transform: scale(1.1);
}

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

/* Group Info Panel */
.group-info-panel {
    width: 350px;
    background: var(--light-bg);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

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

.panel-header h3 {
    font-size: 1.1rem;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
}

.panel-content {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.panel-content img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin: 0 auto 20px;
    display: block;
    border: 3px solid var(--primary-color);
}

.panel-content h4 {
    text-align: center;
    margin-bottom: 10px;
}

.panel-content p {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.group-stats {
    display: flex;
    justify-content: space-around;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.stat {
    text-align: center;
}

.stat i {
    display: block;
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.stat span {
    font-size: 1.2rem;
    font-weight: 600;
}

.group-members-list h5 {
    margin-bottom: 15px;
    color: var(--text-secondary);
}

.member-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.member-item:hover {
    background: var(--dark-bg);
}

.member-item img {
    width: 35px;
    height: 35px;
    border-radius: 50%;
}

.member-info {
    flex: 1;
}

.member-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.member-role {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.btn-danger {
    width: 100%;
    padding: 12px;
    background: var(--danger-color);
    border: none;
    border-radius: 10px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-danger:hover {
    background: #e53e3e;
    transform: translateY(-2px);
}

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

.modal-content {
    background: var(--light-bg);
    border-radius: 15px;
    padding: 30px;
    width: 90%;
    max-width: 500px;
    animation: modalSlide 0.3s;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 1.3rem;
}

.pricing-card {
    background: var(--dark-bg);
    border-radius: 10px;
    padding: 20px;
    margin: 20px 0;
    text-align: center;
}

.pricing-card h4 {
    margin-bottom: 15px;
}

.price {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.pricing-card ul {
    list-style: none;
    text-align: left;
}

.pricing-card li {
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.pricing-card i {
    color: var(--success-color);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--light-bg);
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    display: none;
    align-items: center;
    gap: 10px;
    animation: slideInRight 0.3s;
    z-index: 2000;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.toast.show {
    display: flex;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

.toast.warning {
    border-left: 4px solid var(--warning-color);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 280px;
    }
    
    .group-info-panel {
        display: none;
    }
    
    .message-content {
        max-width: 80%;
    }
    
    .auth-card {
        padding: 30px 20px;
    }
}

@media (max-width: 576px) {
    .chat-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: 50vh;
    }
    
    .main-chat {
        height: 50vh;
    }
}