/* SnakkaZ - Modern Telegram-style Design */

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

:root {
    --primary: #0088cc;
    --primary-dark: #006699;
    --bg-main: #ffffff;
    --bg-chat: #f5f5f5;
    --bg-message-in: #ffffff;
    --bg-message-out: #e7f3ff;
    --text-primary: #000000;
    --text-secondary: #707579;
    --border: #e0e0e0;
    --shadow: 0 1px 2px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-main);
}

/* Auth Screen */
.auth-screen {
    display: none;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-screen.active {
    display: flex;
}

.auth-container {
    background: white;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.auth-logo h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--primary);
}

.auth-logo p {
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--bg-chat);
    padding: 4px;
    border-radius: 8px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
}

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

.auth-form {
    display: none;
}

.auth-form.active {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-form input {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: border 0.2s;
}

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

.btn-primary {
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

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

.btn-primary:active {
    transform: scale(0.98);
}

.error-msg {
    color: #e74c3c;
    font-size: 13px;
    padding: 8px 12px;
    background: #fee;
    border-radius: 6px;
    display: none;
}

.error-msg:not(:empty) {
    display: block;
}

/* Chat Screen */
.chat-screen {
    display: none;
    height: 100vh;
    grid-template-columns: 320px 1fr;
}

.chat-screen.active {
    display: grid;
}

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

.sidebar-header {
    padding: 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: background 0.2s;
}

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

.search-input {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: var(--bg-chat);
    border-radius: 20px;
    font-size: 14px;
}

.search-input:focus {
    outline: none;
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.tab {
    flex: 1;
    padding: 14px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
}

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

.channels-list, .users-list {
    padding: 8px 0;
}

.channel-item, .user-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.1s;
}

.channel-item:hover, .user-item:hover {
    background: var(--bg-chat);
}

.channel-item.active {
    background: var(--bg-chat);
}

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

.channel-info, .user-info {
    flex: 1;
    min-width: 0;
}

.channel-name, .user-name {
    font-weight: 500;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel-last-message, .user-status {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-status.online {
    color: #4caf50;
}

/* Chat Area */
.chat-area {
    display: flex;
    flex-direction: column;
    background: var(--bg-chat);
}

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

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

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

.chat-info h3 {
    font-size: 15px;
    font-weight: 500;
}

.chat-status {
    font-size: 13px;
    color: var(--text-secondary);
}

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

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

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

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.message {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.message.outgoing {
    flex-direction: row-reverse;
}

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

.message-content {
    max-width: 60%;
    background: var(--bg-message-in);
    padding: 8px 12px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.message.outgoing .message-content {
    background: var(--bg-message-out);
}

.message-author {
    font-weight: 600;
    font-size: 13px;
    color: var(--primary);
    margin-bottom: 2px;
}

.message.outgoing .message-author {
    display: none;
}

.message-text {
    word-wrap: break-word;
}

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

/* Message Input */
.message-input-area {
    background: white;
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.input-wrapper {
    flex: 1;
    background: var(--bg-chat);
    border-radius: 20px;
    padding: 8px 16px;
}

.input-wrapper textarea {
    width: 100%;
    border: none;
    background: transparent;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    max-height: 120px;
}

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

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

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

/* Profile Sidebar */
.profile-sidebar {
    position: fixed;
    right: -320px;
    top: 0;
    bottom: 0;
    width: 320px;
    background: white;
    border-left: 1px solid var(--border);
    transition: right 0.3s;
    z-index: 100;
}

.profile-sidebar.active {
    right: 0;
}

.profile-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-header h3 {
    font-size: 16px;
    font-weight: 500;
}

.profile-content {
    padding: 32px 24px;
    text-align: center;
}

.profile-avatar-large {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    margin: 0 auto 24px;
}

.profile-content h2 {
    font-size: 20px;
    margin-bottom: 8px;
}

.profile-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.btn-secondary {
    width: 100%;
    padding: 12px;
    background: var(--bg-chat);
    color: var(--text-primary);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

/* Responsive */
@media (max-width: 768px) {
    .chat-screen {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        display: none;
    }
    
    .sidebar.mobile-visible {
        display: flex;
    }
    
    .chat-area.mobile-hidden {
        display: none;
    }
}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
