/* Blindado - Dark UI Design System (iOS & Android Native Feel) */
:root {
    --bg-app: #090a0d;
    --bg-header: #111318;
    --bg-card: #181b22;
    --bg-bubble-me: #1e3a5f;
    --bg-bubble-peer: #1c202a;
    --border-color: #262a34;
    --primary: #3b82f6;
    --primary-active: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --danger-active: #dc2626;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-stack);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Header */
.app-header {
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
}

.peer-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: #ffffff;
    position: relative;
}

.status-dot {
    position: absolute;
    bottom: 0px;
    right: 0px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #64748b;
    border: 2px solid var(--bg-header);
    transition: background-color 0.3s;
}

.status-dot.online {
    background-color: var(--success);
}

.peer-details h2 {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
}

.peer-status {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.peer-status.online {
    color: var(--success);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.icon-btn:active {
    background: var(--bg-card);
    transform: scale(0.92);
}

.icon-btn.call-btn {
    background: #1e3a5f;
    color: #60a5fa;
}

.icon-btn.call-btn:active {
    background: #2563eb;
    color: #ffffff;
}

/* Chat Messages View */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    background-color: var(--bg-app);
    scroll-behavior: smooth;
}

.message-bubble {
    max-width: 82%;
    padding: 0.6rem 0.85rem;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.4;
    word-break: break-word;
    user-select: text;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.message-bubble.me {
    align-self: flex-end;
    background-color: var(--bg-bubble-me);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.message-bubble.peer {
    align-self: flex-start;
    background-color: var(--bg-bubble-peer);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

.bubble-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.3rem;
    margin-top: 0.25rem;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
    user-select: none;
}

.status-check {
    font-size: 0.8rem;
}

.status-check.delivered {
    color: #38bdf8;
}

/* Player de Áudio estilo WhatsApp */
.audio-player-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 210px;
    padding: 0.2rem 0;
}

.audio-play-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: var(--primary);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.1s;
}

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

.audio-track-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.audio-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
}

.audio-progress-fill {
    height: 100%;
    background: #38bdf8;
    border-radius: 2px;
    width: 0%;
}

.audio-duration {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    font-family: ui-monospace, SFMono-Regular, monospace;
}

/* Chat Input Bar & Gravador de Voz */
.chat-input-bar {
    background-color: var(--bg-header);
    border-top: 1px solid var(--border-color);
    padding: 0.6rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 10;
    position: relative;
}

.chat-input-bar input {
    flex: 1;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 0.7rem 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    user-select: text;
}

.chat-input-bar input:focus {
    border-color: var(--primary);
}

.action-btn {
    background-color: var(--primary);
    color: #ffffff;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
}

.action-btn:active {
    background-color: var(--primary-active);
    transform: scale(0.92);
}

.action-btn.mic-btn {
    background-color: #1e3a5f;
    color: #60a5fa;
}

.action-btn.mic-btn:active {
    background-color: #2563eb;
    color: #ffffff;
}

/* Barra de Gravação Ativa */
.recording-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-header);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    z-index: 20;
    display: none;
}

.recording-bar.active {
    display: flex;
}

.recording-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.recording-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #ef4444;
    animation: blink 1s infinite;
}

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

.recording-timer {
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: #ef4444;
}

.recording-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cancel-rec-btn {
    background-color: #334155;
    color: #f87171;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.send-rec-btn {
    background-color: var(--primary);
    color: #ffffff;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Modais e Overlays */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1.25rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

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

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 1.5rem;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.modal-card h3 {
    font-size: 1.2rem;
    font-weight: 700;
}

.fingerprint-box {
    background: #0b0f19;
    border: 1px solid #1e3a8a;
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
}

.fingerprint-numbers {
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 1.25rem;
    letter-spacing: 0.12em;
    color: #60a5fa;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.fingerprint-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
    border: none;
    padding: 0.75rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-danger {
    background-color: var(--danger);
    color: #ffffff;
    border: none;
    padding: 0.75rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}

.btn-secondary {
    background-color: var(--bg-header);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}

/* Modal de Chamada em Tela Cheia */
.call-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, #1e293b 0%, #090a0d 100%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: calc(env(safe-area-inset-top, 20px) + 2rem) 1.5rem calc(env(safe-area-inset-bottom, 20px) + 2.5rem);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.call-screen.active {
    opacity: 1;
    pointer-events: auto;
}

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

.call-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin: 0 auto 1.25rem;
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5); }
    70% { box-shadow: 0 0 0 20px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

.call-peer-name {
    font-size: 1.5rem;
    font-weight: 700;
}

.call-status {
    font-size: 0.95rem;
    color: #93c5fd;
    margin-top: 0.35rem;
}

.call-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.call-action-btn {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    cursor: pointer;
    transition: transform 0.1s;
}

.call-action-btn:active {
    transform: scale(0.9);
}

.call-action-btn.accept {
    background-color: var(--success);
    color: #ffffff;
}

.call-action-btn.reject, .call-action-btn.hangup {
    background-color: var(--danger);
    color: #ffffff;
}

.call-action-btn.mute {
    background-color: #334155;
    color: #ffffff;
}

.call-action-btn.mute.active {
    background-color: #ef4444;
}

/* Config / Login Overlay */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-app);
    z-index: 300;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem 1.5rem;
}
