:root {
    --primary-color: #0088cc;
    --secondary-color: #f0f0f0;
    --text-color: #333;
    --border-color: #ddd;
    --online-color: #4caf50;
    --offline-color: #9e9e9e;
    --message-sent: #e3f2fd;
    --message-received: #f5f5f5;
    --error-color: #f44336;
    --success-color: #4caf50;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    overflow: hidden;
}

/* Login Screen */
.login-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    text-align: center;
    max-width: 500px;
    width: 90%;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
}

.logo .material-icons {
    font-size: 48px;
    color: var(--primary-color);
}

.logo h1 {
    color: var(--text-color);
    font-size: 28px;
    font-weight: 600;
}

.subtitle {
    color: #666;
    margin-bottom: 30px;
    font-size: 16px;
    line-height: 1.5;
}

/* TonConnect Button Styling */
.ton-connect-button {
    margin: 20px 0;
    min-height: 50px;
}

.mdc-button--raised {
    background-color: var(--primary-color) !important;
    color: white !important;
    padding: 15px 30px !important;
    font-size: 16px !important;
    border-radius: 10px !important;
    min-width: 200px;
}

.wallet-info {
    margin: 20px 0;
    padding: 15px;
    background: var(--secondary-color);
    border-radius: 10px;
    text-align: center;
}

#walletAddress {
    font-family: monospace;
    font-size: 14px;
    word-break: break-all;
    margin-bottom: 10px;
    color: #333;
}

.nft-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
    font-size: 14px;
}

.spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

.contract-info {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: left;
}

.contract-info p {
    margin: 5px 0;
    font-size: 14px;
    color: #666;
}

.contract-info code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: #333;
}

/* Chat Screen */
.chat-container {
    width: 100%;
    height: 100vh;
    display: flex;
    background: white;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 350px;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: white;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: var(--secondary-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.user-info img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
}

.user-info div {
    flex: 1;
    min-width: 0;
}

.user-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info p {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mdc-icon-button {
    color: var(--primary-color) !important;
}

.search-box {
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
    background: white;
}

.search-box .material-icons {
    color: #999;
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    padding: 8px;
    font-size: 14px;
    background: transparent;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    background: white;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 15px;
    gap: 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--secondary-color);
    transition: background 0.2s;
    position: relative;
}

.chat-item:hover {
    background: var(--secondary-color);
}

.chat-item.active {
    background: var(--message-sent);
    border-right: 3px solid var(--primary-color);
}

.chat-item .material-icons {
    color: var(--primary-color);
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-info h4 {
    margin-bottom: 5px;
    font-size: 15px;
    font-weight: 600;
}

.chat-info p {
    color: #666;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-time {
    font-size: 12px;
    color: #999;
    white-space: nowrap;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
}

.chat-header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.chat-partner {
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-partner img {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-partner h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.chat-partner p {
    font-size: 13px;
    color: #666;
}

.messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f0f2f5;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 70%;
    display: flex;
    flex-direction: column;
    animation: messageAppear 0.3s ease;
}

@keyframes messageAppear {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.sent {
    align-self: flex-end;
    align-items: flex-end;
}

.message.received {
    align-self: flex-start;
    align-items: flex-start;
}

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    line-height: 1.4;
    max-width: 100%;
}

.message.sent .message-content {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received .message-content {
    background: white;
    color: var(--text-color);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message-sender {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
    font-weight: 600;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    padding: 0 4px;
}

.message-input {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--border-color);
    background: white;
}

.input-actions {
    display: flex;
    align-items: center;
}

.input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--secondary-color);
    border-radius: 25px;
    padding: 0 15px;
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
}

.input-wrapper input {
    flex: 1;
    border: none;
    outline: none;
    padding: 12px 5px;
    background: transparent;
    font-size: 15px;
    min-width: 0;
}

.send-btn {
    background: var(--primary-color) !important;
    color: white !important;
    border-radius: 50% !important;
    width: 48px !important;
    height: 48px !important;
    flex-shrink: 0;
}

.send-btn .material-icons {
    font-size: 20px;
}

/* Friends Sidebar */
.friends-sidebar {
    width: 280px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: white;
}

.friends-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: var(--secondary-color);
}

.friends-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

#friendsOnlineList {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.friend-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    gap: 12px;
    cursor: pointer;
    border-radius: 10px;
    transition: background 0.2s;
    margin-bottom: 5px;
}

.friend-item:hover {
    background: var(--secondary-color);
}

.friend-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    position: relative;
}

.friend-avatar.online::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: var(--online-color);
    border-radius: 50%;
    border: 2px solid white;
}

.friend-item span {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    min-width: 400px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalAppear 0.3s ease;
}

@keyframes modalAppear {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.modal-content h3 {
    margin-bottom: 20px;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-color);
}

.modal-content input {
    width: 100%;
    padding: 12px;
    margin: 15px 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s;
}

.modal-content input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.file-size-info {
    font-size: 14px;
    color: #666;
    margin: 10px 0;
    text-align: center;
}

/* File Preview */
.file-preview {
    max-width: 300px;
    margin-top: 10px;
}

.file-preview img, .file-preview audio {
    width: 100%;
    border-radius: 10px;
}

.file-preview img {
    max-height: 300px;
    object-fit: contain;
}

/* Mention */
.mention {
    background: #ffeb3b;
    padding: 2px 5px;
    border-radius: 4px;
    font-weight: bold;
    color: #333;
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 1001;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.notification.success {
    background: var(--success-color);
}

.notification.error {
    background: var(--error-color);
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.loading-spinner .material-icons {
    animation: spin 1s linear infinite;
    color: var(--primary-color);
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-state .material-icons {
    font-size: 48px;
    color: #ccc;
    margin-bottom: 15px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Responsive */
@media (max-width: 1200px) {
    .sidebar {
        width: 300px;
    }
    
    .friends-sidebar {
        width: 250px;
    }
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 15px;
    background: white;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    align-self: flex-start;
    max-width: fit-content;
    margin-bottom: 10px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #666;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}