/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #e5ddd5;
    height: 100vh;
    overflow: hidden;
}

/* App container */
#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Screen management */
.screen {
    display: none;
    height: 100vh;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* Login Screen */
#loginScreen {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-container {
    background: white;
    border-radius: 20px;
    padding: 40px 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.login-header {
    margin-bottom: 30px;
}

.login-header .logo {
    font-size: 4rem;
    color: #25d366;
    margin-bottom: 10px;
}

.login-header h1 {
    color: #333;
    margin-bottom: 5px;
    font-size: 2rem;
}

.login-header p {
    color: #666;
    font-size: 1rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 15px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.input-group:focus-within {
    border-color: #25d366;
    background: white;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.input-group i {
    color: #666;
    margin-right: 15px;
    font-size: 1.2rem;
}

.input-group input,
.input-group select {
    border: none;
    outline: none;
    background: transparent;
    flex: 1;
    font-size: 1rem;
    color: #333;
}

.input-group select {
    cursor: pointer;
}

.login-btn {
    background: linear-gradient(135deg, #25d366, #20bd5a);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 15px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(37, 211, 102, 0.3);
}

.demo-info {
    margin-top: 20px;
    color: #666;
}

/* Chat Screen */
#chatScreen {
    background-color: #e5ddd5;
}

/* Header */
.chat-header {
    background-color: #075e54;
    color: white;
    padding: 15px 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
}

.header-content h1 {
    font-size: 1.5rem;
    font-weight: 500;
}

.header-content h1 i {
    margin-right: 10px;
    color: #25d366;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logged-in-user {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #075e54;
    font-size: 0.9rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 12px;
}

.logged-in-user i {
    font-size: 0.8rem;
}

.online-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.online-indicator i {
    color: #25d366;
    font-size: 0.8rem;
}

.logout-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="chat-bg" patternUnits="userSpaceOnUse" width="100" height="100"><circle cx="50" cy="50" r="2" fill="%23ffffff" opacity="0.05"/></pattern></defs><rect width="100" height="100" fill="url(%23chat-bg)"/></svg>');
}

.messages-list {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.welcome-message {
    text-align: center;
    color: #666;
    padding: 40px 20px;
}

.welcome-message i {
    font-size: 3rem;
    color: #25d366;
    margin-bottom: 15px;
}

.welcome-message h3 {
    margin-bottom: 10px;
    color: #333;
}

.commands-info {
    margin-top: 15px;
    padding: 10px;
    background-color: #f0f0f0;
    border-radius: 8px;
    border-left: 3px solid #25d366;
}

.commands-info code {
    background-color: #e0e0e0;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    color: #d63384;
}

/* Message styles */
.message {
    max-width: 70%;
    padding: 12px 15px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    margin: 2px 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message.sent {
    background-color: #dcf8c6;
    align-self: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 5px;
}

.message.received {
    background-color: white;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

.message-header {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    gap: 10px;
}

.message-sender {
    font-weight: 600;
    font-size: 0.9rem;
    color: #075e54;
}

.message-time {
    font-size: 0.75rem;
    color: #666;
    margin-left: auto;
}

.message-content {
    font-size: 1rem;
    line-height: 1.4;
    color: #333;
}

.message-image {
    max-width: 100%;
    border-radius: 12px;
    margin: 5px 0;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.message-image:hover {
    transform: scale(1.02);
}

.message-audio {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    margin: 5px 0;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.play-btn {
    background: #25d366;
    border: none;
    color: white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.play-btn:hover {
    background: #20bd5a;
}

.audio-duration {
    font-size: 0.9rem;
    color: #666;
}

/* System messages */
.system-message {
    text-align: center;
    color: #666;
    font-size: 0.9rem;
    margin: 10px 0;
    padding: 5px 15px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 20px;
    align-self: center;
}

/* Message Input */
.message-input-container {
    background-color: #f0f0f0;
    padding: 10px 20px;
    border-top: 1px solid #d1d1d1;
}

.message-input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    border-radius: 25px;
    padding: 8px 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.attach-btn, .voice-btn, .send-btn, .emoji-btn {
    background: none;
    border: none;
    color: #666;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.attach-btn:hover, .emoji-btn:hover {
    background: #f0f0f0;
    color: #333;
}

.voice-btn:hover {
    background: #ff6b6b;
    color: white;
}

.send-btn {
    background: #25d366;
    color: white;
}

.send-btn:hover {
    background: #20bd5a;
    transform: scale(1.05);
}

.input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

#messageInput {
    flex: 1;
    border: none;
    outline: none;
    padding: 10px 0;
    font-size: 1rem;
    background: transparent;
    color: #333;
}

#messageInput::placeholder {
    color: #999;
}

/* Attachment Menu */
.attachment-menu {
    position: absolute;
    bottom: 80px;
    left: 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 1000;
    transition: all 0.3s ease;
    transform-origin: bottom left;
}

.attachment-menu.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.attachment-option {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 20px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 10px;
    transition: background-color 0.3s ease;
    font-size: 1rem;
    color: #333;
    min-width: 150px;
}

.attachment-option:hover {
    background: #f0f0f0;
}

.attachment-option i {
    font-size: 1.2rem;
    color: #25d366;
    width: 20px;
}

/* Emoji Picker */
.emoji-picker {
    position: absolute;
    bottom: 80px;
    right: 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 15px;
    z-index: 1000;
    max-width: 320px;
    max-height: 250px;
    overflow-y: auto;
}

.emoji-picker.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
}

.emoji-picker .emoji-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.emoji-picker .emoji-btn:hover {
    background-color: #f0f0f0;
    transform: scale(1.1);
}

.emoji-picker .emoji-btn:active {
    background-color: #e0e0e0;
    transform: scale(0.95);
}

/* Message Reactions */
.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
    align-items: center;
}

.reaction {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 2px 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
}

.reaction:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.05);
}

.reaction-emoji {
    font-size: 0.9rem;
}

.reaction-count {
    font-weight: 500;
    color: #666;
    min-width: 12px;
    text-align: center;
}

.reaction-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid #e0e0e0;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
    color: #666;
}

.reaction-add-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

/* Reaction Picker */
.reaction-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 8px;
    margin-bottom: 8px;
    z-index: 1000;
    animation: fadeInUp 0.2s ease-out;
}

.reaction-picker-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.reaction-picker-title {
    font-size: 0.8rem;
    color: #666;
    text-align: center;
    margin-bottom: 4px;
}

.reaction-picker-emojis {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.reaction-picker-emoji {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.reaction-picker-emoji:hover {
    background-color: #f0f0f0;
    transform: scale(1.1);
}

.reaction-picker-emoji:active {
    background-color: #e0e0e0;
    transform: scale(0.95);
}

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

/* Voice Recording */
.voice-recording {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ff6b6b;
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s ease;
}

.voice-recording.hidden {
    transform: translateY(100%);
}

.recording-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.recording-icon {
    animation: pulse 1s infinite;
    font-size: 1.5rem;
}

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

.recording-text {
    font-weight: 600;
    font-size: 1.1rem;
}

#recordingTime {
    font-family: monospace;
    font-size: 1.2rem;
    font-weight: bold;
}

.recording-controls {
    display: flex;
    gap: 15px;
}

.cancel-btn, .stop-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.cancel-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.stop-btn {
    background: #25d366;
}

.stop-btn:hover {
    background: #20bd5a;
    transform: scale(1.05);
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .messages-container {
        padding: 10px;
    }
    
    .message {
        max-width: 85%;
    }
    
    .login-container {
        margin: 20px;
        padding: 30px 20px;
    }
    
    .header-content {
        padding: 0 10px;
    }
    
    .header-content h1 {
        font-size: 1.3rem;
    }
    
    .online-indicator {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .attachment-menu {
        left: 10px;
        right: 10px;
        bottom: 70px;
        flex-direction: row;
        justify-content: space-around;
    }
    
    .attachment-option {
        flex-direction: column;
        gap: 8px;
        padding: 15px 10px;
        min-width: auto;
        text-align: center;
    }
    
    .attachment-option span {
        font-size: 0.9rem;
    }
    
    .emoji-picker {
        right: 10px;
        left: 10px;
        max-width: none;
        max-height: 200px;
    }
    
    .emoji-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 4px;
    }
    
    .emoji-picker .emoji-btn {
        width: 32px;
        height: 32px;
        font-size: 1.2rem;
    }
    
    .reaction {
        font-size: 0.7rem;
        padding: 1px 4px;
    }
    
    .reaction-add-btn {
        width: 20px;
        height: 20px;
        font-size: 0.7rem;
    }
    
    .reaction-picker-emoji {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }
    
    /* Mobile chat input positioning */
    .message-input-container {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1000 !important;
        background: #075e54 !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    }
    
    .messages-container {
        padding-bottom: 80px !important;
    }
    
    .header-actions {
        gap: 10px;
    }
    
    .logged-in-user {
        font-size: 0.8rem;
        padding: 3px 6px;
    }
    
    .online-indicator {
        font-size: 0.8rem;
        padding: 3px 8px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1f1f1f;
    }
    
    #chatScreen {
        background-color: #1f1f1f;
    }
    
    .message.received {
        background-color: #2a2a2a;
        color: #e1e1e1;
    }
    
    .message-content {
        color: #e1e1e1;
    }
    
    .message-input-wrapper {
        background: #2a2a2a;
    }
    
    #messageInput {
        color: #e1e1e1;
    }
    
    #messageInput::placeholder {
        color: #888;
    }
}

/* Scrollbar styling */
.messages-container::-webkit-scrollbar {
    width: 6px;
}

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

.messages-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}
