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

html {
    height: 100%;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    height: calc(var(--vh, 1vh) * 100); /* JavaScript fallback for mobile Chrome */
    overflow: hidden;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #ffffff;
    margin: 0;
    padding: 0;
    /* Mobile defaults - will be overridden by media queries */
    background: #000000;
    height: 100%;
    height: 100dvh;
    height: calc(var(--vh, 1vh) * 100);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
}

/* Phone Frame Wrapper - Base styles */
.phone-frame-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000000;
    position: relative;
}

/* Android Container - Base styles */
.android-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    height: calc(var(--vh, 1vh) * 100); /* JavaScript fallback for mobile Chrome */
    max-height: 100dvh;
    max-height: calc(var(--vh, 1vh) * 100); /* JavaScript fallback */
    background: #000000;
    min-height: 0; /* Allow flex children to shrink */
    overflow: hidden;
    flex: 1;
    position: relative;
    /* Ensure container doesn't grow beyond viewport */
    contain: layout style;
}

/* Desktop: Show phone frame */
@media screen and (min-width: 769px) {
    html {
        overflow: auto !important;
        height: auto !important;
    }

    body {
        background: #1a1a1a !important;
        overflow: auto !important;
        position: relative !important;
        height: auto !important;
        min-height: 100vh !important;
        width: 100% !important;
        top: auto !important;
        left: auto !important;
        display: block !important;
        flex-direction: row !important;
    }

    .phone-frame-wrapper {
        width: 100% !important;
        min-height: 100vh !important;
        height: auto !important;
        padding: 40px 20px !important;
        background: #1a1a1a !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        position: relative !important;
    }

    .android-container {
        width: 420px !important;
        max-width: 420px !important;
        height: 912px !important;
        max-height: calc(100vh - 80px) !important;
        min-height: 600px !important;
        border-radius: 40px !important;
        border: 8px solid #2a2a2a !important;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8),
                    0 0 0 1px rgba(255, 255, 255, 0.1) inset !important;
        flex: none !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* Phone notch simulation */
    .android-container::before {
        content: '' !important;
        position: absolute !important;
        top: 0 !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: 150px !important;
        height: 30px !important;
        background: #000000 !important;
        border-radius: 0 0 20px 20px !important;
        z-index: 1000 !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5) !important;
    }
}

/* Tablet: Show phone frame but smaller */
@media screen and (min-width: 481px) and (max-width: 768px) {
    html {
        overflow: auto !important;
        height: auto !important;
    }

    body {
        background: #000000 !important;
        overflow: auto !important;
        position: relative !important;
        height: auto !important;
        min-height: 100vh !important;
        width: 100% !important;
        top: auto !important;
        left: auto !important;
        display: block !important;
    }

    .phone-frame-wrapper {
        padding: 20px !important;
        height: auto !important;
        min-height: 100vh !important;
    }

    .android-container {
        width: 100% !important;
        max-width: 480px !important;
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
        flex: 1 !important;
        height: auto !important;
        max-height: none !important;
    }

    .android-container::before {
        display: none !important;
    }
}

/* Mobile: No frame, full screen */
@media screen and (max-width: 480px) {
    html {
        overflow: hidden !important;
        height: 100% !important;
        height: 100dvh !important;
        height: calc(var(--vh, 1vh) * 100) !important;
    }

    body {
        background: #000000 !important;
        overflow: hidden !important;
        position: fixed !important;
        height: 100% !important;
        height: 100dvh !important;
        height: calc(var(--vh, 1vh) * 100) !important;
        width: 100% !important;
        top: 0 !important;
        left: 0 !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .phone-frame-wrapper {
        width: 100% !important;
        height: 100% !important;
        padding: 0 !important;
        background: #000000 !important;
    }

    .android-container {
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
        flex: 1 !important;
    }

    .android-container::before {
        display: none !important;
    }
}

/* Caller Info Card - Top */
.caller-card {
    background: #1a1a1a;
    border-radius: 16px;
    margin: 16px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    flex-shrink: 0; /* Prevent caller card from shrinking */
}

.caller-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.caller-avatar-link {
    text-decoration: none;
    display: flex;
    cursor: pointer;
}

.caller-avatar {
    width: 86px;
    height: 86px;
    border-radius: 50%;
    background: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.caller-avatar-link:hover .caller-avatar {
    transform: scale(1.05);
}

.caller-avatar-link:active .caller-avatar {
    transform: scale(0.95);
}

.avatar-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
}

.caller-info {
    flex: 1;
}

.caller-name {
    font-size: 20px;
    font-weight: 500;
    color: #ffffff;
    margin-bottom: 4px;
}

.caller-status {
    font-size: 14px;
    color: #999999;
}

.caller-icons {
    display: flex;
    gap: 12px;
}

.icon-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #2a2a2a;
    color: #B8450E;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.icon-button:hover:not(.disabled) {
    background: #3a3a3a;
}

.icon-button.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.icon-button svg {
    width: 20px;
    height: 20px;
}

#info-button {
    background: #000000;
    color: #ffffff;
}

#info-button:hover:not(.disabled) {
    background: #1a1a1a;
}

#video-info-button {
    background: #000000;
    color: #ffffff;
}

#video-info-button:hover:not(.disabled) {
    background: #1a1a1a;
}

/* Chat Area - Middle */
.chat-container {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0; /* Allow flex item to shrink below content size */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    position: relative;
}

.chat-container::-webkit-scrollbar {
    width: 4px;
}

.chat-container::-webkit-scrollbar-track {
    background: #000000;
}

.chat-container::-webkit-scrollbar-thumb {
    background: #333333;
    border-radius: 2px;
}

.message {
    display: none;
    margin-bottom: 8px;
}

.message.visible {
    display: flex;
    animation: fadeIn 0.3s ease-in forwards;
}

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

/* Typing indicator / Spinner */
.typing-indicator {
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    margin-bottom: 8px;
    opacity: 0;
    animation: fadeIn 0.3s ease-in forwards;
}

.typing-indicator.hidden {
    display: none;
}

.typing-spinner {
    width: 4rem;
    height: 4rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    align-self: center;
    margin-right: -2rem;
    z-index: 1;
}

.typing-spinner::before {
    content: '';
    width: 2rem;
    height: 2rem;
    border: 2px solid #2a2a2a;
    border-top-color: #B8450E;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.typing-dots {
    display: flex;
    gap: 8px;
    padding: 0.875rem 1.25rem;
    background: #2a2a2a;
    border-radius: 20px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    position: relative;
    margin-left: 2rem;
}

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

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

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

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

.message.user {
    justify-content: flex-end;
    align-items: flex-end;
    gap: 0.75rem;
}

.message.ai {
    justify-content: flex-start;
    align-items: flex-end;
}

.message-bubble {
    max-width: 75%;
    padding: 0.875rem 1.25rem;
    border-radius: 20px;
    font-size: 1.125rem;
    line-height: 1.6;
    word-wrap: break-word;
    text-align: center;
}

.message.user .message-bubble {
    background: #B8450E;
    color: #ffffff;
    border-bottom-right-radius: 4px;
    align-self: flex-start;
}

.message.ai .message-bubble {
    background: #000000;
    color: #ffffff;
    border: 1px solid #333333;
    border-bottom-left-radius: 4px;
    text-align: left;
    align-self: flex-start;
    margin-bottom: 0.5rem;
}

.message-avatar {
    width: 4rem;
    height: 4rem;
    flex-shrink: 0;
    object-fit: contain;
    object-position: bottom;
    border-radius: 50%;
    background: #000000;
    align-self: flex-end;
}

.user-avatar {
    width: 3rem;
    height: 3rem;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
    align-self: flex-end;
}

.user-avatar.question-mark {
    background: #666666;
}

.user-avatar.initials {
    background: #B8450E;
}

.message-text {
    display: block;
}

/* Bottom Action Bar */
.action-bar {
    background: #2a2a2a;
    padding: 32px 16px;
    padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px)); /* Account for safe area on mobile */
    display: flex;
    justify-content: center;
    gap: 40px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.5);
    flex-shrink: 0; /* Prevent action bar from shrinking */
    position: relative;
    z-index: 10;
    margin-top: auto; /* Push to bottom of flex container */
}

.action-button {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.action-button:hover {
    transform: scale(1.1);
}

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

.action-button.answer {
    background: #4CAF50;
    color: #ffffff;
}

.action-button.speaker {
    background: #FFC107;
    color: #ffffff;
}

.action-button.reject {
    background: #F44336;
    color: #ffffff;
}

.action-button svg {
    width: 36px;
    height: 36px;
    display: block;
    margin: 0 auto;
    transform-origin: center center;
}

.action-button.reject svg {
    transform: rotate(135deg);
    transform-origin: center center;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.3s ease-in;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #1a1a1a;
    border-radius: 16px;
    padding: 32px;
    max-width: 90%;
    width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    animation: slideUp 0.3s ease-out;
}

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

.modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.modal-phone-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #4CAF50;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.modal-phone-button svg {
    width: 28px;
    height: 28px;
}

.modal-speaker-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #FFC107;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.4);
}

.modal-speaker-button svg {
    width: 28px;
    height: 28px;
}

.modal-reject-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #F44336;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

.modal-reject-button svg {
    width: 28px;
    height: 28px;
    transform: rotate(135deg);
    transform-origin: center center;
}

.modal-info-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #000000;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.modal-info-button svg {
    width: 28px;
    height: 28px;
}

.modal-video-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #000000;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.modal-video-button svg {
    width: 28px;
    height: 28px;
}

.modal-video-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
    background: #000000;
}

.modal-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.modal-title {
    font-size: 24px;
    font-weight: 500;
    color: #ffffff;
    margin: 0;
}

.modal-body {
    margin-bottom: 24px;
}

.modal-body p {
    font-size: 16px;
    line-height: 1.6;
    color: #cccccc;
    margin: 0;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
}

.modal-close-button {
    background-color: #4CAF50;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
    text-decoration: none;
    display: inline-block;
}

.modal-close-button:hover {
    background-color: #45a049;
    transform: scale(1.05);
}

.modal-close-button:active {
    transform: scale(0.95);
}

.modal-close-button.speaker {
    background-color: #FFC107;
}

.modal-close-button.speaker:hover {
    background-color: #ffb300;
}

.modal-close-button.reject {
    background-color: #F44336;
}

.modal-close-button.reject:hover {
    background-color: #e53935;
}

@media (max-width: 480px) {
    .caller-card {
        margin: 0.75rem;
        margin-bottom: 0.5rem; /* Reduce bottom margin to save space */
        padding: 1rem;
        flex-shrink: 0; /* Prevent caller card from shrinking */
    }

    .chat-container {
        padding: 0.75rem;
        padding-top: 0.5rem; /* Reduce top padding to save space */
    }

    .message-bubble {
        font-size: 1rem;
        padding: 0.75rem 1rem;
    }

    .action-bar {
        padding: 1.5rem 0.75rem; /* Reduced top padding */
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)); /* Account for safe area on mobile */
        gap: 2rem;
        min-height: auto; /* Allow natural height */
    }

    .action-button {
        width: 68px;
        height: 68px;
    }

    .action-button svg {
        width: 34px;
        height: 34px;
    }

    .modal-content {
        padding: 24px;
        max-width: 95%;
    }

    .modal-title {
        font-size: 20px;
    }

    .modal-body p {
        font-size: 14px;
    }

    .modal-phone-button {
        width: 48px;
        height: 48px;
    }

    .modal-phone-button svg {
        width: 24px;
        height: 24px;
    }

    .modal-speaker-button {
        width: 48px;
        height: 48px;
    }

    .modal-speaker-button svg {
        width: 24px;
        height: 24px;
    }

    .modal-reject-button {
        width: 48px;
        height: 48px;
    }

    .modal-reject-button svg {
        width: 24px;
        height: 24px;
    }

    .modal-video-button {
        width: 48px;
        height: 48px;
    }

    .modal-video-button svg {
        width: 24px;
        height: 24px;
    }

    .modal-video-container {
        margin-bottom: 16px;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .message-bubble {
        font-size: 1.0625rem;
    }
}

@media (min-width: 769px) {
    .message-bubble {
        font-size: 1.25rem;
    }
}

