:root {
    --wa-header-bg: #008069;
    --wa-chat-bg: #EFEAE2;
    --wa-message-out: #E7FFDB;
    --wa-message-in: #FFFFFF;
    --wa-teal: #00a884;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

body {
    background-color: #d1d7db;
    display: flex;
    justify-content: center;
    height: 100vh;
    overflow: hidden;
}

.main-container {
    width: 100%;
    max-width: 500px;
    background-color: var(--wa-chat-bg);
    height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    background-repeat: repeat;
    background-size: 300px;
    position: relative;
}

@media (min-width: 600px) {
    body {
        background-color: #2c2c2c;
        /* Dark background mainly */
        align-items: center;
    }

    .main-container {
        height: 95vh;
        max-height: 850px;
        border-radius: 30px;
        border: 12px solid #111;
        overflow: hidden;
    }

    /* Adjust fixed header for "phone" container */
    header {
        position: absolute;
    }

    #chat-container {
        padding-top: 70px;
        /* Reset top padding since header is absolute inside relative container */
    }
}

/* Header */
header {
    background-color: var(--wa-header-bg);
    color: white;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    z-index: 100;
    /* Fixed positioning for mobile */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    max-width: 500px;
    margin: 0 auto;
}

.back-btn {
    cursor: pointer;
    font-size: 1.2rem;
}

.profile-pic {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    background-color: #ddd;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.profile-pic img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.profile-info {
    flex: 1;
}

.profile-info h1 {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 2px;
}

.status-text {
    font-size: 12px;
    color: white;
    opacity: 0.9;
    font-weight: 400;
}

/* Chat Area */
#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    padding-top: 75px;
    /* Space for fixed header */
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 80px;
    /* Hide scrollbar like WhatsApp */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

#chat-container::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

/* Messages */
.message {
    max-width: 85%;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
}

.message.bot {
    align-self: flex-start;
    background-color: var(--wa-message-in);
    border-top-left-radius: 0;
}

.message.user {
    align-self: flex-end;
    background-color: var(--wa-message-out);
    border-top-right-radius: 0;
}

/* Timestamp & Ticks */
.message-time {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    font-size: 10px;
    color: #999;
    background: transparent;
    float: right;
    margin-top: 5px;
    margin-left: 10px;
}

.message-time-audio {
    position: absolute;
    bottom: -18px;
    right: 0;
    font-size: 11px;
    color: #999;
    display: flex;
    align-items: center;
    gap: 3px;
}

.tick {
    font-size: 11px;
    color: #999;
}

.tick.read {
    color: #34B7F1;
}

/* Input Area */
.input-area {
    background-color: #f0f2f5;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    position: absolute;
    bottom: 0;
    width: 100%;
}

.input-area input {
    flex: 1;
    border: none;
    padding: 10px 15px;
    border-radius: 20px;
    outline: none;
    font-size: 15px;
}

.input-area button {
    background-color: var(--wa-header-bg);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

/* Typing Indicator */
.typing-indicator {
    align-self: flex-start;
    background-color: white;
    padding: 10px 15px;
    border-radius: 20px;
    border-bottom-left-radius: 0;
    display: none;
    align-items: center;
    gap: 5px;
    margin-bottom: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.dot {
    width: 8px;
    height: 8px;
    background-color: #b4b4b4;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) {
    animation-delay: -0.32s;
}

.dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

@keyframes wave {

    0%,
    100% {
        transform: scaleY(1);
    }

    50% {
        transform: scaleY(1.5);
    }
}

/* Shake Error Animation */
.shake-error {
    animation: shake 0.5s;
    border: 1px solid #ff5252;
}

@keyframes shake {
    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    50% {
        transform: translateX(5px);
    }

    75% {
        transform: translateX(-5px);
    }

    100% {
        transform: translateX(0);
    }
}

/* Buttons */
.options-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 5px 0;
    justify-content: flex-end;
}

.option-btn {
    background-color: white;
    border: 1px solid #e0e0e0;
    padding: 10px 15px;
    border-radius: 8px;
    /* Slightly rounded, simpler */
    cursor: pointer;
    font-size: 14px;
    color: var(--wa-teal);
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.option-btn:hover {
    background-color: #f9f9f9;
}

.option-btn i {
    font-size: 16px;
}

/* Advanced Audio Player (Waveform) */
.audio-player {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 250px;
    padding: 6px 0;
    position: relative;
    /* margin-bottom to fit timestamp */
    margin-bottom: 15px;
}

.audio-profile {
    position: relative;
    width: 50px;
    height: 50px;
    flex-shrink: 0;
}

.audio-profile img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.audio-mic-icon {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: #00a884;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    border: 2px solid white;
}

.play-btn {
    color: #999;
    font-size: 24px;
    cursor: pointer;
    width: 30px;
    display: flex;
    justify-content: center;
}

.message.bot .play-btn {
    color: #999;
}

.audio-waveform {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 24px;
    flex-grow: 1;
    overflow: hidden;
    mask-image: linear-gradient(to right, #00a884 0%, #00a884 var(--progress), #b9b9b9 var(--progress), #b9b9b9 100%);
    -webkit-mask-image: linear-gradient(to right, #00a884 0%, #00a884 var(--progress), #b9b9b9 var(--progress), #b9b9b9 100%);
}

.wave-bar {
    width: 3px;
    background-color: currentColor;
    border-radius: 2px;
    animation: wave 1s infinite paused;
}

.wave-bar:nth-child(odd) {
    height: 14px;
}

.wave-bar:nth-child(2n) {
    height: 22px;
}

.wave-bar:nth-child(3n) {
    height: 10px;
}

.wave-bar:nth-child(4n) {
    height: 18px;
}

.audio-info {
    position: absolute;
    bottom: -18px;
    left: 64px;
    font-size: 11px;
    color: #999;
    display: flex;
    gap: 5px;
}

/* Simplified Audio Player */
.audio-player-simple {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
}

.audio-profile-simple {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.audio-profile-simple img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.play-btn-simple {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--wa-teal);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.play-btn-simple:active {
    transform: scale(0.95);
}

.audio-waveform-simple {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 20px;
    flex-grow: 1;
}

.audio-waveform-simple .wave-bar {
    width: 3px;
    background-color: #b9b9b9;
    border-radius: 2px;
}

.audio-waveform-simple .wave-bar:nth-child(odd) {
    height: 12px;
}

.audio-waveform-simple .wave-bar:nth-child(2n) {
    height: 18px;
}

.audio-waveform-simple .wave-bar:nth-child(3n) {
    height: 8px;
}

.audio-waveform-simple .wave-bar:nth-child(5n) {
    height: 20px;
}

.audio-duration {
    font-size: 11px;
    color: #999;
    flex-shrink: 0;
}

/* Mini Audio Player (WhatsApp Professional Style) */
.audio-player-mini {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 220px;
    padding: 4px 0;
}

.play-btn-mini {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #54656f;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    transition: color 0.2s, transform 0.1s;
}

.play-btn-mini:hover {
    color: #3b4a54;
}

.play-btn-mini:active {
    transform: scale(0.9);
}

.audio-track-mini {
    flex-grow: 1;
    position: relative;
    height: 30px;
    display: flex;
    align-items: center;
}

.waveform-mini {
    display: flex;
    align-items: center;
    gap: 2px;
    width: 100%;
    height: 100%;
}

.wave-bar-mini {
    width: 3px;
    background-color: #ced0d1;
    border-radius: 3px;
    flex-shrink: 0;
    transition: background-color 0.2s;
    /* Default state: no animation or paused */
}

.waveform-mini.playing .wave-bar-mini {
    animation: wave-mini 1s infinite ease-in-out;
}

.waveform-mini.playing .wave-bar-mini:nth-child(odd) {
    animation-duration: 0.6s;
}

.waveform-mini.playing .wave-bar-mini:nth-child(2n) {
    animation-duration: 1.1s;
}

.waveform-mini.playing .wave-bar-mini:nth-child(3n) {
    animation-duration: 1.3s;
}

.waveform-mini.playing .wave-bar-mini:nth-child(5n) {
    animation-duration: 0.9s;
}

@keyframes wave-mini {

    0%,
    100% {
        transform: scaleY(1);
    }

    50% {
        transform: scaleY(0.5);
    }
}

.audio-progress-dot {
    position: absolute;
    left: 0%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: #00a884;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: left 0.1s linear;
    z-index: 5;
}

.audio-meta-mini {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    padding-left: 52px;
}

.audio-time-mini {
    font-size: 11px;
    color: #667781;
    font-weight: 400;
}

.audio-hour-mini {
    font-size: 11px;
    color: #667781;
}

/* Progress Bar for Serasa Consultation */
.progress-container {
    width: 100%;
    padding: 10px 0;
}

.progress-text {
    font-size: 13px;
    color: #333;
    margin-bottom: 8px;
    font-weight: 500;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--wa-teal) 0%, #00d9a5 100%);
    border-radius: 4px;
    width: 0%;
    transition: width 0.5s ease-in-out;
}

/* Profile Modal */
.profile-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 350px;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 15px;
    display: flex;
    justify-content: flex-end;
}

.modal-close {
    font-size: 20px;
    color: #666;
    cursor: pointer;
    padding: 5px;
}

.modal-body {
    text-align: center;
    padding: 0 20px 20px;
}

.modal-profile-pic {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 0 auto 15px;
    overflow: hidden;
    border: 4px solid #f0f2f5;
}

.modal-profile-pic img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-name {
    font-size: 20px;
    font-weight: 500;
    color: #111;
    margin-bottom: 5px;
}

.modal-phone {
    font-size: 16px;
    color: var(--wa-teal);
    margin-bottom: 5px;
}

.modal-status {
    font-size: 14px;
    color: #667781;
}

.modal-actions {
    display: flex;
    justify-content: space-around;
    padding: 15px 10px;
    border-top: 1px solid #f0f2f5;
    background: #fafafa;
}

.modal-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 10px 20px;
    border-radius: 8px;
    transition: background 0.2s;
}

.modal-action:hover {
    background: #e9edef;
}

.modal-action i {
    font-size: 22px;
    color: var(--wa-teal);
}

.modal-action span {
    font-size: 12px;
    color: #667781;
}

/* Cursor pointer for clickable profile */
header .profile-pic {
    cursor: pointer;
}

/* Fullscreen Photo Modal */
.fullphoto-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.fullphoto-modal img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    object-fit: contain;
}

/* Call Alert Toast */
.call-alert {
    display: none;
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 3000;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.call-alert i {
    color: #ff5252;
}