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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    height: 100vh;
    overflow: hidden;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.app-container {
    display: flex;
    height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

.sidebar {
    width: 300px;
    background: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    background: #34495e;
    border-bottom: 1px solid #4a5f7a;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.sidebar-header p {
    font-size: 0.9rem;
    opacity: 0.8;
}

.contacts-list {
    flex: 1;
    overflow-y: auto;
}

.contact-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #34495e;
}

.contact-item:hover {
    background: #34495e;
}

.contact-item.active {
    background: #3498db;
}

.contact-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #3498db;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-right: 15px;
}

.contact-info h3 {
    font-size: 1rem;
    margin-bottom: 3px;
}

.contact-info p {
    font-size: 0.8rem;
    opacity: 0.7;
}

.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-header {
    background: #3498db;
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-user-info {
    display: flex;
    align-items: center;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #2980b9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-right: 15px;
}

.chat-user-details h2 {
    font-size: 1.1rem;
    margin-bottom: 2px;
}

.chat-user-details p {
    font-size: 0.8rem;
    opacity: 0.9;
}

.chat-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #27ae60;
}

.status-indicator.offline {
    background: #95a5a6;
}

.status-indicator.ringing {
    background: #f39c12;
    animation: pulse 1s infinite;
}

.status-indicator.connecting {
    background: #3498db;
    animation: pulse 1s infinite;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
}

.message {
    display: flex;
    margin-bottom: 15px;
    align-items: flex-end;
}

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

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    margin: 0 8px;
}

.message.sent .message-avatar {
    background: #3498db;
    order: 2;
}

.message.received .message-avatar {
    background: #95a5a6;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
}

.message.sent .message-content {
    background: #3498db;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received .message-content {
    background: white;
    color: #2c3e50;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 4px;
}

.video-call-container {
    position: relative;
    background: #000;
    border-radius: 15px;
    overflow: hidden;
    margin: 20px;
    display: none;
    min-height: 300px;
}

.video-call-container.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#trump-video {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
    background: #000;
}

.caption-overlay {
    position: absolute;
    bottom: 90px;
    left: 0;
    right: 0;
    padding: 20px 20px 10px 20px;
    pointer-events: none;
    z-index: 10;
}

.caption-text {
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    text-shadow: 
        2px 2px 4px rgba(0, 0, 0, 0.9),
        0 0 8px rgba(0, 0, 0, 0.7),
        0 0 12px rgba(0, 0, 0, 0.5);
    line-height: 1.4;
    max-width: 100%;
    word-wrap: break-word;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease-in-out;
    margin-bottom: 10px;
}

.caption-text.show {
    opacity: 1;
    transform: translateY(0);
}

.caption-text.typing {
    opacity: 0.7;
    animation: captionPulse 1.5s infinite;
}

@keyframes captionPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.user-video-preview {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 100px;
    height: 75px;
    border-radius: 8px;
    border: 2px solid white;
    background: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: white;
}

.chat-input {
    padding: 20px;
    background: white;
    border-top: 1px solid #e1e8ed;
    display: flex;
    align-items: center;
    gap: 15px;
}

.input-container {
    flex: 1;
    position: relative;
}

.message-input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #e1e8ed;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.message-input:focus {
    border-color: #3498db;
}


.action-buttons {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #229954;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 15px;
    background: white;
    border-radius: 18px;
    margin-bottom: 15px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #95a5a6;
    animation: typing 1.4s infinite;
}

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

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

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

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.hidden {
    display: none !important;
}

.call-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
}

.call-btn {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.call-btn.end {
    background: #e74c3c;
    color: white;
}

.call-btn.mic {
    background: #3498db;
    color: white;
}

.call-btn.mic.listening {
    background: #f39c12;
    animation: pulse 1s infinite;
}

.call-btn.mic.continuous {
    background: #27ae60;
    animation: pulse 2s infinite;
}

.call-btn.lipsync-toggle {
    background: #9b59b6;
    color: white;
}

.call-btn.lipsync-toggle.active {
    background: #e67e22;
    color: white;
    animation: pulse 1s infinite;
}

.call-btn.lipsync-toggle:hover {
    background: #8e44ad;
    transform: scale(1.05);
}

.call-btn.lipsync-toggle.active:hover {
    background: #d35400;
}


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

.permission-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    max-width: 400px;
    margin: 20px;
}

.permission-content h2 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.permission-content p {
    color: #7f8c8d;
    margin-bottom: 10px;
    line-height: 1.5;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
    margin-left: 10px;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.user-video-preview {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 100px;
    height: 75px;
    border-radius: 8px;
    border: 2px solid white;
    background: #333;
    overflow: hidden;
}

.user-video-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.permission-modal.hidden {
    display: none;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        height: 100vh;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 30vh;
        order: 2;
    }
    
    .main-chat {
        order: 1;
        height: 70vh;
    }
    
    .sidebar-header {
        padding: 15px;
    }
    
    .sidebar-header h1 {
        font-size: 1.2rem;
    }
    
    .contact-item {
        padding: 10px 15px;
    }
    
    .contact-avatar {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .chat-header {
        padding: 15px;
    }
    
    .chat-avatar {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
    
    .chat-user-details h2 {
        font-size: 1rem;
    }
    
    .chat-messages {
        padding: 15px;
    }
    
    .message-content {
        max-width: 85%;
        padding: 10px 14px;
    }
    
    .chat-input {
        padding: 15px;
        flex-direction: column;
        gap: 10px;
    }
    
    .input-container {
        width: 100%;
    }
    
    .action-buttons {
        width: 100%;
        justify-content: center;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 16px;
        min-height: 44px; /* iOS touch target minimum */
    }
    
    .voice-button {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .video-call-container {
        margin: 10px;
        min-height: 250px;
    }
    
    #trump-video {
        max-height: 300px;
    }
    
    .user-video-preview {
        width: 80px;
        height: 60px;
        top: 10px;
        right: 10px;
    }
    
    .call-controls {
        bottom: 15px;
    }
    
    .caption-overlay {
        bottom: 80px;
        padding: 15px 15px 8px 15px;
    }
    
    .caption-text {
        font-size: 1rem;
        font-weight: 600;
    }
    
    .call-btn {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
    
    .permission-content {
        padding: 20px;
        margin: 15px;
        max-width: 90%;
    }
    
    .permission-content h2 {
        font-size: 1.3rem;
    }
    
    /* Touch-friendly improvements */
    .contact-item:active {
        background: #34495e;
        transform: scale(0.98);
    }
    
    .btn:active {
        transform: scale(0.95);
    }
    
    .voice-button:active {
        transform: scale(0.9);
    }
    
    .call-btn:active {
        transform: scale(0.9);
    }
}

@media (max-width: 480px) {
    .sidebar {
        max-height: 25vh;
    }
    
    .main-chat {
        height: 75vh;
    }
    
    .chat-header {
        padding: 10px;
    }
    
    .chat-messages {
        padding: 10px;
    }
    
    .chat-input {
        padding: 10px;
    }
    
    .message-content {
        max-width: 90%;
        padding: 8px 12px;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .video-call-container {
        margin: 5px;
    }
    
    #trump-video {
        height: 200px;
    }
    
    .user-video-preview {
        width: 70px;
        height: 50px;
        top: 8px;
        right: 8px;
    }
}
