/* ===== CSS Variables - Cores do Tema Dark ===== */
:root {
    /* Cores principais - tema escuro */
    --bg-primary: #0a0a0a;           /* Preto quase absoluto */
    --bg-secondary: #1a1a1a;          /* Cinza muito escuro */
    --bg-tertiary: #252525;           /* Cinza escuro */
    --bg-hover: #2a2a2a;               /* Hover suave */
    
    /* Cores de destaque */
    --accent-green: #1e3a1e;            /* Verde escuro */
    --accent-green-light: #2d5a2d;     /* Verde médio */
    --accent-blue: #1a2332;            /* Azul escuro */
    --accent-blue-light: #2a3441;      /* Azul médio */
    
    /* Cores de texto */
    --text-primary: #e0e0e0;            /* Branco suave */
    --text-secondary: #b0b0b0;          /* Cinza claro */
    --text-muted: #808080;              /* Cinza médio */
    --text-accent: #4a9eff;             /* Azul claro para links */
    
    /* Cores de status */
    --online: #4caf50;                 /* Verde online */
    --offline: #757575;                 /* Cinza offline */
    --away: #ffb74d;                    /* Amarelo ausente */
    --busy: #f44336;                    /* Vermelho ocupado */
    
    /* Outras cores */
    --border: #333333;                  /* Bordas sutis */
    --shadow: rgba(0, 0, 0, 0.5);       /* Sombras escuras */
    --message-sent: #1e3a1e;            /* Fundo mensagens enviadas */
    --message-received: #2a3441;          /* Fundo mensagens recebidas */
    
    /* Dimensões */
    --sidebar-width: 320px;
    --header-height: 60px;
    --status-bar-height: 30px;
    --border-radius: 8px;
    --border-radius-lg: 12px;
}

/* ===== Reset e estilos base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    user-select: none;
}

/* ===== Splash Screen ===== */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--accent-blue) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.splash-content {
    text-align: center;
    animation: fadeInUp 0.8s ease-out;
}

.splash-content .logo {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: pulse 2s infinite;
}

.splash-content h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(45deg, var(--text-primary), var(--text-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.splash-content p {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--text-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

/* ===== Login Screen ===== */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--accent-green) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.login-container {
    background: var(--bg-secondary);
    padding: 3rem;
    border-radius: var(--border-radius-lg);
    box-shadow: 0 10px 30px var(--shadow);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.login-container .logo {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.login-container h2 {
    font-size: 1.8rem;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

#login-form input {
    width: 100%;
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
}

#login-form input:focus {
    outline: none;
    border-color: var(--text-accent);
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(45deg, var(--accent-green-light), var(--accent-blue-light));
    border: none;
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.network-info {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ===== Main Interface ===== */
.main-interface {
    display: flex;
    height: 100vh;
    background: var(--bg-primary);
}

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

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

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(45deg, var(--accent-green), var(--accent-blue));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    color: white;
}

.user-avatar.large {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
}

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

.sidebar-search {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-search input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.sidebar-search input:focus {
    outline: none;
    border-color: var(--text-accent);
}

.users-list {
    flex: 1;
    overflow-y: auto;
}

.users-header {
    padding: 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

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

.user-item.active {
    background: var(--bg-hover);
    border-left-color: var(--text-accent);
}

.user-item-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

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

.user-item-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.user-item-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--online);
}

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

.status-indicator.busy {
    background: var(--busy);
}

.status-indicator.offline {
    background: var(--offline);
}

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

.chat-header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-details h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.chat-details .status {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.chat-actions {
    display: flex;
    gap: 0.5rem;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: var(--bg-primary);
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    animation: messageSlide 0.3s ease-out;
}

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

.message-bubble {
    max-width: 70%;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    position: relative;
}

.message.received .message-bubble {
    background: var(--message-received);
    border-bottom-left-radius: 4px;
}

.message.sent .message-bubble {
    background: var(--message-sent);
    border-bottom-right-radius: 4px;
}

.message-text {
    color: var(--text-primary);
    line-height: 1.4;
    word-wrap: break-word;
}

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

.message-status {
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

.message-status.sent::after {
    content: "✓";
    color: var(--text-muted);
}

.message-status.delivered::after {
    content: "✓✓";
    color: var(--text-muted);
}

.message-status.read::after {
    content: "✓✓";
    color: var(--text-accent);
}

/* ===== Message Input ===== */
.message-input-container {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 1rem;
}

.message-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.message-input-area {
    flex: 1;
    position: relative;
}

#message-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

#message-input:focus {
    outline: none;
    border-color: var(--text-accent);
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}

.typing-indicator {
    position: absolute;
    bottom: -1.5rem;
    left: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ===== Buttons ===== */
.btn-icon {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

.btn-send {
    width: 40px;
    height: 40px;
    border: none;
    background: linear-gradient(45deg, var(--accent-green-light), var(--accent-blue-light));
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s ease;
}

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

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

/* ===== Emoji Picker ===== */
.emoji-picker {
    position: absolute;
    bottom: 80px;
    right: 20px;
    width: 350px;
    height: 400px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 10px 30px var(--shadow);
    z-index: 1000;
}

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

.emoji-categories {
    display: flex;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
    gap: 0.25rem;
}

.emoji-category {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
}

.emoji-category.active,
.emoji-category:hover {
    background: var(--bg-hover);
}

.emoji-grid {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.25rem;
}

.emoji-item {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
}

.emoji-item:hover {
    background: var(--bg-hover);
    transform: scale(1.1);
}

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

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 20px 60px var(--shadow);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
}

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

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.setting-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.setting-group:last-child {
    border-bottom: none;
}

/* ===== Switch Toggle ===== */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--text-muted);
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--text-accent);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* ===== Status Bar ===== */
.status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--status-bar-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    z-index: 100;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.status-dot.connecting {
    background: var(--away);
    animation: pulse 1.5s infinite;
}

.status-dot.error {
    background: var(--busy);
}

/* ===== Utilidades ===== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

/* ===== Scrollbars ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ===== Animações ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

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

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

/* ===== Responsividade ===== */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
    }
    
    .sidebar {
        position: fixed;
        left: -100%;
        z-index: 1000;
        transition: left 0.3s ease;
    }
    
    .sidebar.mobile-open {
        left: 0;
    }
    
    .messages-container {
        padding: 1rem;
    }
    
    .message-bubble {
        max-width: 85%;
    }
    
    .emoji-picker {
        width: 90%;
        right: 5%;
        left: 5%;
    }
}

@media (max-width: 480px) {
    .login-container {
        padding: 2rem;
        margin: 1rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    :root {
        --header-height: 50px;
    }
}