/**
 * FALLEZAP - ESTILO VISUAL COMPLETO (style.css)
 * Identidade visual inspirada em mensageiros modernos (estilo WhatsApp)
 * Responsivo, Mobile-First, Rápido, Acessível, Sem bibliotecas externas.
 */

:root {
    --fz-primary: #00a884;
    --fz-primary-dark: #075e54;
    --fz-primary-deep: #128c7e;
    --fz-bg-auth: #111b21;
    --fz-bg-header: #202c33;
    --fz-bg-panel: #111b21;
    --fz-bg-chat: #0b141a;
    --fz-bubble-in: #202c33;
    --fz-bubble-out: #005c4b;
    --fz-text-main: #e9edef;
    --fz-text-muted: #8696a0;
    --fz-border: #222d34;
    --fz-active: #2a3942;
    --fz-danger: #ea4335;
    --fz-accent: #25d366;
    --fz-card: #202c33;
    --fz-input-bg: #2a3942;
    --fz-font: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

/* Reset Geral */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--fz-font);
    background-color: var(--fz-bg-panel);
    color: var(--fz-text-main);
    line-height: 1.4;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* Páginas de Autenticação (Login / Cadastro) */
.auth-body {
    overflow-y: auto;
    background-color: var(--fz-bg-auth);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 16px;
}

.auth-wrapper {
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 10;
}

.auth-header-band {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 180px;
    background: linear-gradient(135deg, var(--fz-primary-dark) 0%, var(--fz-primary-deep) 100%);
    z-index: 1;
}

.auth-card {
    position: relative;
    z-index: 10;
    background: var(--fz-card);
    border-radius: 16px;
    padding: 28px 24px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    border: 1px border var(--fz-border);
}

.brand-box {
    text-align: center;
    margin-bottom: 24px;
}

.brand-logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    background: linear-gradient(135deg, var(--fz-primary) 0%, var(--fz-primary-deep) 100%);
    color: white;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(0, 168, 132, 0.3);
}

.brand-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--fz-text-main);
}

.brand-subtitle {
    font-size: 13px;
    color: var(--fz-text-muted);
    margin-top: 4px;
}

/* Formulários */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--fz-text-muted);
}

.input-with-prefix {
    display: flex;
    align-items: center;
    background: var(--fz-input-bg);
    border: 1px solid var(--fz-border);
    border-radius: 10px;
    overflow: hidden;
}

.input-with-prefix .prefix {
    padding: 0 12px;
    font-weight: 700;
    color: var(--fz-primary);
    font-size: 16px;
}

.input-with-prefix input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    padding: 12px 12px 12px 0;
    color: var(--fz-text-main);
    font-size: 15px;
    font-family: inherit;
}

.phone-split-input {
    display: flex;
    gap: 8px;
}

.input-ddd-box {
    width: 80px;
}

.input-number-box {
    flex: 1;
}

.sub-label {
    display: block;
    font-size: 11px;
    color: var(--fz-text-muted);
    margin-bottom: 4px;
}

.phone-split-input input,
.form-group input {
    width: 100%;
    background: var(--fz-input-bg);
    border: 1px solid var(--fz-border);
    border-radius: 10px;
    padding: 12px;
    color: var(--fz-text-main);
    font-size: 15px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.phone-split-input input:focus,
.form-group input:focus {
    border-color: var(--fz-primary);
}

.input-with-action {
    position: relative;
}

.btn-toggle-pass {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--fz-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.helper-text {
    font-size: 11px;
    color: var(--fz-text-muted);
}

.identifier-preview-badge {
    background: rgba(0, 168, 132, 0.12);
    border: 1px solid rgba(0, 168, 132, 0.25);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    color: var(--fz-primary);
    text-align: center;
}

.security-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(134, 150, 160, 0.08);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 11px;
    color: var(--fz-text-muted);
}

.btn {
    border: none;
    border-radius: 10px;
    padding: 13px 18px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
}

.btn-primary {
    background: var(--fz-primary);
    color: #111b21;
}

.btn-primary:hover {
    background: #06cf9c;
}

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

.btn-block {
    width: 100%;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
    color: var(--fz-text-muted);
}

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

/* LAYOUT DO APLICATIVO DE CHAT ESTILO WHATSAPP */
.chat-body {
    height: 100vh;
    height: 100dvh;
    display: flex;
}

.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: var(--fz-bg-panel);
    overflow: hidden;
    position: relative;
}

/* Barra Lateral (Lista de Conversas) */
.sidebar {
    width: 380px;
    min-width: 320px;
    height: 100%;
    border-right: 1px solid var(--fz-border);
    display: flex;
    flex-direction: column;
    background: var(--fz-bg-panel);
    z-index: 5;
    transition: transform 0.25s ease;
}

.sidebar-header {
    height: 60px;
    background: var(--fz-bg-header);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--fz-border);
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--fz-primary-dark);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 15px;
    overflow: hidden;
    flex-shrink: 0;
}

.user-profile-info {
    display: flex;
    flex-direction: column;
}

.user-name-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--fz-text-main);
}

.user-id-tag {
    font-size: 11px;
    color: var(--fz-primary);
    font-family: monospace;
}

.sidebar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--fz-text-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

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

/* Barra de Busca */
.search-container {
    padding: 8px 14px;
    background: var(--fz-bg-panel);
    border-bottom: 1px solid var(--fz-border);
}

.search-box {
    background: var(--fz-input-bg);
    border-radius: 8px;
    height: 36px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--fz-text-main);
    font-size: 14px;
    width: 100%;
    font-family: inherit;
}

/* Lista de Conversas */
.conversations-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    cursor: pointer;
    border-bottom: 1px solid rgba(34, 45, 52, 0.5);
    transition: background 0.15s;
}

.conversation-item:hover {
    background: var(--fz-input-bg);
}

.conversation-item.active {
    background: var(--fz-active);
}

.conv-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #374248;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    flex-shrink: 0;
}

.conv-content {
    flex: 1;
    min-width: 0;
}

.conv-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 3px;
}

.conv-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--fz-text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-time {
    font-size: 11px;
    color: var(--fz-text-muted);
}

.conv-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conv-last-msg {
    font-size: 13px;
    color: var(--fz-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.conv-badge {
    background: var(--fz-primary);
    color: #111b21;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* Área Principal do Chat */
.chat-area {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--fz-bg-chat);
    position: relative;
}

/* Placeholder vazio quando nenhuma conversa estiver aberta */
.empty-chat-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
    background: var(--fz-bg-panel);
    border-bottom: 6px solid var(--fz-primary);
}

.empty-chat-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(0, 168, 132, 0.1);
    color: var(--fz-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.empty-chat-state h2 {
    font-size: 24px;
    font-weight: 400;
    color: var(--fz-text-main);
    margin-bottom: 8px;
}

.empty-chat-state p {
    font-size: 14px;
    color: var(--fz-text-muted);
    max-width: 440px;
    line-height: 1.5;
}

.empty-chat-e2ee-tag {
    margin-top: 24px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--fz-text-muted);
}

/* Header do Chat Ativo */
.chat-header {
    height: 60px;
    background: var(--fz-bg-header);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--fz-border);
    z-index: 2;
}

.chat-header-user {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.btn-back-mobile {
    display: none;
}

.chat-header-details {
    display: flex;
    flex-direction: column;
}

.chat-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--fz-text-main);
}

.chat-status-indicator {
    font-size: 12px;
    color: var(--fz-text-muted);
}

/* Mensagens (Corpo do Chat) */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background-image: radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 20px 20px;
}

.e2ee-encryption-banner {
    background: rgba(32, 44, 51, 0.85);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 12px;
    color: #ffd279;
    text-align: center;
    max-width: 480px;
    margin: 0 auto 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Balões de Mensagem */
.message-bubble {
    max-width: 65%;
    padding: 8px 12px 6px;
    border-radius: 8px;
    font-size: 14.5px;
    position: relative;
    word-break: break-word;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
}

.message-bubble.incoming {
    align-self: flex-start;
    background: var(--fz-bubble-in);
    color: var(--fz-text-main);
    border-top-left-radius: 0;
}

.message-bubble.outgoing {
    align-self: flex-end;
    background: var(--fz-bubble-out);
    color: var(--fz-text-main);
    border-top-right-radius: 0;
}

.message-text {
    line-height: 1.4;
}

.message-meta {
    align-self: flex-end;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
}

.ticks-delivered {
    color: #53bdeb;
}

/* Barra de Digitação (Footer do Chat) */
.chat-footer {
    min-height: 62px;
    background: var(--fz-bg-header);
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--fz-border);
}

.chat-input-wrapper {
    flex: 1;
    background: var(--fz-input-bg);
    border-radius: 20px;
    padding: 4px 14px;
    display: flex;
    align-items: center;
}

.chat-input-wrapper textarea {
    width: 100%;
    max-height: 100px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--fz-text-main);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    line-height: 1.4;
    padding: 6px 0;
}

.btn-send-message {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--fz-primary);
    color: #111b21;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s, background 0.15s;
    flex-shrink: 0;
}

.btn-send-message:hover {
    background: #06cf9c;
}

.btn-send-message:active {
    transform: scale(0.92);
}

/* Modal de Novo Contato */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-dialog {
    background: var(--fz-card);
    width: 100%;
    max-width: 420px;
    border-radius: 14px;
    padding: 24px;
    border: 1px solid var(--fz-border);
    box-shadow: 0 16px 40px rgba(0,0,0,0.5);
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--fz-text-main);
    margin-bottom: 8px;
}

/* Toast de Notificação */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--fz-card);
    color: var(--fz-text-main);
    border: 1px solid var(--fz-border);
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 13.5px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
    animation: slideIn 0.2s ease forwards;
}

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

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

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

/* RESPONSIVIDADE MOBILE-FIRST */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
    }

    .chat-area {
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        transform: translateX(100%);
        transition: transform 0.25s ease;
    }

    .app-container.chat-open .sidebar {
        transform: translateX(-100%);
    }

    .app-container.chat-open .chat-area {
        transform: translateX(0);
    }

    .btn-back-mobile {
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: var(--fz-text-muted);
        margin-right: 4px;
        cursor: pointer;
    }

    .message-bubble {
        max-width: 85%;
    }
}
