:root {
    --wa-green: #128C7E;
    --wa-light-green: #25D366;
    --wa-teal: #075E54;
    --wa-light-gray: #F0F2F5;
    --wa-chat-bg: #E4DDD6;
    --wa-outgoing-bg: #DCF8C6;
    --wa-incoming-bg: #FFFFFF;
    --wa-gray-text: #667781;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'Helvetica Neue', sans-serif;
}

body {
    background-color: var(--wa-light-gray);
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.app-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 800px;
    height: 100vh;
    background-color: white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.header {
    background-color: var(--wa-teal);
    color: white;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    height: 60px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.header-title {
    display: flex;
    align-items: center;
    flex: 1;
}

.header-title h1 {
    font-size: 18px;
    margin-left: 15px;
}

.fa-face-smile {
    font-size: 40px;
    color: #ffcc00;
}

.header-actions {
    display: flex;
    gap: 16px;
}

.header-btn {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
}

.header-btn-reject {
    width: 35px;
    height: 35px;
    border-radius: 50px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
    cursor: pointer;
    background-color: #e53935;
}


.main-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(100% - 120px);
    margin-top: 60px;
    margin-bottom: 60px;
    overflow-y: auto;
    background-color: var(--wa-chat-bg);
}

.info-bar {
    background-color: #F0F4F9;
    padding: 10px 16px;
    color: var(--wa-gray-text);
    font-size: 13px;
    text-align: center;
    border-bottom: 1px solid #E5E5E5;
}

.info-bar1 {
    padding: 10px 16px;
}

.status-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

#connectedPeers {
    font-size: 13px;
    color: white;
}

#connectionStatus {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.online {
    background-color: #25D366;
    box-shadow: 0 0 5px #25D366;
}

.status-indicator.offline {
    background-color: #ff4444;
    box-shadow: 0 0 5px #ff4444;
}

#statusText {
    color: white;
    font-weight: 500;
}

.peer-id-section {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin-bottom: 5px;
}

.peer-id {
    font-family: monospace;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 1em;
    border: 1px solid #ddd;
    margin: 12px;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.1em;
    cursor: pointer;
    color: #fff;
}

.audio-container {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 20px 0;
}

.videos {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 20px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.videos.active {
    display: contents;
}

.video-container {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.video-container label {
    position: absolute;
    left: 0;
    color: white;
    padding: 8px;
}

video {
    width: 100%;
    height: auto;
}

canvas {
    background-color: #111;
    border-radius: 8px;
    margin-top: 8px;
}

.remote-video-container {
    display: none;
}

.remote-video-container.active {
    display: block;
}

.chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    opacity: 0.9;
    height: 100vh;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 10px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    scroll-behavior: smooth;
}

.message {
    max-width: 75%;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 7px;
    position: relative;
    box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
    word-wrap: break-word;
}

.message.outgoing {
    background-color: var(--wa-outgoing-bg);
    align-self: flex-end;
    margin-left: auto;
    border-top-right-radius: 0;
}

.message.incoming {
    background-color: var(--wa-incoming-bg);
    align-self: flex-start;
    border-top-left-radius: 0;
}

.message-time,
.metadata {
    display: block;
    text-align: right;
    font-size: 0.75em;
    color: var(--wa-gray-text);
    margin-top: 4px;
}

.ticks {
    color: #4fc3f7;
    margin-left: 5px;
}

.file-input-hidden {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

.chat-attachment-img {
    display: block;
    max-width: 100%;
    max-height: 220px;
    border-radius: 8px;
    margin-bottom: 4px;
    object-fit: contain;
}

.chat-attachment-video {
    display: block;
    max-width: 100%;
    max-height: 240px;
    border-radius: 8px;
    margin-bottom: 4px;
    background: #000;
}

.chat-attachment-audio {
    display: block;
    width: 100%;
    max-width: 280px;
    margin-bottom: 4px;
}

.chat-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 14px;
    border-radius: 20px;
    background-color: var(--wa-green);
    color: white;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.chat-download-btn:hover {
    background-color: var(--wa-teal);
    color: white;
}

.message.incoming .chat-download-btn {
    background-color: #e8f5e9;
    color: var(--wa-teal);
}

.message.incoming .chat-download-btn:hover {
    background-color: #c8e6c9;
    color: var(--wa-teal);
}

.chat-file-name {
    font-size: 13px;
    color: var(--wa-gray-text);
    margin-bottom: 4px;
}

.chat-input-container {
    display: flex;
    align-items: center;
}

.chat-input-wrapper {
    flex: 1;
    background-color: white;
    border-radius: 20px;
    display: flex;
    align-items: center;
    padding: 0 10px;
}

.input-box {
    flex: 1;
    border: none;
    padding: 8px;
    border-radius: 20px;
    border: 1px solid #ddd;
    outline: none;
    font-size: 15px;
}

.input-btn {
    border: none;
    background: none;
    color: var(--wa-gray-text);
    font-size: 16px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 8px;
}

.input-btn:hover {
    background-color: #ECECEC;
}

#sendChatButton {
    background-color: var(--wa-green);
    color: white;
}

#sendChatButton:hover {
    background-color: var(--wa-teal);
}

.call-controls {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px;
    border-radius: 30px;
}

.call-controls-audio {
    display: flex;
    gap: 8px;
    justify-content: center;
    padding: 10px;
    background-color: rgba(0,0,0,0.7);
    bottom: 0;
    left: 0;
    right: 0;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.control-btn {
    width: 50px;
    height: 50px;
    background: white;
    color: #333;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
}

.control-btn:hover {
    background: #e0e0e0;
    transform: scale(1.1);
}

#toggleAudioButton.muted,
#toggleVideoButton.off,
#endCallButton {
    background: #e53935;
    color: white;
}

#endCallButton.active {
    display: flex;
}
#endCallButton:hover {
    background: #d32f2f;
}

.start-call-section {
    padding: 8px 12px;
    background-color: #f0f2f5;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    border-top: 1px solid #e0e0e0;
}

.call-init.hide {
    display: none;
}

.connect-dialog-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.connect-dialog-overlay.active {
    display: flex;
}

.connect-dialog {
    background: white;
    width: 100%;
    max-width: 380px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    animation: popIn 0.2s ease;
}

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

.connect-dialog-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 20px 14px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 18px;
    font-weight: 600;
    color: var(--wa-teal);
}

.connect-dialog-body {
    padding: 18px 20px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.connect-dialog-hint {
    font-size: 13px;
    color: #888;
}

.connect-input {
    width: 100%;
    border: 1.5px solid #ddd;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.connect-input:focus {
    border-color: var(--wa-green);
}

.connect-dialog-footer {
    padding: 12px 20px 20px;
    display: flex;
    justify-content: flex-end;
}

.call-btn {
    background-color: var(--wa-green);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 10px 20px;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.call-btn:hover {
    background-color: var(--wa-teal);
}

.emoji-dialog-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2100;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.emoji-dialog-overlay.active {
    display: flex;
}

.emoji-dialog {
    background: white;
    width: 100%;
    max-width: 340px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    overflow: hidden;
    animation: popIn 0.2s ease;
}

.emoji-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid #eee;
    font-size: 16px;
    font-weight: 600;
    color: var(--wa-teal);
}

.emoji-dialog-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #888;
    cursor: pointer;
    padding: 0 6px;
    border-radius: 4px;
}

.emoji-dialog-close:hover {
    background: #f0f0f0;
    color: #333;
}

.emoji-dialog-hint {
    font-size: 12px;
    color: #888;
    padding: 0 16px 8px;
    line-height: 1.35;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    padding: 14px 16px 18px;
    max-height: 55vh;
    overflow-y: auto;
}

.emoji-cell {
    font-size: 28px;
    border: none;
    background: #f5f5f5;
    border-radius: 10px;
    padding: 10px 6px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.emoji-cell:hover {
    background: #e8f5e9;
    transform: scale(1.08);
}

.emoji-cell:active {
    transform: scale(0.95);
}

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: 10px;
    padding: 20px;
    width: 300px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.modal h2 {
    color: var(--wa-teal);
    margin-bottom: 15px;
    font-size: 18px;
    text-align: center;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-btn {
    padding: 12px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background 0.2s;
}

.modal-btn.primary {
    background-color: var(--wa-green);
    color: white;
}

.modal-btn.primary:hover {
    background-color: var(--wa-teal);
}

.modal-btn.secondary {
    background-color: #f0f2f5;
    color: #333;
}

.modal-btn.secondary:hover {
    background-color: #e0e0e0;
}

.incoming-call-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.incoming-call-modal.active {
    display: flex;
}

.incoming-call-box {
    background: white;
    border-radius: 10px;
    padding: 20px;
    width: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.incoming-call-box h2 {
    color: #333;
    margin-bottom: 5px;
    font-size: 18px;
}

#incomingCallType {
    color: var(--wa-gray-text);
    margin-bottom: 15px;
    font-size: 14px;
}

.incoming-call-box .caller {
    width: 60px;
    height: 60px;
    border-radius: 50px;
    background-color: var(--wa-light-green);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 15px;
}

.call-actions {
    display: flex;
    gap: 20px;
    margin-top: 15px;
}

.call-action-btn {
    width: 60px;
    height: 60px;
    border-radius: 50px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    cursor: pointer;
}

.accept {
    background-color: var(--wa-green);
}

.reject {
    background-color: #e53935;
}

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 3000;
}

.typing-indicator {
    padding: 10px 15px;
    margin: 5px 0;
    background-color: var(--wa-incoming-bg);
    border-radius: 7.5px;
    max-width: fit-content;
    box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #9e9e9e;
    margin: 0 2px;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .app-container {
        height: 100%;
        width: 100%;
        max-width: none;
    }
}