@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap');

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

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #d79aff 0%, #2f0642 99%, #3b0337 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
    overflow-x: hidden; /* prevent horizontal scrollbar */
}

.container {
    position: relative;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(240, 230, 255, 0.9) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 40px;
    box-shadow:
        0 10px 30px rgba(47, 6, 66, 0.3),
        0 0 60px rgba(215, 154, 255, 0.2),
        inset 0 0 15px rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
    text-align: center;
    max-width: 500px;
    width: 90%;
    transition: all 0.3s ease;
}

.container:hover {
    transform: translateY(-5px);
    box-shadow:
        0 15px 40px rgba(47, 6, 66, 0.35),
        0 0 80px rgba(215, 154, 255, 0.25),
        inset 0 0 20px rgba(255, 255, 255, 0.6);
}

/* Dark: landing card switches to a dark surface but keeps style */
body.dark .container {
    background: linear-gradient(135deg, rgba(38, 29, 48, 0.92) 0%, rgba(26, 21, 32, 0.92) 100%);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow:
        0 15px 40px rgba(0, 0, 0, 0.55),
        0 0 80px rgba(0, 0, 0, 0.28),
        inset 0 0 20px rgba(255, 255, 255, 0.04);
}
body.dark header p { color: #cfc6da; }
body.dark .footer-link { color: #cfc6da; }
body.dark .footer-link:hover { color: #d79aff; }

#back-btn-container {
    position: absolute;
    top: 20px;
    right: 20px;
}

.back-btn {
    background: linear-gradient(135deg, #d79aff 0%, #9b4dca 100%);
    color: white;
    border: none;
    padding: 8px 15px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(155, 77, 202, 0.4);
}

header h1 {
    font-size: 3rem;
    color: #2f0642;
    margin-bottom: 10px;
    text-shadow: 1px 1px 2px rgba(215, 154, 255, 0.3);
}

header p {
    color: #3b0337;
    margin-bottom: 30px;
}

.auth-section h2 {
    font-size: 1.5rem;
    color: #2f0642;
    margin-bottom: 20px;
    text-shadow: 1px 1px 2px rgba(215, 154, 255, 0.3);
}

.auth-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.auth-btn {
    width: 100%;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 500;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
}

.auth-btn i {
    margin-right: 10px;
    font-size: 18px;
}

.google-btn {
    background-color: #4285F4;
    color: white;
}

.google-btn:hover {
    background-color: #357ae8;
}

.apple-btn {
    background-color: #000;
    color: white;
}

.apple-btn:hover {
    background-color: #333;
}

.email-btn {
    background-color: #DB4437;
    color: white;
}

.email-btn:hover {
    background-color: #c53929;
}

.or-divider {
    margin: 20px 0;
    color: #3b0337;
}

.talk-strangers-btn {
    display: inline-block;
    background: linear-gradient(135deg, #d79aff 0%, #9b4dca 100%);
    color: #fff;
    text-decoration: none;
    padding: 12px 30px;
    border-radius: 30px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.talk-strangers-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(155, 77, 202, 0.4);
}

footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(59, 3, 55, 0.2);
    color: #3b0337;
    font-size: 0.9rem;
}

.footer-links {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
}

.footer-link {
    color: #3b0337;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.footer-link:hover {
    color: #9b4dca;
    text-decoration: underline;
}

/* Talk to Strangers form styles */
#talk-to-strangers-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    width: 100%;
}

/* Style for select elements */
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%233b0337' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

/* Style for select and input elements */
select,
input[type="text"],
input[type="number"],
.country-display {
    width: 100%;
    padding: 12px 15px;
    font-size: 16px;
    border: 1px solid rgba(59, 3, 55, 0.2);
    border-radius: 25px;
    background-color: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    transition: all 0.3s ease;
    color: #3b0337;
    font-family: 'Poppins', sans-serif;
}

select:focus,
input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.9);
    border-color: rgba(59, 3, 55, 0.4);
    box-shadow: 0 0 15px rgba(215, 154, 255, 0.4);
}

/* Style for select options */
select option {
    background-color: rgba(255, 255, 255, 0.9);
    color: #3b0337;
    padding: 12px;
}

/* Custom scrollbar for select dropdowns */
select::-webkit-scrollbar {
    width: 10px;
}

select::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
}

select::-webkit-scrollbar-thumb {
    background: rgba(155, 77, 202, 0.5);
    border-radius: 10px;
}

select::-webkit-scrollbar-thumb:hover {
    background: rgba(155, 77, 202, 0.7);
}

.flag-icon {
    width: 24px;
    height: 16px;
    margin-right: 5px;
    vertical-align: middle;
    border-radius: 3px;
}

.submit-btn {
    background: linear-gradient(135deg, #d79aff 0%, #9b4dca 100%);
    color: white;
    border: none;
    padding: 12px 25px;
    font-size: 18px;
    font-weight: 600;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(155, 77, 202, 0.4);
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(155, 77, 202, 0.6);
}

.country-display {
    display: flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(59, 3, 55, 0.2);
    border-radius: 25px;
    font-size: 16px;
    padding: 12px 15px;
}

.chat-container {
    position: relative;
    display: flex;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(240, 230, 255, 0.9) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    overflow: hidden;
    box-shadow:
        0 10px 30px rgba(47, 6, 66, 0.3),
        0 0 60px rgba(215, 154, 255, 0.2),
        inset 0 0 15px rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
    width: 90%;
    max-width: 1200px;
    height: 80vh;
    margin: 0 auto;
}

.user-list {
    width: 30%;
    border-right: 1px solid rgba(59, 3, 55, 0.2);
    overflow-y: auto;
    overflow-x: hidden; /* never scroll horizontally */
}
/* Dark: left panel surface */
body.dark .user-list {
    background: linear-gradient(180deg, rgba(20, 16, 24, 0.96), rgba(20, 16, 24, 0.96));
    border-right-color: rgba(255, 255, 255, 0.08);
}

.chat-area {
    width: 70%;
    display: flex;
    flex-direction: column;
}

.tabs {
    display: flex;
    border-bottom: 1px solid rgba(59, 3, 55, 0.2);
}
body.dark .tabs { border-bottom-color: rgba(255, 255, 255, 0.08); }

.tab-btn {
    flex: 1;
    padding: 15px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    color: #3b0337;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background-color: rgba(215, 154, 255, 0.2);
    border-bottom: 3px solid #9b4dca;
}
body.dark .tab-btn { color: #e8e1ee; }
body.dark .tab-btn.active { background-color: rgba(155, 77, 202, 0.18); border-bottom-color: #9b4dca; }

.tab-content {
    display: none;
    padding: 15px;
}

.tab-content.active {
    display: block;
}

.user-item, .chat-item {
    display: flex;
    align-items: center;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.user-item:hover, .chat-item:hover {
    background-color: rgba(215, 154, 255, 0.2);
}

.user-avatar, .chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 10px;
    object-fit: cover;
}

.user-info, .chat-info {
    flex: 1;
    min-width: 0; /* allow ellipsis in children */
}

.user-name, .chat-name {
    font-weight: 600;
    color: #2f0642;
}
body.dark .user-name, body.dark .chat-name { color: #f1e9ff; }

.user-details, .chat-details {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: #3b0337;
}
body.dark .user-details, body.dark .chat-details { color: #cfc6da; }

.chat-preview {
    font-size: 12px;
    color: #3b0337;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
body.dark .chat-preview { color: #e8e1ee; opacity: 0.7; }

.chat-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid rgba(59, 3, 55, 0.2);
}

.chat-header h2 {
    margin-bottom: 5px;
    color: #2f0642;
}
body.dark .chat-header h2 { color: #f1e9ff; }

.messages {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    position: relative;
}
body.dark .messages { color: #e8e1ee; }

/* fade-out at top using an overlay element so it always shows */
.messages .messages-fade {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: 26px;
    pointer-events: none;
    z-index: 2;
    background: linear-gradient(180deg, rgba(240, 230, 255, 1), rgba(240, 230, 255, 0));
}

.message {
    max-width: 70%;
    margin: 10px 12px;
    padding: 12px 16px;
    border-radius: 20px;
    position: relative;
    box-shadow: 0 4px 12px rgba(47, 6, 66, 0.08);
}

/* sender name removed from UI */
.message-sender { display: none; }

.message-content {
    font-size: 0.95rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.message.has-image {
    padding: 8px;
    position: relative; /* anchor for trash button */
}

.message-image {
    display: block;
    max-width: 240px;
    max-height: 280px;
    border-radius: 16px;
    box-shadow: 0 6px 18px rgba(47, 6, 66, 0.12);
}

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 2000; }
.lightbox-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(2px); }
.lightbox-body { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 90vw; max-height: 90vh; }
.lightbox-body img { max-width: 100%; max-height: 90vh; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,0.35); }

/* Image delete button */
/* Trash button outside bottom-right of image bubble */
.image-trash-btn {
    position: absolute;
    right: -10px;
    bottom: -10px;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, #d79aff 0%, #9b4dca 100%);
    box-shadow: 0 8px 18px rgba(155, 77, 202, 0.4);
}
.image-trash-btn:hover { transform: translateY(-1px); }
.image-trash-btn i { pointer-events: none; }

.message.outgoing {
    margin-left: auto;
}

.message.outgoing .message-content {
    background: transparent; /* remove darker block behind text */
    color: inherit;
}

.message-input {
    display: flex;
    padding: 20px;
    border-top: 1px solid rgba(59, 3, 55, 0.2);
}
body.dark .message-input { border-top-color: rgba(255, 255, 255, 0.08); }

#message-text {
    flex: 1;
    padding: 12px 15px;
    font-size: 16px;
    border: 1px solid rgba(59, 3, 55, 0.2);
    border-radius: 25px;
    background-color: rgba(255, 255, 255, 0.7);
    margin-right: 10px;
}
body.dark #message-text {
    background-color: rgba(255, 255, 255, 0.08);
    color: #e8e1ee;
    border-color: rgba(255, 255, 255, 0.15);
}

#send-btn {
    background: linear-gradient(135deg, #d79aff 0%, #9b4dca 100%);
    color: white;
    border: none;
    padding: 12px 25px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(155, 77, 202, 0.4);
}

.filter-section {
    padding: 10px;
    background-color: rgba(215, 154, 255, 0.1);
    border-bottom: 1px solid rgba(59, 3, 55, 0.2);
    margin-bottom: 10px;
}

.filter-section select,
.filter-section input {
    width: 100%;
    padding: 8px 12px;
    margin-bottom: 8px;
    border: 1px solid rgba(59, 3, 55, 0.2);
    border-radius: 15px;
    background-color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
}

.age-filter {
    display: flex;
    gap: 8px;
}

.age-filter select {
    flex: 1;
}

#apply-filters {
    width: 100%;
    background: linear-gradient(135deg, #d79aff 0%, #9b4dca 100%);
    color: white;
    border: none;
    padding: 8px 15px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(155, 77, 202, 0.4);
}

#apply-filters:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(155, 77, 202, 0.6);
}

.filter-buttons {
    display: flex;
    gap: 8px;
}

#apply-filters,
#clear-filters {
    flex: 1;
    background: linear-gradient(135deg, #d79aff 0%, #9b4dca 100%);
    color: white;
    border: none;
    padding: 8px 15px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(155, 77, 202, 0.4);
}

#apply-filters:hover,
#clear-filters:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(155, 77, 202, 0.6);
}

#clear-filters {
    background: linear-gradient(135deg, #ff9a9a 0%, #ca4d4d 100%);
}

.chat-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid rgba(59, 3, 55, 0.2);
}

.chat-actions {
    display: flex;
    justify-content: flex-end; /* move to right */
    padding: 6px 10px;
    margin-top: 0;
    border-top: 1px solid transparent; /* keep structure, invisible */
    border-bottom: 1px solid transparent; /* keep structure, invisible */
}

.chat-area {
    width: 70%;
    display: flex;
    flex-direction: column;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.action-btn {
    background: linear-gradient(135deg, #d79aff 0%, #9b4dca 100%);
    color: white;
    border: none;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(155, 77, 202, 0.4);
    margin-left: 10px;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(155, 77, 202, 0.6);
}

#report-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    padding: 20px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(47, 6, 66, 0.3);
    z-index: 1000;
}
body.dark #report-popup {
    background-color: rgba(34, 26, 42, 0.95);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

#report-popup h3 {
    margin-bottom: 15px;
    color: #2f0642;
}

#report-popup label {
    display: block;
    margin-bottom: 10px;
}

#report-popup input[type="radio"] {
    margin-right: 5px;
}

#report-popup textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid rgba(59, 3, 55, 0.2);
    border-radius: 10px;
    margin-top: 10px;
}

#report-popup .popup-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 15px;
}

#report-popup .popup-actions button {
    margin-left: 10px;
}

.default-state {
    display: none;
    flex: 1;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.5);
}
body.dark .default-state { background: rgba(255, 255, 255, 0.05); }
body.dark .default-message { color: #e8e1ee; }

.default-message {
    text-align: center;
    color: #3b0337;
    padding: 20px;
}

.default-message i {
    font-size: 48px;
    margin-bottom: 20px;
    color: #9b4dca;
}

.default-message h2 {
    margin-bottom: 10px;
    color: #2f0642;
}

.default-message p {
    color: #666;
}

.chat-area .chat-header,
.chat-area .chat-actions,
.chat-area .messages,
.chat-area .message-input {
    display: none;
}

.chat-area.active .chat-header,
.chat-area.active .chat-actions,
.chat-area.active .messages,
.chat-area.active .message-input {
    display: flex;
}

.chat-area.active .default-state {
    display: none;
}

.chat-area:not(.active) .default-state {
    display: flex;
}

.logout-container {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.logout-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5253 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(238, 82, 83, 0.3);
}

.logout-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(238, 82, 83, 0.4);
    background: linear-gradient(135deg, #ff5252 0%, #dd4444 100%);
}

.logout-btn i {
    font-size: 16px;
}

.message.incoming {
    /* iMessage-like light bubble with subtle lavender tint */
    background: linear-gradient(135deg, #ffffff 0%, #f5efff 100%);
    align-self: flex-start;
    color: #2f0642;
    border: 1px solid rgba(155, 77, 202, 0.15);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    border-bottom-right-radius: 20px;
    border-bottom-left-radius: 8px; /* inward corner like iMessage */
}

.message.outgoing {
    /* keep brand purple but refine to iMessage style */
    background: linear-gradient(135deg, #d79aff 0%, #9b4dca 100%);
    align-self: flex-end;
    color: #ffffff;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 8px; /* inward corner like iMessage */
}

/* remove glossy overlay to avoid white edge artifacts on rounded corners */
.message.incoming::before,
.message.outgoing::before { content: none; }

/* System message (notifications like image expired/removed) */
.message.system {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 4px 8px;
    margin: 8px 12px;
    max-width: 100%;
    align-self: center;
}
.message.system .message-content {
    background: transparent !important;
    color: rgba(59, 3, 55, 0.6);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}
.message.system .message-timestamp { display: none; }

/* Dark theme contrast for system messages */
body.dark .message.system .message-content { color: rgba(255, 255, 255, 0.65); }

.message-timestamp {
    position: absolute;
    bottom: -18px;
    font-size: 0.7em;
    color: rgba(59, 3, 55, 0.45) !important;
}

.message.incoming .message-timestamp {
    left: 0;
}

.message.outgoing .message-timestamp {
    right: 0;
}

/* Smooth message animations */
.message {
    animation: messageAppear 0.3s ease-out;
}

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

.connection-status {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 10px 20px;
    border-radius: 20px;
    color: white;
    font-size: 14px;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.connection-status.connected {
    background: #4CAF50;
}

.connection-status.disconnected {
    background: #f44336;
}

.chat-item.unread {
    background-color: rgba(215, 154, 255, 0.1);
    font-weight: bold;
}

.unread-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #9b4dca;
    border-radius: 50%;
    margin-left: 5px;
}

.tab-btn.has-unread::after {
    content: '';
    position: absolute;
    top: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    background-color: #9b4dca;
    border-radius: 50%;
}

.unread-indicator {
    width: 8px;
    height: 8px;
    background-color: #9b4dca;
    border-radius: 50%;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

/* removed top-right new message dot; we use list highlighting instead */

.typing-indicator {
    padding: 10px;
    margin: 10px;
    background: rgba(155, 77,202, 0.1);
    border-radius: 20px;
    display: flex;
    align-items: center;
    font-size: 14px;
    animation: fadeIn 0.3s ease-in;
}

.typing-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.typing-text {
    color: #666;
    margin-right: 10px;
}

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

.typing-dots span {
    width: 4px;
    height: 4px;
    background: #9b4dca;
    border-radius: 50%;
    display: inline-block;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-4); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opactiy: 1; }
}

.message-info {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    font-size: 12px;
    margin-top: 5px;
}

.message.outgoing .message-status {
    margin-left: auto;
}

/* highlight for search jump */
.search-hit {
    box-shadow: 0 0 0 3px rgba(155, 77, 202, 0.25) inset;
}

/* File Upload Button */
.attach-btn {
    background: none;
    border: none;
    color: #9b4dca;
    cursor: pointer;
    padding: 0 10px;
    font-size: 20px;
    transition: all 0.3s ease;
}

.attach-btn:hover {
    color: #2f0642;
}

/* Preferences Popup */
.popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.popup-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 15px;
    min-width: 300px;
}

.preference-item {
    margin: 15px 0;
}

/* Image Send Settings actions and button styles */
#image-settings .popup-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 15px;
}

#image-cancel {
    background: rgba(155, 77, 202, 0.12);
    color: #9b4dca;
    border: 1px solid rgba(155, 77, 202, 0.35);
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#image-cancel:hover {
    background: rgba(155, 77, 202, 0.18);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(155, 77, 202, 0.25);
}

#image-cancel:active {
    transform: translateY(0);
    box-shadow: 0 1px 6px rgba(155, 77, 202, 0.2);
}

#image-cancel:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(155, 77, 202, 0.25);
}

/* Message Status Indicators */
.message-status {
    font-size: 12px;
    margin-left: 5px;
    color: #9b4dca;
}

/* Search Container */
.chat-toolbar { display: none; }

.search-toggle-btn {
    width: 36px;
    height: 36px;
    border-radius: 18px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, #d79aff 0%, #9b4dca 100%);
    box-shadow: 0 6px 16px rgba(155, 77, 202, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.search-toggle-btn:hover { transform: translateY(-1px); }
.search-toggle-btn:active { transform: translateY(0); box-shadow: 0 4px 12px rgba(155,77,202,0.3); }

.search-popover {
    position: absolute;
    right: 14px;
    top: 10px;
    width: min(420px, 70%);
    background: linear-gradient(135deg, rgba(255,255,255,0.96) 0%, rgba(245,235,255,0.96) 100%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(59, 3, 55, 0.15);
    border-radius: 16px;
    padding: 10px;
    box-shadow: 0 10px 30px rgba(47, 6, 66, 0.18);
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 50;
}

.search-popover.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: all; }

.search-popover-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.9);
    border-radius: 12px;
    padding: 8px 12px;
}

.search-popover-inner input {
    border: none;
    outline: none;
    background: transparent;
    flex: 1;
    font-size: 14px;
    color: #3b0337;
}

/* Theme Support */
body.dark {
    background: #1a1a1a;
    color: #fff;
}

body.dark .chat-container {
    background: linear-gradient(135deg, rgba(30, 30, 30, 0.9) 0%, rgba(20, 20, 20, 0.9) 100%);
}
/* Dark: chat content surface to reduce glow */
body.dark .chat-area { background: linear-gradient(180deg, rgba(32, 28, 36, 0.92), rgba(32, 28, 36, 0.92)); }

/* Font Size Classes */
.font-size-small {
    font-size: 0.9em;
}

.font-size-medium {
    font-size: 1em;
}

.font-size-large {
    font-size: 1.1em;
}

/* File Upload Preview */
.file-preview {
    display: flex;
    align-items: center;
    padding: 5px 10px;
    background: rgba(155, 77, 202, 0.1);
    border-radius: 10px;
    margin: 5px 0;
}

.file-preview img {
    max-width: 50px;
    max-height: 50px;
    margin-right: 10px;
}

.search-results { display: none; }

.message-input .search-results {
    position: absolute;
    bottom: 60px;
    left: 60px;
    right: 95px;
    background: white;
    border: 1px solid rgba(59, 3, 55, 0.15);
    border-radius: 12px;
    max-height: 280px;
    overflow-y: auto;
    z-index: 60;
    box-shadow: 0 10px 24px rgba(47, 6, 66, 0.18);
}

/* New inline search (slides over the input) */
.message-input { position: relative; align-items: center; gap: 8px; }
.search-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 18px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, #d79aff 0%, #9b4dca 100%);
    box-shadow: 0 6px 16px rgba(155, 77, 202, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.search-icon-btn:hover { transform: translateY(-1px); }
.search-icon-btn:active { transform: translateY(0); box-shadow: 0 4px 12px rgba(155,77,202,0.3); }

.search-slide {
    position: absolute;
    left: 60px; /* after attach + search icon */
    right: 95px; /* before send */
    height: 40px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    background: linear-gradient(135deg, rgba(255,255,255,0.96) 0%, rgba(245,235,255,0.96) 100%);
    border: 1px solid rgba(59, 3, 55, 0.15);
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(47,6,66,0.12);
    transform: scaleX(0.6) translateY(8px);
    transform-origin: left center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}
body.dark .search-slide {
    background: linear-gradient(135deg, rgba(45,35,55,0.96) 0%, rgba(36,28,44,0.96) 100%);
    border-color: rgba(255, 255, 255, 0.12);
}

.message-input.search-mode .search-slide { opacity: 1; transform: scaleX(1) translateY(0); pointer-events: all; }
.message-input.search-mode #message-text { visibility: hidden; }
.search-slide input { flex: 1; border: none; background: transparent; outline: none; font-size: 14px; color: #3b0337; }

/* Center and tighten actions header */
.chat-actions { justify-content: center; padding: 6px 10px; margin-top: 0; }

/* Truncate chat preview text */
.chat-preview { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.search-result-item {
    padding: 10px;
    border-bottom: 1px solid rgba(59, 3, 55, 0.1);
    cursor: pointer;
}

.search-result-item:hover {
    background: rgba(215, 154, 255, 0.1);
}

.search-result-item .highlight {
    background: rgba(155, 77, 202, 0.2);
    padding: 2px;
    border-radius: 3px;
}

/* Theme Toggle (top-right) */
.theme-toggle { position: fixed; top: 16px; right: 16px; z-index: 3000; }
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid rgba(155, 77, 202, 0.3);
    background: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(245,235,255,0.9) 100%);
    color: #2f0642;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(155, 77, 202, 0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.theme-toggle-btn:hover { transform: translateY(-1px); }
.theme-toggle-btn i { color: #9b4dca; }

body.dark .theme-toggle-btn {
    background: linear-gradient(135deg, rgba(45,35,55,0.9) 0%, rgba(32,24,40,0.9) 100%);
    color: #e8e1ee;
    border-color: rgba(255,255,255,0.12);
    box-shadow: 0 6px 16px rgba(0,0,0,0.35);
}
body.dark .theme-toggle-btn i { color: #d79aff; }
