* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --dark-bg: #1f2937;
    --light-bg: #f9fafb;
    --sidebar-bg: #ffffff;
    --message-bg: #f3f4f6;
    --own-message-bg: #6366f1;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
}

body {
    background-color: var(--light-bg);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    position: relative;
}

/* Sidebar Styles */
.sidebar {
    width: 320px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: relative;
    transition: transform 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

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

.sidebar-header h2 {
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.menu-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    border-radius: 8px;
    transition: background 0.3s;
}

.menu-toggle:hover {
    background: var(--light-bg);
}

.search-box {
    padding: 15px 20px;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 30px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-box input {
    width: 100%;
    padding: 10px 10px 10px 35px;
    border: 1px solid var(--border-color);
    border-radius: 25px;
    font-size: 0.9rem;
    transition: border-color 0.3s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.sidebar-nav ul {
    list-style: none;
    padding: 10px 0;
}

.sidebar-nav li {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-secondary);
}

.sidebar-nav li i {
    width: 20px;
    font-size: 1.1rem;
}

.sidebar-nav li:hover {
    background: var(--light-bg);
    color: var(--primary-color);
}

.sidebar-nav li.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
    color: var(--primary-color);
    border-left: 3px solid var(--primary-color);
}

.chats-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

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

.chats-header h3 {
    color: var(--text-primary);
    font-size: 1rem;
}

.new-chat-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.3s;
}

.new-chat-btn:hover {
    background: var(--light-bg);
}

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

.chat-item:hover {
    background: var(--light-bg);
}

.chat-item.active {
    background: var(--light-bg);
    border-left: 3px solid var(--primary-color);
}

.chat-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-info {
    flex: 1;
    overflow: hidden;
}

.chat-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.chat-last-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

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

.user-info {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-details {
    flex: 1;
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

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

.logout-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 8px;
    transition: all 0.3s;
}

.logout-btn:hover {
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.1);
}

/* Main Content */
.main-content {
    flex: 1;
    background: var(--light-bg);
    overflow: hidden;
}

.tab-content {
    display: none;
    height: 100%;
}

.tab-content.active {
    display: block;
}

/* Chat Container */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: white;
}

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

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

.chat-user-info img {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-user-info h3 {
    color: var(--text-primary);
    font-size: 1.1rem;
    margin-bottom: 4px;
}

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

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 70%;
}

.message.own-message {
    flex-direction: row-reverse;
    margin-left: auto;
}

.message-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
}

.message-content {
    background: var(--message-bg);
    padding: 10px 15px;
    border-radius: 18px;
    position: relative;
}

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

.message-text {
    font-size: 0.95rem;
    line-height: 1.4;
    word-break: break-word;
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 4px;
    text-align: right;
}

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

.message-input-area {
    padding: 20px 25px;
    border-top: 1px solid var(--border-color);
}

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

.message-input-wrapper textarea {
    flex: 1;
    border: none;
    background: none;
    padding: 10px 0;
    max-height: 100px;
    resize: none;
    font-size: 0.95rem;
}

.message-input-wrapper textarea:focus {
    outline: none;
}

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

.send-btn:hover {
    background: var(--primary-dark);
}

.no-chat-selected {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.no-chat-selected i {
    font-size: 4rem;
    margin-bottom: 15px;
    color: var(--border-color);
}

/* Profile Container */
.profile-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 30px;
    background: white;
    height: 100%;
    overflow-y: auto;
}

.profile-container h2 {
    margin-bottom: 25px;
    color: var(--text-primary);
}

.profile-avatar-section {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.profile-avatar {
    position: relative;
    width: 120px;
    height: 120px;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary-color);
}

.change-avatar-btn {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: var(--primary-color);
    color: white;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.change-avatar-btn:hover {
    background: var(--primary-dark);
}

.profile-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-group input {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.3s;
}

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

.change-email-btn {
    align-self: flex-end;
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.9rem;
    margin-top: 5px;
}

.save-profile-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
    margin-top: 10px;
}

.save-profile-btn:hover {
    background: var(--primary-dark);
}

/* Devices Container */
.devices-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 30px;
    background: white;
    height: 100%;
    overflow-y: auto;
}

.devices-container h2 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

.logout-all-btn {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    margin-bottom: 25px;
    transition: background 0.3s;
}

.logout-all-btn:hover {
    background: #dc2626;
}

.device-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 10px;
    transition: box-shadow 0.3s;
}

.device-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.device-icon {
    width: 40px;
    height: 40px;
    background: var(--light-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
}

.device-info {
    flex: 1;
}

.device-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.device-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.device-current {
    background: var(--success-color);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    margin-left: 10px;
}

.device-delete-btn {
    background: none;
    border: none;
    color: var(--danger-color);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.3s;
}

.device-delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Settings Container */
.settings-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 30px;
    background: white;
    height: 100%;
    overflow-y: auto;
}

.settings-container h2 {
    margin-bottom: 25px;
    color: var(--text-primary);
}

.settings-section {
    margin-bottom: 30px;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.settings-section h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

.change-password-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
    width: 100%;
    margin-top: 10px;
}

.change-password-btn:hover {
    background: var(--primary-dark);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-header {
    text-align: center;
    margin-bottom: 25px;
}

.modal-header h2 {
    color: var(--text-primary);
    margin-bottom: 8px;
}

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

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.auth-tab {
    background: none;
    border: none;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-secondary);
    border-radius: 20px;
    transition: all 0.3s;
}

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

.auth-form {
    display: none;
}

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

.auth-submit {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
    width: 100%;
    margin-top: 20px;
}

.auth-submit:hover {
    background: var(--primary-dark);
}

.auth-links {
    text-align: center;
    margin-top: 15px;
}

.auth-links a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.9rem;
}

.auth-links a:hover {
    text-decoration: underline;
}

.qr-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    background: var(--light-bg);
    border-radius: 10px;
    margin: 20px 0;
}

.qr-placeholder {
    text-align: center;
    color: var(--text-secondary);
}

.qr-placeholder i {
    font-size: 3rem;
    margin-bottom: 10px;
}

.resend-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.9rem;
    margin-top: 15px;
    width: 100%;
    padding: 8px;
}

.resend-btn:hover {
    text-decoration: underline;
}

.reset-step {
    display: none;
}

.reset-step.active {
    display: block;
}

.search-results {
    margin-top: 20px;
    max-height: 300px;
    overflow-y: auto;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
}

.search-result-item:hover {
    background: var(--light-bg);
}

.search-result-item img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.search-result-info {
    flex: 1;
}

.search-result-name {
    font-weight: 600;
    color: var(--text-primary);
}

.search-result-email {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Notifications */
.notifications-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification {
    background: white;
    border-radius: 8px;
    padding: 15px 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: slideIn 0.3s ease;
    border-left: 4px solid var(--primary-color);
}

.notification.success {
    border-left-color: var(--success-color);
}

.notification.error {
    border-left-color: var(--danger-color);
}

.notification.warning {
    border-left-color: var(--warning-color);
}

.notification i {
    font-size: 1.2rem;
}

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

.notification.error i {
    color: var(--danger-color);
}

.notification.warning i {
    color: var(--warning-color);
}

.notification-content {
    flex: 1;
}

.notification-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.notification-message {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

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

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 100;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    }
    
    .sidebar.collapsed {
        transform: translateX(-100%);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .message {
        max-width: 85%;
    }
}