:root {
    --bg-dark: #0b141a;
    --bg-surface: #202c33;
    --bg-sent: #005c4b;
    --accent: #00a884;
    --text-primary: #e9edef;
    --text-secondary: #8696a0;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.screen {
    display: none;
    height: 100vh;
}

.screen.active {
    display: block;
}

.upload-container {
    text-align: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 400px;
}

.whatsapp-icon {
    margin-bottom: 24px;
}

h1 {
    font-size: 1.8rem;
    margin-bottom: 12px;
}

p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

input[type="file"] {
    display: none;
}

.file-input-btn {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    display: inline-block;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.file-input-btn:active {
    transform: scale(0.98);
}

.file-input-btn:hover {
    background-color: #008d6b;
}

.error-message {
    color: #ff4d4d;
    margin-top: 16px;
    min-height: 20px;
}

.who-container {
    text-align: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    padding-bottom: 20px;
}

.senders-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 24px 0;
}

.sender-card {
    border: 2px solid var(--bg-surface);
    border-radius: 20px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sender-card:hover {
    border-color: var(--accent);
    background-color: rgba(0, 168, 132, 0.1);
}

.sender-card.selected {
    border-color: var(--accent);
    background-color: rgba(0, 168, 132, 0.2);
}

.sender-card.selected::after {
    content: "✓";
    color: var(--accent);
    font-weight: bold;
    font-size: 1.2rem;
}

.sender-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.sender-name {
    font-weight: bold;
    font-size: 1.1rem;
}

.sender-count {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.view-chat-btn {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
    transition: background-color 0.2s;
}

.view-chat-btn:disabled {
    background-color: var(--text-secondary);
    cursor: not-allowed;
}

.view-chat-btn:hover:not(:disabled) {
    background-color: #008d6b;
}

.chat-header {
    display: flex;
    align-items: center;
    background-color: var(--bg-surface);
    padding: 12px 16px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.back-btn {
    background: none;
    border: none;
    cursor: pointer;
    margin-right: 16px;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.back-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

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

.avatar {
    display: flex;
    align-items: center;
    margin-right: 12px;
    position: relative;
}

.avatar-initials {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #00a884, #008d6b);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    color: white;
}

.status-dot {
    width: 10px;
    height: 10px;
    background-color: var(--accent);
    border-radius: 50%;
    position: absolute;
    border: 2px solid var(--bg-surface);
}

#chat-name {
    font-size: 1.2rem;
    font-weight: bold;
}

.chat-area {
    position: absolute;
    top: 64px; /* Header height */
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    overflow-y: auto;
    background-color: var(--bg-dark);
    background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23121c24' fill-opacity='0.05'%3E%3Ccircle cx='10' cy='10' r='1'/%3E%3C/g%3E%3C/svg%3E");
}

.message-group {
    margin-bottom: 4px;
    display: flex;
    flex-direction: column;
}

.message-group:first-child {
    margin-top: 8px;
}

.message-bubble {
    max-width: 80%;
    word-wrap: break-word;
    border-radius: 18px;
    padding: 12px 16px;
    margin-bottom: 4px;
    position: relative;
}

.message-bubble.sent {
    align-self: flex-end;
    background-color: var(--bg-sent);
    border-bottom-right-radius: 4px;
}

.message-bubble.sent::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-top-color: var(--bg-sent);
    border-bottom: 0;
    border-right: 0;
    margin-left: -4px;
    margin-bottom: 0;
}

.message-bubble.received {
    align-self: flex-start;
    background-color: var(--bg-surface);
    border-bottom-left-radius: 4px;
}

.message-bubble.received::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-top-color: var(--bg-surface);
    border-bottom: 0;
    border-left: 0;
    margin-right: -4px;
    margin-bottom: 0;
}

.message-text {
    margin-bottom: 4px;
    line-height: 1.4;
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0.8;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.message-tick {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 4px;
}

.sender-label {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
    margin-left: 4px;
}

.date-separator {
    text-align: center;
    margin: 24px 0;
    position: sticky;
    top: 64px; /* Header height */
    background-color: var(--bg-surface);
    padding: 8px 16px;
    border-radius: 20px;
    z-index: 50;
}

.date-separator-chip {
    display: inline-block;
    background-color: var(--bg-surface);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.system-message {
    text-align: center;
    margin: 16px 0;
}

.system-message span {
    display: inline-block;
    background-color: var(--bg-surface);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
}

/* Smooth transitions */
.screen {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.screen.active {
    opacity: 1;
}

/* Responsive design */
@media (max-width: 480px) {
    .upload-container, .who-container {
        width: 95%;
        padding: 0 10px;
    }
    
    .chat-area {
        padding: 10px;
    }
    
    .message-bubble {
        max-width: 85%;
    }
}