/**
 * FALLEZAP - ESTILO VISUAL COMPLETO (style.css)
 * Identidade visual inspirada no WhatsApp: Moderna, responsiva, mobile-first.
 * Suporta fotos, gravações de áudio/voz, PWA e notificações.
 */

: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;
}

* {
    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 */
.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 solid 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; color: var(--fz-text-main); }
.brand-subtitle { font-size: 13px; color: var(--fz-text-muted); margin-top: 4px; }

.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; }

.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;
}
.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;
}

.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;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    transition: background-color 0.2s, transform 0.1s;
}
.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 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;
}

.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;
    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: 38px;
    height: 38px;
    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); }

/* Banner PWA para Instalar */
.pwa-banner-install {
    background: linear-gradient(90deg, #075e54 0%, #128c7e 100%);
    color: white;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
}
.pwa-btn-install {
    background: #25d366;
    color: #111b21;
    border: none;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 11px;
    cursor: pointer;
}

/* 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%; }

/* 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 do Chat */
.chat-area { flex: 1; height: 100%; display: flex; flex-direction: column; background: var(--fz-bg-chat); position: relative; }
.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; }

/* Header do Chat */
.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);
}
.chat-header-user { display: flex; align-items: center; gap: 12px; }
.btn-back-mobile { display: none; }
.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 */
.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;
}

.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-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; }

/* Anexos de Mídia e Imagens */
.bubble-image-preview {
    max-width: 280px;
    max-height: 280px;
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
    object-fit: cover;
}

/* Player de Áudio de Voz Estilo WhatsApp */
.audio-player-bubble {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 220px;
    padding: 4px 0;
}
.audio-play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.audio-play-btn:hover { background: rgba(255,255,255,0.3); }
.audio-progress-bar {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}
.audio-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--fz-accent);
}
.audio-time-label {
    font-size: 11px;
    color: rgba(255,255,255,0.8);
    font-family: monospace;
}

/* Anexo de Arquivo Documento */
.file-attachment-bubble {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.15);
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 4px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}
.file-attachment-icon {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    background: var(--fz-primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

/* Footer / Input do Chat */
.chat-footer {
    min-height: 62px;
    background: var(--fz-bg-header);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid var(--fz-border);
    position: relative;
}

.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;
    padding: 6px 0;
}

.btn-action-circle {
    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;
    flex-shrink: 0;
    transition: transform 0.15s, background 0.15s;
}
.btn-action-circle:hover { background: #06cf9c; }
.btn-action-circle:active { transform: scale(0.92); }

/* Barra de Gravação de Áudio ao Vivo */
.voice-recording-bar {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: var(--fz-bg-header);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 10;
}
.record-pulse {
    width: 12px;
    height: 12px;
    background: var(--fz-danger);
    border-radius: 50%;
    animation: pulse 1s infinite alternate;
}
@keyframes pulse { from { opacity: 0.3; } to { opacity: 1; } }
.record-timer {
    font-size: 15px;
    font-weight: 600;
    color: var(--fz-text-main);
    font-family: monospace;
}

/* Modais e Toasts */
.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);
}
.modal-title { font-size: 18px; font-weight: 700; color: var(--fz-text-main); margin-bottom: 8px; }

.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);
}
.toast-success { border-left: 4px solid var(--fz-primary); }
.toast-error { border-left: 4px solid var(--fz-danger); }

/* Responsividade Mobile */
@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); cursor: pointer; }
    .message-bubble { max-width: 85%; }
}
