/* ==================== CHAT STYLES ==================== */

.chat-container {
    display: flex;
    height: calc(100vh - 120px);
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* SIDEBAR CONTATTI */
.chat-sidebar {
    width: 300px;
    background: #f8f9fa;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-search {
    padding: 12px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
}

.chat-search input {
    border: none;
    border-radius: 20px;
    padding: 10px 15px;
    background: #e8e8e8;
    width: 100%;
    font-size: 0.9rem;
}

.chat-search input:focus {
    background: #ddd;
    outline: none;
}

/* LISTA CONTATTI */
.chat-contacts-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.chat-contact-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
    gap: 10px;
}

.chat-contact-item:hover {
    background: #f5f5f5;
}

.chat-contact-item.active {
    background: #e3f2fd;
    border-left: 4px solid #2196F3;
}

.contact-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2196F3 0%, #1565C0 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.contact-info {
    flex: 1;
    min-width: 0;
}

.contact-name {
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 3px;
}

.online-badge {
    width: 10px;
    height: 10px;
    background: #28a745;
    border-radius: 50%;
    display: inline-block;
}

.contact-preview {
    color: #999;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background: #2196F3;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: inline-grid;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    flex-shrink: 0;
}

/* AREA CHAT PRINCIPALE */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
}

/* HEADER CHAT */
.chat-header {
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
}

.contact-details h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #333;
}

.status-info {
    font-size: 0.85rem;
    color: #999;
    margin-top: 3px;
}

.status-online {
    color: #4CAF50;
    font-weight: 500;
}

.status-offline {
    color: #999;
}

/* AREA MESSAGGI */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 15px;
    padding-right: 40px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fff;
}

.message {
    display: flex;
    margin-bottom: 8px;
    align-items: flex-end;
    gap: 8px;
}

.message.sent {
    justify-content: flex-end;
}

.message.received {
    justify-content: flex-start;
}

.message-content {
    background: white;
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 70%;
    word-wrap: break-word;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.message.sent .message-content {
    background: linear-gradient(135deg, #2196F3 0%, #1565C0 100%);
    color: white;
}

.message.received .message-content {
    background: white;
    color: #333;
}

.message-content p {
    margin: 0;
    line-height: 1.4;
}

.message-attachment {
    margin-bottom: 8px;
}

.attachment-link {
    color: inherit;
    text-decoration: none;
    padding: 8px 10px;
    background: rgba(0,0,0,0.1);
    border-radius: 6px;
    display: inline-block;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.attachment-link:hover {
    background: rgba(0,0,0,0.15);
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    color: #999;
}

.message.sent .message-meta {
    color: #888;
}

.message-status {
    font-weight: bold;
}

/* INPUT AREA */
.chat-input-area {
    padding: 12px 15px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
}

.message-form {
    display: flex;
    gap: 0;
}

.input-group {
    display: flex;
    align-items: stretch;
    gap: 0;
    width: 100%;
    border: ;
    padding: 5px 0px;
    transition: border 0.2s;
}

.input-group:focus-within {
    border-color: #2196F3;
}

.btn-icon,
.btn-emoji,
.btn-send {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px 8px;
    transition: transform 0.2s;
    color: #666;
}

.btn-icon:hover,
.btn-emoji:hover,
.btn-send:hover {
    transform: scale(1.1);
}

.btn-send {
    color: #2196F3;
    font-weight: bold;
    font-size: 1.3rem;
}

.message-textarea {
    flex: 1;
    border: none;
    resize: none;
    padding: 8px 5px;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.4;
    max-height: 100px;
    outline: none;
}

/* EMPTY STATE */
.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 15px;
}

.chat-empty p {
    font-size: 1.1rem;
}

/* EMOJI PICKER */
.emoji-picker {
    position: absolute;
    bottom: 100px;
    right: 20px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-width: 300px;
}

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

.emoji-grid span {
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.2s;
    text-align: center;
    font-size: 1.2rem;
}

.emoji-grid span:hover {
    background: #f0f0f0;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
    }
    
    .chat-sidebar {
        width: 100%;
        height: 150px;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }
    
    .chat-contacts-list {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
    }
    
    .chat-contact-item {
        flex-direction: column;
        width: 80px;
        text-align: center;
        border-bottom: none;
        border-right: 1px solid #f0f0f0;
        padding: 10px 5px;
        gap: 5px;
    }
    
    .contact-info {
        display: none;
    }
    
    .message-content {
        max-width: 90%;
    }
    
    .emoji-picker {
        bottom: auto;
        top: -250px;
        right: 0;
        left: auto;
    }
}

/* Scrollbar personalizzata */
.chat-messages::-webkit-scrollbar,
.chat-contacts-list::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track,
.chat-contacts-list::-webkit-scrollbar-track {
    background: #f0f0f0;
}

.chat-messages::-webkit-scrollbar-thumb,
.chat-contacts-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.chat-contacts-list::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.delete-msg-btn {
    padding: 0 !important;
    border: none !important;
    background: none !important;
    color: #dc3545 !important;
    font-size: 16px;
    opacity: 0.5;
    cursor: pointer;
    margin-left: 3px;
    margin-right: 15px;
    align-self: flex-start;
    margin-top: 2px;
    position: relative;
    z-index: 100;
    transition: opacity 0.2s;
}

.delete-msg-btn:hover {
    opacity: 1;
}

.message-row {
    display: flex;
    gap: 3px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.message-row-sent {
    justify-content: flex-end;
}

.message-row-received {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 60%;
    word-wrap: break-word;
}

.message-bubble.sent {
    background: #007bff;
    color: white;
}

.message-bubble.received {
    background: #e9ecef;
    color: black;
}

/* ==================== DARK MODE STYLES ==================== */

html.dark-mode .chat-container {
    background: #2d2d2d;
}

html.dark-mode .chat-sidebar {
    background: #1a1a1a;
    border-right-color: #444;
}

html.dark-mode .chat-search {
    background: #2d2d2d;
    border-bottom-color: #444;
}

html.dark-mode .chat-search input {
    background: #3a3a3a;
    color: #e0e0e0;
    border-color: #444;
}

html.dark-mode .chat-search input:focus {
    background: #3a3a3a;
    color: #e0e0e0;
    border-color: #2196F3;
}

html.dark-mode .chat-contact-item {
    background: #2d2d2d;
    border-color: #444;
    color: #e0e0e0;
}

html.dark-mode .chat-contact-item:hover {
    background: #3a3a3a;
}

html.dark-mode .chat-contact-item.active {
    background: #2196F3;
}

html.dark-mode .chat-main {
    background: #1a1a1a;
    border-left-color: #444;
}

html.dark-mode .chat-header {
    background: #2d2d2d;
    border-bottom-color: #444;
    color: #e0e0e0;
}

html.dark-mode .chat-messages {
    background: #1a1a1a;
    color: #e0e0e0;
}

html.dark-mode .message-bubble.sent {
    background: #1565C0;
    color: #e0e0e0;
}

html.dark-mode .message-bubble.received {
    background: #3a3a3a;
    color: #e0e0e0;
    border: 1px solid #555;
}

html.dark-mode .message-time {
    color: #b0b0b0;
}

html.dark-mode .chat-input-group {
    background: #2d2d2d;
    border-top-color: #444;
}

html.dark-mode .chat-input-group .form-control {
    background: #3a3a3a;
    color: #e0e0e0;
    border-color: #444;
}

html.dark-mode .chat-input-group .form-control:focus {
    background: #3a3a3a;
    color: #e0e0e0;
    border-color: #2196F3;
    box-shadow: 0 0 0 0.25rem rgba(33, 150, 243, 0.25);
}

html.dark-mode .list-group-item {
    background: #2d2d2d;
    border-color: #444;
    color: #e0e0e0;
}

html.dark-mode .list-group-item:hover {
    background: #3a3a3a;
}

html.dark-mode .list-group-item.active {
    background: #2196F3;
    border-color: #2196F3;
}

html.dark-mode .badge {
    background-color: #2196F3;
}

html.dark-mode .badge.bg-danger {
    background-color: #dc3545 !important;
}

html.dark-mode .badge.bg-success {
    background-color: #28a745 !important;
}

html.dark-mode .badge.bg-secondary {
    background-color: #6c757d !important;
}
/* Input fields in dark mode */
html.dark-mode input[type="text"],
html.dark-mode input[type="email"],
html.dark-mode input[type="password"],
html.dark-mode input[type="search"],
html.dark-mode input[type="number"],
html.dark-mode input[type="file"],
html.dark-mode textarea,
html.dark-mode .form-control {
    background-color: #3a3a3a !important;
    color: #e0e0e0 !important;
    border-color: #444 !important;
}

html.dark-mode input[type="text"]::placeholder,
html.dark-mode input[type="email"]::placeholder,
html.dark-mode input[type="password"]::placeholder,
html.dark-mode input[type="search"]::placeholder,
html.dark-mode textarea::placeholder,
html.dark-mode .form-control::placeholder {
    color: #888 !important;
    opacity: 1;
}

html.dark-mode input[type="file"]::file-selector-button {
    background-color: #2196F3 !important;
    color: white !important;
    border: none !important;
    padding: 6px 12px !important;
    border-radius: 4px !important;
    cursor: pointer !important;
}

html.dark-mode input[type="text"]:focus,
html.dark-mode input[type="email"]:focus,
html.dark-mode input[type="password"]:focus,
html.dark-mode input[type="search"]:focus,
html.dark-mode input[type="number"]:focus,
html.dark-mode input[type="file"]:focus,
html.dark-mode textarea:focus,
html.dark-mode .form-control:focus {
    background-color: #3a3a3a !important;
    color: #e0e0e0 !important;
    border-color: #2196F3 !important;
    box-shadow: 0 0 0 0.25rem rgba(33, 150, 243, 0.25) !important;
}

html.dark-mode .message-textarea {
    background-color: #3a3a3a !important;
    color: #e0e0e0 !important;
    border-color: #444 !important;
}

html.dark-mode .message-textarea:focus {
    background-color: #3a3a3a !important;
    color: #e0e0e0 !important;
    border-color: #2196F3 !important;
}
