/* ================== RESET ================== */
* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

/* ================== BODY ================== */
body {
    font-family: Arial, Helvetica, sans-serif;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    transition: background 0.3s;
}

body.dark-mode {
    background: #121212;
}

/* ================== CHAT APP ================== */
.chat-app {
    background-color: #fff;
    width: 350px;
    height: 600px;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: background 0.3s;
}

body.dark-mode .chat-app {
    background-color: #1e1e1e;
}

/* ================== HEADER ================== */
.chat-header {
    background: #667eea;
    color: #fff;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ================== USERNAME BOX ================== */
.username-box {
    display: flex;
    padding: 10px;
    border-bottom: 1px solid #ddd;
    background: #f9f9f9;
}

body.dark-mode .username-box {
    background: #252525;
    border-color: #444;
}

.username-box input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 8px 0 0 8px;
}

.username-box button {
    background: #667eea;
    color: white;
    border: none;
    padding: 0 15px;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
}

/* ================== CHAT BOX ================== */
.chat-box {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* ================== MESSAGES ================== */
.message {
    max-width: 75%;
    margin-bottom: 15px;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 15px;
    position: relative;
    word-wrap: break-word;
    display: flex;
    align-items: center;
}

.message input.select-msg {
    margin-right: 8px;
}

.sent {
    background-color: #667eea;
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.received {
    background: #f1f1f1;
    color: #333;
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

body.dark-mode .received {
    background: #333;
    color: #eee;
}

.time {
    font-size: 11px;
    opacity: 0.7;
    margin-left: 8px;
    flex-shrink: 0;
}

/* ================== CHAT INPUT ================== */
.chat-input {
    display: flex;
    border-top: 1px solid #ddd;
    background: #fff;
}

body.dark-mode .chat-input {
    background: #1e1e1e;
    border-color: #444;
}

.chat-input input {
    flex: 1;
    padding: 14px;
    border: none;
    outline: none;
    font-size: 15px;
}

.chat-input button {
    background-color: #667eea;
    color: white;
    border: none;
    padding: 0 18px;
    cursor: pointer;
    font-size: 16px;
}

/* ================== CLEAR BUTTON ================== */
.clear-btn {
    font-size: 12px;
    padding: 0 14px;
    background-color: #e74c3c;
    color: white;
    border-radius: 8px;
    min-width: 85px;
    border: none;
    cursor: pointer;
    transition: 0.3s;
}

.clear-btn:hover {
    background-color: #c0392b;
}

/* ================== TYPING INDICATOR ================== */
.typing {
    font-style: italic;
    color: #888;
    padding: 10px 15px;
    font-size: 14px;
}

body.dark-mode .typing {
    color: #aaa;
}

/* ================== EMOJI PICKER ================== */
.emoji-picker {
    display: none;
    flex-wrap: wrap;
    background: #fff;
    padding: 10px;
    border-top: 1px solid #ddd;
    max-height: 150px;
    overflow-y: auto;
}

body.dark-mode .emoji-picker {
    background: #252525;
    border-color: #444;
}

.emoji-picker span {
    cursor: pointer;
    font-size: 24px;
    margin: 5px;
    padding: 5px;
    border-radius: 8px;
    transition: background 0.2s;
}

.emoji-picker span:hover {
    background: #eee;
}

body.dark-mode .emoji-picker span:hover {
    background: #444;
}

/* ================== MODAL ================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: #fff;
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 300px;
    width: 90%;
}

body.dark-mode .modal-content {
    background: #2d2d2d;
    color: #fff;
}

.modal-content p {
    margin-bottom: 20px;
    font-size: 16px;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.modal-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: 0.3s;
}

#confirmClearBtn {
    background: #e74c3c;
    color: white;
}

#confirmClearBtn:hover {
    background: #c0392b;
}

#deleteSelectedBtn {
    background: #f39c12;
    color: white;
}

#deleteSelectedBtn:hover {
    background: #d68910;
}

#cancelClearBtn {
    background: #95a5a6;
    color: white;
}

#cancelClearBtn:hover {
    background: #7f8c8d;
}

/* ================== SHAKE ANIMATION ================== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

/* ================== RESPONSIVE ================== */
@media (max-width: 400px) {
    .chat-app {
        width: 95%;
        height: 95vh;
    }
}

