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

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #0a1014;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #ffffff;
    padding: 24px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    margin: 0 16px;
}

.modal-content h2 {
    color: #075e54;
    margin-bottom: 20px;
    font-size: 20px;
}

.modal-content input {
    width: 100%;
    padding: 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 16px;
    transition: border-color 0.3s;
}

.modal-content input:focus {
    outline: none;
    border-color: #25d366;
}

.modal-content button {
    width: 100%;
    padding: 14px;
    background: #25d366;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
    min-height: 48px;
}

/* Chat Container - Mobile First */
.chat-container {
    width: 100%;
    height: 100vh;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    position: relative;
}

.hidden {
    display: none !important;
}

/* Chat Header */
.chat-header {
    background: #075e54;
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    min-height: 64px;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #25d366;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    color: white;
}

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

.contact-info h3 {
    font-size: 16px;
    font-weight: 600;
}

.status {
    font-size: 13px;
    opacity: 0.8;
}

/* Messages Area */
.messages-area {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #e5ddd5;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d9d9d9' fill-opacity='0.1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    -webkit-overflow-scrolling: touch;
}

.message {
    margin-bottom: 12px;
    display: flex;
    animation: slideIn 0.3s ease-out;
}

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

.message.sent {
    justify-content: flex-end;
}

.message.received {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 8px;
    position: relative;
    word-wrap: break-word;
    word-break: break-word;
}

.message.sent .message-bubble {
    background: #dcf8c6;
    border-bottom-right-radius: 2px;
}

.message.received .message-bubble {
    background: #ffffff;
    border-bottom-left-radius: 2px;
}

.message-text {
    font-size: 14px;
    line-height: 1.4;
    color: #303030;
}

.message-time {
    font-size: 11px;
    color: #667781;
    margin-top: 4px;
    text-align: right;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
}

.avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #25d366;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
}

.typing-dots {
    background: #ffffff;
    padding: 12px 16px;
    border-radius: 8px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #90949c;
    animation: typing 1.4s infinite;
}

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

.typing-dots 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;
    }
}

/* Input Area */
.input-area {
    padding: 10px 12px;
    background: #f0f0f0;
    display: flex;
    gap: 8px;
    align-items: center;
    min-height: 64px;
}

.input-area input {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 24px;
    font-size: 16px;
    background: #ffffff;
    min-height: 44px;
}

.input-area input:focus {
    outline: none;
}

.input-area button {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    border-radius: 50%;
    background: #25d366;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
    flex-shrink: 0;
}

/* Scrollbar Styling */
.messages-area::-webkit-scrollbar {
    width: 6px;
}

.messages-area::-webkit-scrollbar-track {
    background: transparent;
}

.messages-area::-webkit-scrollbar-thumb {
    background: #999;
    border-radius: 3px;
}

.messages-area::-webkit-scrollbar-thumb:hover {
    background: #777;
}

/* Responsive Design - Mobile First */

/* Tablets and up */
@media (min-width: 768px) {
    .chat-header {
        padding: 16px;
    }

    .modal-content {
        padding: 32px;
    }

    .modal-content h2 {
        font-size: 22px;
        margin-bottom: 24px;
    }

    .messages-area {
        padding: 20px;
    }

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

    .input-area {
        padding: 12px 16px;
    }
}

/* Desktop and up */
@media (min-width: 1024px) {
    .chat-container {
        max-width: 600px;
        max-height: 800px;
        box-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
        border-radius: 0;
    }

    .modal-content {
        padding: 40px;
    }

    .modal-content h2 {
        font-size: 24px;
    }

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

    .input-area button:hover {
        background: #20ba5a;
    }

    .input-area button:active {
        transform: scale(0.95);
    }

    .modal-content button:hover {
        background: #20ba5a;
    }
}

/* Handle safe area for notched devices */
@supports (padding: max(0px)) {
    .chat-header {
        padding-top: max(16px, env(safe-area-inset-top));
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .input-area {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }
}
