* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: #000;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    padding: 0;
}

.chat-container {
    width: 100%;
    max-width: 450px;
    height: 100vh;
    background-color: #fff;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-header {
    background-color: #212121;
    color: white;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    height: 60px;
}

.back-button {
    margin-right: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    flex-grow: 1;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    margin-right: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.username {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}


.header-actions {
    display: flex;
    gap: 20px;
}

.header-actions i {
    cursor: pointer;
    font-size: 18px;
}

.chat-messages {
    flex-grow: 1;
    padding: 12px;
    overflow-y: auto;
    background-color: #999;
    display: flex;
    flex-direction: column;
    background-image: url('bg.png');
    background-blend-mode: multiply;
    background-repeat: repeat;
    background-size: cover;
    
}

.loading {
    text-align: center;
    padding: 20px;
    color: #888;
    font-style: italic;
}

.message-container {
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
    max-width: 80%;
    position: relative;
}

.message-container.sent {
    align-self: flex-end;
    align-items: flex-end;
}

.message-container.received {
    align-self: flex-start;
    align-items: flex-start;
}

.message-sender {
    font-size: 16px;
    margin-bottom: 3px;
    color: #000;
    font-weight: bold;
}

/* Aggiungi queste modifiche al tuo CSS */

.message-bubble {
    padding: 8px 12px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    max-width: 100%;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    padding-bottom: 24px; /* Spazio per l'orario */
}

.message-time {
    position: absolute;
    bottom: 6px;
    right: 12px;
    font-size: 11px;
    color: #999;
    margin: 0;
}

.message-container.sent .message-bubble {
    background-color: #e3ffc8;
    border-bottom-right-radius: 4px;
}

.message-container.received .message-bubble {
    background-color: #ffffff;
    border-bottom-left-radius: 4px;
}

.message-text {
    font-size: 15px;
    line-height: 1.4;
}

.message-time {
    font-size: 11px;
    color: #959595;
    margin-top: 2px;
    margin-right: 6px;
}

.date-separator {
    text-align: center;
    margin: 15px 0;
    position: relative;
    width: 100%;
}

.date-separator span {
    background-color: rgba(225, 245, 254, 0.9);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    color: #555;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}

.chat-input {
    padding: 25px 10px 10px; /* Increased top padding to 20px */
    margin-bottom: 0; /* Remove any bottom margin */
    background-color: #f5f5f5;
    display: flex;
    align-items: center;
    border-top: 1px solid #e0e0e0;
    position: relative; /* Add position relative */
    bottom: 8px;
    
}

/* Adjust input field and icons to be vertically centered */
.input-text input, .input-attachment i, .input-actions i {
    position: relative;
    bottom: 5px; /* Move elements up slightly within the container */
}

.input-attachment, .input-actions {
    padding: 0 12px;
    color: #666;
    cursor: pointer;
}

.input-attachment i, .input-actions i {
    font-size: 20px;
    
}

.input-text {
    flex-grow: 1;
    

}

.input-text input {
    width: 100%;
    padding: 10px 15px;
    border: none;
    border-radius: 20px;
    outline: none;
    background-color: white;
    font-size: 15px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);

}

/* Stilizzazione per i link all'interno dei messaggi */
.message-text a {
    color: #0088cc;
    text-decoration: none;
}

.message-text a:hover {
    text-decoration: underline;
}

/* Stilizzazione per l'area di scorrimento */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Animazione di caricamento */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-container {
    animation: fadeIn 0.2s ease;
}

/* Stili per la barra di ricerca */
.search-bar {
    display: flex;
    align-items: center;
    flex-grow: 1;
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 0 12px;
    margin-left: 5px;
    height: 36px;
    position: relative;
}

.search-bar::before {
    content: "\f002";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    color: white;
    opacity: 0.8;
    margin-right: 8px;
    font-size: 14px;
}

.search-bar input {
    background: transparent;
    border: none;
    color: white;
    flex-grow: 1;
    font-size: 15px;
    padding: 5px 0;
    outline: none;
}

.search-bar input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.search-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-actions i {
    color: white;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    font-size: 14px;
}

.search-actions i:hover {
    opacity: 1;
}

#result-count {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    min-width: 10px;
    text-align: right;
}

/* Stili per i risultati evidenziati */
.highlighted {
    background-color: rgba(255, 213, 79, 0.5);
    border-radius: 2px;
    padding: 0 1px;
    font-weight: bold;
}

.message-text.active-result .highlighted {
    background-color: #ffb700;
    color: #000;
}

.message-text.active-result {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* Stile per nessun risultato */
.no-results {
    text-align: center;
    padding: 20px;
    color: #888;
    font-style: italic;
}

/* Modifiche specifiche per rendering mobile */
@media (max-width: 480px) {
    .chat-container {
        height: 100vh;
        max-width: 100%;
        border-radius: 0;
    }
    
    .message-container {
        max-width: 90%;
    }
    
    body {
        background-color: #fff;
    }
    
    .chat-header {
        padding: 8px 12px;
    }
    
    .chat-messages {
        padding: 10px;
    }
    
    .chat-input {
        padding: 8px;
    }
}

/* Supporto per schermi più piccoli */
@media (max-width: 320px) {
    .chat-header {
        padding: 5px 8px;
    }
    
    .avatar {
        width: 32px;
        height: 32px;
        margin-right: 8px;
    }
    
    .username {
        font-size: 15px;
    }
    
    .status {
        font-size: 12px;
    }
    
    .message-container {
        max-width: 85%;
    }
}