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

html {
    touch-action: manipulation;
    -ms-touch-action: manipulation;
    overflow: hidden;
    height: 100%;
    width: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #111b21;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    user-select: none;
    -webkit-user-select: none;
}

.hidden { display: none !important; }

/* ========== LOCKSCREEN ========== */
.lockscreen {
    height: 100vh;
    width: 100vw;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #0a0a0a 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 15vh;
    cursor: pointer;
}

.lock-time {
    font-size: 72px;
    font-weight: 200;
    color: #fff;
    letter-spacing: 2px;
}

.lock-date {
    font-size: 16px;
    color: rgba(255,255,255,0.7);
    margin-bottom: 40px;
}

.notification {
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    padding: 12px;
    animation: slideDown 0.5s ease-out;
}

@keyframes slideDown {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.notif-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.notif-icon {
    width: 18px;
    height: 18px;
}

.notif-app {
    font-size: 13px;
    color: rgba(255,255,255,0.5);
    flex: 1;
}

.notif-time {
    font-size: 12px;
    color: rgba(255,255,255,0.4);
}

.notif-body {
    display: flex;
    gap: 10px;
}

.notif-content {
    flex: 1;
}

.notif-content strong {
    color: #fff;
    font-size: 15px;
    display: block;
    margin-bottom: 2px;
}

.notif-content p {
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notif-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.lock-hint {
    color: rgba(255,255,255,0.3);
    font-size: 13px;
    margin-top: 20px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

/* ========== CHAT APP ========== */
.chat-app {
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    background: #0b141a;
    max-width: 500px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

/* Header */
.chat-header {
    background: #1f2c34;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.back-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.header-info {
    display: flex;
    flex-direction: column;
}

.header-name {
    color: #e9edef;
    font-size: 16px;
    font-weight: 500;
}

.header-status {
    color: #8696a0;
    font-size: 13px;
}

.header-right {
    display: flex;
    gap: 12px;
}

.header-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

/* Chat Body */
.chat-body {
    flex: 1;
    overflow-y: auto;
    position: relative;
    background: #0b141a;
}

.chat-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='400' height='400' xmlns='http://www.w3.org/2000/svg'%3E%3Cdefs%3E%3Cpattern id='p' width='40' height='40' patternUnits='userSpaceOnUse'%3E%3Cpath d='M20 5c-1 0-2 1-2 2s1 2 2 2 2-1 2-2-1-2-2-2zm-10 10c-1 0-2 1-2 2s1 2 2 2 2-1 2-2-1-2-2-2zm20 0c-1 0-2 1-2 2s1 2 2 2 2-1 2-2-1-2-2-2zm-10 10c-1 0-2 1-2 2s1 2 2 2 2-1 2-2-1-2-2-2z' fill='%23ffffff' fill-opacity='0.02'/%3E%3C/pattern%3E%3C/defs%3E%3Crect width='400' height='400' fill='url(%23p)'/%3E%3C/svg%3E");
    opacity: 0.5;
}

.messages-container {
    position: relative;
    z-index: 1;
    padding: 8px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 100%;
}

/* Mensagens */
.message {
    max-width: 85%;
    padding: 6px 8px 2px;
    border-radius: 8px;
    position: relative;
    animation: msgIn 0.3s ease-out;
    line-height: 1.45;
}

@keyframes msgIn {
    from { transform: scale(0.9) translateY(10px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.message.received {
    background: #1f2c34;
    align-self: flex-start;
    border-top-left-radius: 0;
    color: #e9edef;
}

.message.received:first-of-type,
.message.received.first {
    border-top-left-radius: 8px;
}

.message.received::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    border-width: 0 8px 8px 0;
    border-style: solid;
    border-color: transparent #1f2c34 transparent transparent;
}

.msg-text {
    font-size: 14.5px;
    padding-right: 50px;
    padding-bottom: 4px;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.msg-text b, .msg-text strong {
    color: #fff;
    font-weight: 600;
}

.msg-time {
    font-size: 11px;
    color: rgba(255,255,255,0.45);
    float: right;
    margin-top: -14px;
    margin-right: -4px;
}

/* Link dentro da mensagem */
.msg-link {
    display: inline-block;
    background: rgba(0, 150, 100, 0.15);
    border: 1px solid rgba(0, 150, 100, 0.3);
    border-radius: 8px;
    padding: 8px 12px;
    margin: 6px 0;
    color: #53bdeb;
    text-decoration: none;
    font-size: 13px;
    word-break: break-all;
    transition: background 0.2s;
}

.msg-link:active {
    background: rgba(0, 150, 100, 0.3);
}

/* Botao de resposta rapida */
.quick-reply-container {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    width: 85%;
    max-width: 85%;
}

.quick-reply-btn {
    flex: 1;
    background: #1f2c34;
    border: 1px solid #2a3942;
    border-radius: 8px;
    color: #53bdeb;
    font-size: 14px;
    font-weight: 500;
    padding: 10px 16px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    animation: msgIn 0.3s ease-out;
}

.quick-reply-btn:active {
    background: #2a3942;
    transform: scale(0.97);
}

.quick-reply-btn.selected {
    background: #005c4b;
    border-color: #005c4b;
    color: #fff;
    pointer-events: none;
}

/* Mensagem enviada (resposta do usuario) */
.message.sent {
    background: #005c4b;
    align-self: flex-end;
    border-top-right-radius: 0;
    color: #e9edef;
}

.message.sent::after {
    content: '';
    position: absolute;
    top: 0;
    right: -8px;
    border-width: 0 0 8px 8px;
    border-style: solid;
    border-color: transparent transparent transparent #005c4b;
}

.message.sent .msg-time {
    color: rgba(255,255,255,0.55);
}

.message.sent .msg-time::after {
    content: ' ✓✓';
    color: #53bdeb;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #1f2c34;
    border-radius: 8px;
    border-top-left-radius: 0;
    align-self: flex-start;
    animation: msgIn 0.3s ease-out;
}

.typing-indicator::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    border-width: 0 8px 8px 0;
    border-style: solid;
    border-color: transparent #1f2c34 transparent transparent;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #8696a0;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Audio message */
.audio-message {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    min-width: 260px;
}

.audio-play-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #00a884;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s;
}

.audio-play-btn:active {
    transform: scale(0.9);
}

.audio-play-btn svg {
    fill: #fff;
}

.audio-waveform {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.waveform-bars {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 28px;
}

.waveform-bar {
    width: 3px;
    background: #8696a0;
    border-radius: 2px;
    transition: background 0.2s;
}

.waveform-bar.played {
    background: #00a884;
}

.audio-time-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.audio-time {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
}

.audio-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

/* Audio avatar wrapper (speed overlay like WhatsApp) */
.audio-avatar-wrapper {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.audio-speed-btn {
    position: absolute;
    top: 0;
    left: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #00a884;
    border: none;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    z-index: 2;
    transition: transform 0.15s;
}

.audio-speed-btn:active {
    transform: scale(0.9);
}

/* Audio message wrapper */
.audio-msg-wrapper {
    padding-bottom: 6px;
}

/* Transcription toggle */
.audio-transcription-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px 2px;
    cursor: pointer;
    user-select: none;
}

.audio-transcription-toggle span {
    font-size: 12px;
    color: #53bdeb;
    flex: 1;
}

.audio-transcription-toggle .chevron-icon {
    transition: transform 0.3s;
}

/* Transcription content */
.audio-transcription-content {
    padding: 8px 12px 4px;
    border-top: 1px solid rgba(255,255,255,0.06);
    margin: 4px 6px 0;
    animation: transcriptionIn 0.3s ease-out;
}

@keyframes transcriptionIn {
    from { opacity: 0; max-height: 0; }
    to { opacity: 1; max-height: 500px; }
}

.audio-transcription-content p {
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Input bar */
.chat-input-bar {
    background: #1f2c34;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-field {
    flex: 1;
    background: #2a3942;
    border-radius: 24px;
    padding: 10px 16px;
    color: #e9edef;
    font-size: 15px;
    border: none;
    outline: none;
    font-family: inherit;
}

.input-field::placeholder {
    color: #8696a0;
}

.input-left {
    display: flex;
    padding: 4px;
}

.input-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.input-action-btn.recording {
    background: #ea4335;
    border-radius: 50%;
    animation: recPulse 1s infinite;
}

.input-action-btn.recording svg { fill: #fff; }

@keyframes recPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(234,67,53,0.4); }
    50% { box-shadow: 0 0 0 10px rgba(234,67,53,0); }
}

/* Recording bar */
.recording-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    color: #ea4335;
    font-size: 14px;
}

.rec-dot {
    width: 8px;
    height: 8px;
    background: #ea4335;
    border-radius: 50%;
    animation: blink 1s infinite;
}

.rec-time {
    color: #e9edef;
    font-size: 14px;
}

.rec-cancel {
    color: #8696a0;
    font-size: 13px;
    margin-left: auto;
}

/* User voice message */
.user-audio-message {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    min-width: 180px;
}

.user-audio-play-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #00a884;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-audio-play-btn svg { fill: #fff; }

.user-audio-waveform {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-audio-bars {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 24px;
}

.user-audio-time {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
}

/* ========== CTA OVERLAY ========== */
.cta-overlay {
    position: fixed;
    bottom: 56px;
    left: 0;
    right: 0;
    z-index: 100;
    animation: ctaSlideUp 0.5s ease-out;
}

@keyframes ctaSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.cta-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 16px;
    background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.7) 70%, transparent 100%);
    text-align: center;
}

.cta-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #25D366;
    color: #fff;
    text-decoration: none;
    padding: 16px 32px;
    border-radius: 50px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 20px rgba(37, 211, 102, 0.4);
    animation: ctaPulse 2s infinite;
    position: relative;
    z-index: 2;
}

.cta-button:active {
    transform: scale(0.97);
}

@keyframes ctaPulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(37, 211, 102, 0.4); }
    50% { box-shadow: 0 4px 35px rgba(37, 211, 102, 0.7); }
}

.cta-spots {
    color: #ff6b6b;
    font-size: 13px;
    font-weight: 600;
    margin-top: 8px;
    animation: blink 1.5s infinite;
}

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

/* Scrollbar */
.chat-body::-webkit-scrollbar { width: 6px; }
.chat-body::-webkit-scrollbar-track { background: transparent; }
.chat-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

/* WhatsApp Popup */
.whatsapp-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.whatsapp-popup.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.whatsapp-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
}

.whatsapp-popup-content {
    position: relative;
    background: #1f2c34;
    border-radius: 16px;
    padding: 28px 24px;
    width: 85%;
    max-width: 340px;
    text-align: center;
    animation: popIn 0.3s ease-out;
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.whatsapp-popup-content p {
    color: #e9edef;
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 20px;
}

.whatsapp-popup-content strong {
    color: #25D366;
}

.whatsapp-popup-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #25D366;
    color: #fff;
    text-decoration: none;
    padding: 14px 24px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    transition: transform 0.15s;
}

.whatsapp-popup-btn:active {
    transform: scale(0.96);
}

.whatsapp-popup-close {
    background: none;
    border: none;
    color: #8696a0;
    font-size: 14px;
    cursor: pointer;
    padding: 8px;
}

/* Telas muito pequenas */
@media (max-width: 340px) {
    .lock-time { font-size: 56px; }
    .lock-date { font-size: 14px; }
    .notification { width: 94%; padding: 10px; }
    .msg-text { font-size: 13.5px; }
    .audio-message { min-width: 220px; gap: 6px; }
    .waveform-bars { gap: 1px; }
    .waveform-bar { width: 2px; }
    .cta-button { padding: 14px 20px; font-size: 15px; }
}

/* Desktop */
@media (min-width: 501px) {
    .chat-app {
        border-left: 1px solid #2a3942;
        border-right: 1px solid #2a3942;
    }
}
