﻿/* ========== TEMA CHIARO (default) ========== */
:root {
    /* Colori brand */
    --bly-primary: rgb(22, 80, 166);
    --bly-primary-light: rgba(22, 80, 166, 0.1);
    --bly-primary-dark: rgb(18, 64, 133);
    --bly-secondary: #6c757d;
    --bly-success: #28a745;
    --bly-danger: #dc3545;
    --bly-warning: #ffc107;
    --bly-info: #17a2b8;
    --bly-light: #f8f9fa;
    --bly-dark: #343a40;
    /* Colori di sfondo */
    --bg-body: #f5f7fa;
    --bg-card: #ffffff;
    --bg-sidebar: #dfe9f7;
    --bg-footer: #222;
    --bg-navbar: var(--bly-primary);
    --bg-modal: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: #f8f9fa;
    --bg-active: #e9ecef;
    --bg-overlay: rgba(0, 0, 0, 0.9);
    --bg-attachment: rgba(255, 255, 255, 0.5);
    /* Colori messaggi chat */
    --chat-sent-bg: #dfe9f7;
    --chat-receive-bg: #f5f5f7;
    --chat-replied-bg: rgba(0, 0, 0, 0.05);
    --chat-text-color: #212325;
    --chat-action-hover: #4a72b8;
    /* Colori testo */
    --text-primary: #333;
    --text-secondary: #6c757d;
    --text-light: #999;
    --text-white: #ffffff;
    --text-black: #000;
    --text-heading: #212529;
    --text-muted: #495057;
    --text-gray: #555;
    --text-dark: #444;
    /* Colori bordi */
    --border-color: #e5e5e5;
    --border-color-light: #dee2e6;
    --border-color-dark: #ccc;
    /* Colori avatar e icone */
    --avatar-bg: #dee2e6;
    --avatar-text: #495057;
    --icon-color: #6c757d;
    --icon-hover: #495057;
    /* Colori stati */
    --status-online: green;
    --status-offline: red;
    --status-read: #4fc3f7;
    --status-delivered: #aaa;
    --status-sent: #aaa;
    /* Colori chiamate */
    --call-audio: #4caf50;
    --call-video: #2196f3;
    --call-end: #f44336;
    --call-bg-screen: rgba(0, 0, 0, 0.9);
    --call-control-bg: #444;
    --call-control-hover: #666;
    /* Ombre */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.25);
    --shadow-xl: 0 8px 20px rgba(0, 0, 0, 0.15);
    /* Opacità */
    --overlay-bg: rgba(0, 0, 0, 0.5);
    --overlay-light: rgba(0, 0, 0, 0.05);
    --overlay-medium: rgba(0, 0, 0, 0.1);
    /* Altri colori specifici */
    --whatsapp-green: #128C7E;
    --bootstrap-blue: #0d6efd;
    --link-blue: #007bff;
    --video-bg: #222;
    --typing-dots: #555;
    --pin-active: gold;
    --drag-border: #007bff;
    --bg-contact: #dfe9f7;
    --bg-textarea: #ffffff;
}

/* ========== TEMA SCURO ========== */
/* Attivato tramite classe dark-theme sul body O preferenze sistema */
body.dark-theme {
    /* Colori brand (rimangono simili ma più soft) */
    --bly-primary: rgb(45, 110, 200);
    --bly-primary-light: rgba(45, 110, 200, 0.15);
    --bly-primary-dark: rgb(35, 90, 170);
    --bly-secondary: #8d97a1;
    --bly-success: #3fce64;
    --bly-danger: #e85865;
    --bly-warning: #ffd54f;
    --bly-info: #29c4d8;
    --bly-light: #2a2d31;
    --bly-dark: #f0f0f0;
    /* Colori di sfondo */
    --bg-body: #1a1d21;
    --bg-card: #242629;
    --bg-sidebar: #2a3441;
    --bg-footer: #1a1d21;
    --bg-navbar: var(--bly-primary-dark);
    --bg-modal: #2a2d31;
    --bg-input: #36393f;
    --bg-hover: #2e3136;
    --bg-active: #4a4d52;
    --bg-overlay: rgba(0, 0, 0, 0.95);
    --bg-attachment: rgba(50, 50, 50, 0.5);
    /* Colori messaggi chat */
    --chat-sent-bg: #2b4d6b;
    --chat-receive-bg: #2e3136;
    --chat-replied-bg: rgba(255, 255, 255, 0.05);
    --chat-text-color: #e3e5e8;
    --chat-action-hover: #5b8fd8;
    /* Colori testo */
    --text-primary: #e3e5e8;
    --text-secondary: #b9bbbe;
    --text-light: #ffffff;
    --text-white: #ffffff;
    --text-black: #000000;
    --text-heading: #f2f3f5;
    --text-muted: #b9bbbe;
    --text-gray: #dcddde;
    --text-dark: #e3e5e8;
    /* Colori bordi */
    --border-color: #3a3d42;
    --border-color-light: #4a4d52;
    --border-color-dark: #2a2d31;
    /* Colori avatar e icone */
    --avatar-bg: #3a3d42;
    --avatar-text: #b9bbbe;
    --icon-color: #b9bbbe;
    --icon-hover: #dcddde;
    /* Colori stati */
    --status-online: #3ba55d;
    --status-offline: #ed4245;
    --status-read: #4fc3f7;
    --status-delivered: #999;
    --status-sent: #999;
    /* Colori chiamate */
    --call-audio: #3ba55d;
    --call-video: #4dabf7;
    --call-end: #ed4245;
    --call-bg-screen: rgba(0, 0, 0, 0.95);
    --call-control-bg: #3a3d42;
    --call-control-hover: #4a4d52;
    /* Ombre */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 8px 20px rgba(0, 0, 0, 0.4);
    /* Opacità */
    --overlay-bg: rgba(0, 0, 0, 0.7);
    --overlay-light: rgba(255, 255, 255, 0.05);
    --overlay-medium: rgba(255, 255, 255, 0.1);
    /* Altri colori specifici */
    --whatsapp-green: #25d366;
    --bootstrap-blue: #4dabf7;
    --link-blue: #4dabf7;
    --video-bg: #1a1d21;
    --typing-dots: #b9bbbe;
    --pin-active: #ffd54f;
    --drag-border: #4dabf7;
    --bg-contact: #3f4247;
    --bg-textarea: #3f4247;
}

/* Tema scuro automatico basato su preferenze sistema (solo se non c'è override manuale) */
@media (prefers-color-scheme: dark) {
    body:not(.light-theme) {
        /* Colori brand (rimangono simili ma più soft) */
        --bly-primary: rgb(45, 110, 200);
        --bly-primary-light: rgba(45, 110, 200, 0.15);
        --bly-primary-dark: rgb(35, 90, 170);
        --bly-secondary: #8d97a1;
        --bly-success: #3fce64;
        --bly-danger: #e85865;
        --bly-warning: #ffd54f;
        --bly-info: #29c4d8;
        --bly-light: #2a2d31;
        --bly-dark: #f0f0f0;
        /* Colori di sfondo */
        --bg-body: #1a1d21;
        --bg-card: #242629;
        --bg-sidebar: #2a3441;
        --bg-footer: #1a1d21;
        --bg-navbar: var(--bly-primary-dark);
        --bg-modal: #2a2d31;
        --bg-input: #36393f;
        --bg-hover: #2e3136;
        --bg-active: #4a4d52;
        --bg-overlay: rgba(0, 0, 0, 0.95);
        --bg-attachment: rgba(50, 50, 50, 0.5);
        /* Colori messaggi chat */
        --chat-sent-bg: #2b4d6b;
        --chat-receive-bg: #2e3136;
        --chat-replied-bg: rgba(255, 255, 255, 0.05);
        --chat-text-color: #e3e5e8;
        --chat-action-hover: #5b8fd8;
        /* Colori testo */
        --text-primary: #e3e5e8;
        --text-secondary: #b9bbbe;
        --text-light: #ffffff;
        --text-white: #ffffff;
        --text-black: #000000;
        --text-heading: #f2f3f5;
        --text-muted: #b9bbbe;
        --text-gray: #dcddde;
        --text-dark: #e3e5e8;
        /* Colori bordi */
        --border-color: #3a3d42;
        --border-color-light: #4a4d52;
        --border-color-dark: #2a2d31;
        /* Colori avatar e icone */
        --avatar-bg: #3a3d42;
        --avatar-text: #b9bbbe;
        --icon-color: #b9bbbe;
        --icon-hover: #dcddde;
        /* Colori stati */
        --status-online: #3ba55d;
        --status-offline: #ed4245;
        --status-read: #4fc3f7;
        --status-delivered: #999;
        --status-sent: #999;
        /* Colori chiamate */
        --call-audio: #3ba55d;
        --call-video: #4dabf7;
        --call-end: #ed4245;
        --call-bg-screen: rgba(0, 0, 0, 0.95);
        --call-control-bg: #3a3d42;
        --call-control-hover: #4a4d52;
        /* Ombre */
        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.5);
        --shadow-xl: 0 8px 20px rgba(0, 0, 0, 0.4);
        /* Opacità */
        --overlay-bg: rgba(0, 0, 0, 0.7);
        --overlay-light: rgba(255, 255, 255, 0.05);
        --overlay-medium: rgba(255, 255, 255, 0.1);
        /* Altri colori specifici */
        --whatsapp-green: #25d366;
        --bootstrap-blue: #4dabf7;
        --link-blue: #4dabf7;
        --video-bg: #1a1d21;
        --typing-dots: #b9bbbe;
        --pin-active: #ffd54f;
        --drag-border: #4dabf7;
        --bg-contact: #3f4247;
        --bg-textarea: #3f4247;
    }
}

/* ========== TOGGLE TEMA ========== */
/* Stile per il pulsante di switch tema */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
    color: var(--text-white);
}

    .theme-toggle:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }

    .theme-toggle i {
        font-size: 1.25rem;
    }

/* Transizione fluida tra temi */
body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===== Scrollbar globale stile WhatsApp ===== */

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.2) transparent;
}

    /* WebKit (Chrome, Edge, Safari) */
    *::-webkit-scrollbar {
        width: 6px; /* spessore */
        height: 6px; /* per scroll orizzontale */
    }

    *::-webkit-scrollbar-track {
        background: transparent; /* sfondo della track */
    }

    *::-webkit-scrollbar-thumb {
        background-color: rgba(0, 0, 0, 0.2); /* colore del thumb */
        border-radius: 10px; /* angoli arrotondati */
        border: 2px solid transparent; /* distanza thumb-track */
        transition: background-color 0.2s ease-in-out;
    }

        *::-webkit-scrollbar-thumb:hover {
            background-color: rgba(0, 0, 0, 0.4); /* colore al passaggio del mouse */
        }





    /* ========== OVERRIDE BOOTSTRAP PER TEMA SCURO ========== */
    body.dark-theme .card,
    @media (prefers-color-scheme: dark) {
        body: not(.light-theme) .card

{
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

}

body.dark-theme .modal-content,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .modal-content

{
    background-color: var(--bg-modal);
    color: var(--text-primary);
}

}

body.dark-theme .modal-header,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .modal-header

{
    border-bottom-color: var(--border-color);
}

}

body.dark-theme .modal-footer,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .modal-footer

{
    border-top-color: var(--border-color);
}

}

body.dark-theme .form-control,
body.dark-theme .form-select,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .form-control, body:not(.light-theme) .form-select

{
    background-color: var(--bg-input);
    border-color: var(--border-color);
    color: var(--text-primary);
}

}

body.dark-theme .form-control:focus,
body.dark-theme .form-select:focus,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .form-control:focus, body:not(.light-theme) .form-select:focus

{
    background-color: var(--bg-input);
    border-color: var(--bly-primary);
    color: var(--text-primary);
}

}

body.dark-theme .dropdown-menu,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .dropdown-menu

{
    background-color: var(--bg-card);
    border-color: var(--border-color);
}

}

body.dark-theme .dropdown-item,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .dropdown-item

{
    color: var(--text-primary);
}

}

body.dark-theme .dropdown-item:hover,
body.dark-theme .dropdown-item:focus,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .dropdown-item:hover, body:not(.light-theme) .dropdown-item:focus

{
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

}

body.dark-theme .dropdown-divider,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .dropdown-divider

{
    border-top-color: var(--border-color);
}

}

body.dark-theme .list-group-item,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .list-group-item

{
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

}

body.dark-theme .table,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .table

{
    color: var(--text-primary);
    border-color: var(--border-color);
}

}

body.dark-theme .table thead th,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .table thead th

{
    border-color: var(--border-color);
    background-color: var(--bg-hover);
}

}

body.dark-theme .table-striped > tbody > tr:nth-of-type(odd),
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .table-striped > tbody > tr:nth-of-type(odd)

{
    background-color: var(--bg-hover);
}

}

body.dark-theme .btn-secondary,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .btn-secondary

{
    background-color: var(--bly-secondary);
    border-color: var(--bly-secondary);
}

}

body.dark-theme .btn-light,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .btn-light

{
    background-color: var(--bly-light);
    border-color: var(--bly-light);
    color: var(--text-primary);
}

}

body.dark-theme .btn-outline-secondary,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .btn-outline-secondary

{
    color: var(--bly-secondary);
    border-color: var(--bly-secondary);
}

}

body.dark-theme .btn-outline-secondary:hover,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .btn-outline-secondary:hover

{
    background-color: var(--bly-secondary);
    border-color: var(--bly-secondary);
    color: var(--text-white);
}

}

body.dark-theme .alert,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .alert

{
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

}

body.dark-theme .badge,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .badge

{
    background-color: var(--bg-active);
    color: var(--text-primary);
}

}

body.dark-theme .breadcrumb,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .breadcrumb

{
    background-color: var(--bg-card);
}

}

body.dark-theme .breadcrumb-item + .breadcrumb-item::before,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .breadcrumb-item + .breadcrumb-item::before

{
    color: var(--text-secondary);
}

}

body.dark-theme .pagination .page-link,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .pagination .page-link

{
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

}

body.dark-theme .pagination .page-link:hover,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .pagination .page-link:hover

{
    background-color: var(--bg-hover);
    border-color: var(--border-color);
}

}

body.dark-theme .pagination .page-item.active .page-link,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .pagination .page-item.active .page-link

{
    background-color: var(--bly-primary);
    border-color: var(--bly-primary);
}

}

body.dark-theme .nav-tabs,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .nav-tabs

{
    border-bottom-color: var(--border-color);
}

}

body.dark-theme .nav-tabs .nav-link,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .nav-tabs .nav-link

{
    color: var(--text-primary);
}

}

body.dark-theme .nav-tabs .nav-link:hover,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .nav-tabs .nav-link:hover

{
    border-color: var(--border-color);
}

}

body.dark-theme .nav-tabs .nav-link.active,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .nav-tabs .nav-link.active

{
    background-color: var(--bg-card);
    border-color: var(--border-color) var(--border-color) var(--bg-card);
    color: var(--text-primary);
}

}

body.dark-theme .accordion-item,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .accordion-item

{
    background-color: var(--bg-card);
    border-color: var(--border-color);
}

}

body.dark-theme .accordion-button,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .accordion-button

{
    background-color: var(--bg-card);
    color: var(--text-primary);
}

}

body.dark-theme .accordion-button:not(.collapsed),
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .accordion-button:not(.collapsed)

{
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

}

body.dark-theme .toast,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .toast

{
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

}

body.dark-theme .toast-header,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .toast-header

{
    background-color: var(--bg-hover);
    border-bottom-color: var(--border-color);
    color: var(--text-primary);
}

}

body.dark-theme .offcanvas,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .offcanvas

{
    background-color: var(--bg-card);
    color: var(--text-primary);
}

}

body.dark-theme .text-muted,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .text-muted

{
    color: var(--text-muted) !important;
}

}

body.dark-theme .text-secondary,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .text-secondary

{
    color: var(--text-secondary) !important;
}

}

body.dark-theme .bg-light,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .bg-light

{
    background-color: var(--bly-light) !important;
}

}

body.dark-theme .bg-dark,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .bg-dark

{
    background-color: var(--bly-dark) !important;
}

}

body.dark-theme .border,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) .border

{
    border-color: var(--border-color) !important;
}

}

body.dark-theme hr,
@media (prefers-color-scheme: dark) {
    body: not(.light-theme) hr

{
    border-top-color: var(--border-color);
    opacity: 1;
}

}

html {
    font-size: 14px;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

html {
    position: relative;
    min-height: 100%;
}

.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--avatar-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    color: var(--avatar-text);
}

.hidden-by-pin {
    display: none !important;
}
/* Uniforma le intestazioni Chat e Area conversazione */
#chat-sidebar .card-header,
#chat-area .card-header {
    background-color: var(--bly-primary);
    color: var(--text-white);
    height: 60px; /* Altezza fissa */
    display: flex;
    align-items: center;
    padding: 0 1rem; /* Margini interni uguali */
}

.table-wrapper {
    max-height: 400px;
    overflow-y: auto;
}

.table-fixed thead th {
    position: sticky;
    top: 0;
    background-color: var(--bg-card);
    z-index: 1;
}

.scrollable-table-wrapper {
    max-height: calc(100vh - 250px);
    overflow-y: auto;
}

.toggle-visibility {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    font-size: 1.2rem;
    color: var(--icon-color);
    cursor: pointer;
    z-index: 2;
}

    .toggle-visibility:hover {
        color: var(--text-black);
    }

.scrollable-table thead th {
    position: sticky;
    top: 0;
    background-color: var(--bg-card);
    z-index: 1;
}

#friendRequestBadge {
    font-size: 0.75rem;
    padding: 0.35em 0.5em;
}

#friendRequestsList .dropdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#friendRequestsList .btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

.typing-indicator {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: var(--typing-dots);
    margin-top: 5px;
    padding: 2px 2px;
}

    .typing-indicator .dots {
        display: flex;
        margin-left: 5px;
    }

        .typing-indicator .dots span {
            width: 6px;
            height: 6px;
            margin: 0 2px;
            background: var(--typing-dots);
            border-radius: 50%;
            display: inline-block;
            opacity: 0.4;
            animation: blink 1.4s infinite;
        }

            .typing-indicator .dots span:nth-child(1) {
                animation-delay: 0s;
            }

            .typing-indicator .dots span:nth-child(2) {
                animation-delay: 0.2s;
            }

            .typing-indicator .dots span:nth-child(3) {
                animation-delay: 0.4s;
            }

@keyframes blink {
    0% {
        opacity: 0.2;
    }

    20% {
        opacity: 1;
    }

    100% {
        opacity: 0.2;
    }
}

.replied-preview {
    border-left: 3px solid var(--bly-primary);
    background: var(--chat-replied-bg);
    padding: 4px 8px;
    margin-bottom: 6px;
    border-radius: 4px;
    font-size: 0.85em;
}

.replied-header {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    color: var(--whatsapp-green);
    margin-bottom: 2px;
}

.replied-sender {
    font-size: 0.85em;
    color: var(--bly-primary)
}

.replied-time {
    font-size: 0.7em;
    color: var(--text-secondary);
}

.replied-text {
    font-size: 0.85em;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-box {
    border-left: 4px solid var(--bootstrap-blue);
    background-color: var(--bg-hover);
    padding: 8px 12px;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-sm);
}

.edit-box {
    border-left: 4px solid var(--bootstrap-blue);
    background-color: var(--bg-hover);
    padding: 8px 12px;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-sm);
}

.drag-over {
    border: 2px dashed var(--drag-border) !important;
    background-color: var(--bg-hover);
}

#workScheduleForm table tr td,
#workScheduleForm table tr th {
    padding: 0.25rem; /* riduce padding verticale e orizzontale */
    height: 30px; /* altezza fissa righe */
    vertical-align: middle;
}

#workScheduleForm table input.form-control {
    height: 28px; /* riduce altezza input */
    padding: 0 0.25rem;
}

#workScheduleForm table input.form-check-input {
    margin-top: 0; /* riduce spazio sopra checkbox */
}


body {
    /* margin-bottom: 80px;*/
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-body);
    color: var(--text-primary);
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding-bottom: 60px; /* o più, uguale all'altezza del footer */
}

.footer {
    position: fixed;
    bottom: 0;
    width: 100%;
    white-space: nowrap;
    line-height: 60px; /* se vuoi rimpicciolire */
    height: 60px;
    background-color: var(--bg-footer);
    color: var(--text-white);
    padding: 0 1rem;
    z-index: 1000;
}

.bly-footer {
    background-color: var(--bly-primary);
    color: var(--text-white);
}

.navbar {
    background-color: var(--bg-navbar) !important;
    box-shadow: var(--shadow-md);
}

.navbar-brand, .navbar-nav .nav-link {
    color: var(--text-white) !important;
}

.btn-bly {
    background-color: var(--bly-primary);
    color: var(--text-white);
}

    .btn-bly:hover {
        background-color: var(--bly-primary-dark);
        color: var(--text-white);
    }

.text-primary {
    color: var(--bly-primary) !important;
}

.scrollable-modal-body {
    max-height: 400px;
    overflow-y: auto;
}

/* Chat related styles */
.container-fluid {
    height: 100vh;
    /* min-height: 600px;*/
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Evita lo scroll orizzontale */
}

.row.h-100 {
    height: 100%;
    flex: 1;
    overflow: hidden; /* Prevent row from causing overflow */
    display: flex; /* Assicura che la riga usi flexbox */
}

.sidebar {
    border-right: 1px solid var(--border-color);
    height: 100%;
    overflow-y: auto;
}

.chat-area {
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.sidebar {
    opacity: 1;
    transition: opacity 0.3s ease;
}

    .sidebar .card {
        position: relative;
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    .sidebar .card-header {
        position: sticky;
        top: 0;
        z-index: 10;
        background-color: var(--bly-primary); /* garantisce che non diventi trasparente */
        color: var(--text-white);
    }

    .sidebar .card-body {
        overflow-y: auto;
        flex: 1;
    }

    .sidebar .card, .chat-area .card {
        border-radius: 0;
        border: none;
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    .sidebar .list-group-item {
        border-left: none;
        border-right: none;
        cursor: pointer;
    }

        .sidebar .list-group-item:first-child {
            border-top: none;
        }

        .sidebar .list-group-item:hover {
            background-color: var(--bg-hover);
        }

        .sidebar .list-group-item.active {
            background-color: var(--bg-active);
            color: var(--text-heading);
            border-color: var(--border-color-light);
        }

.card-body.messages-container {
    flex: 1;
    overflow: hidden;
    padding: 0;
    position: relative;
    display: flex;
    flex-direction: column;
}

#messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    /* height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;*/
}

.message {
    margin-bottom: 1rem;
    display: flex;
}

.message-own {
    justify-content: flex-end;
}

.message-content {
    max-width: 70%;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    position: relative;
}

.message-other .message-content {
    background-color: var(--chat-receive-bg);
}

.message-own .message-content {
    background-color: var(--chat-sent-bg);
}

.message-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}

.message-sender {
    font-weight: bold;
}

.message-time {
    color: var(--text-secondary);
}

.chat-area .card {
    display: flex;
    flex-direction: column;
}

.chat-area .card-header {
    flex-shrink: 0;
}

.chat-area .card-body {
    flex: 1;
    overflow: hidden;
}

.chat-area .card-footer {
    flex-shrink: 0;
    background-color: var(--bg-card);
    border-top: 1px solid var(--border-color);
    position: sticky;
    bottom: 0;
    z-index: 100;
}

.card-footer {
    padding: 0px !important;
}


.message-form {
    width: 100%;
    padding: 10px;
}

    .message-form .form-control {
        border-radius: 1.5rem 0 0 1.5rem;
    }

    .message-form .btn {
        border-radius: 0 1.5rem 1.5rem 0;
    }

/* Attachment styles */
.message-attachments {
    margin-top: 0.5rem;
    border-top: 1px solid var(--overlay-medium);
    padding-top: 0.5rem;
}

.attachment-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    background-color: var(--bg-attachment);
    padding: 0.5rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-sm);
}

.attachment-preview {
    max-width: 200px;
    max-height: 150px;
    object-fit: contain;
    margin-right: 0.5rem;
    border-radius: 0.25rem;
}

.attachment-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: 0.5rem;
}

.attachment-name {
    font-weight: bold;
    font-size: 0.9rem;
    word-break: break-all;
}

.attachment-size {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.attachment-link {
    display: flex;
    align-items: center;
    color: inherit;
    text-decoration: none;
}

    .attachment-link:hover {
        text-decoration: none;
        color: var(--link-blue);
    }

/* File upload preview */
#attachment-preview {
    margin: 0.5rem 0;
    padding: 0.5rem;
    border: 1px solid var(--border-color-light);
    border-radius: 0.5rem;
    background-color: var(--bg-hover);
}

.file-info {
    display: flex;
    align-items: center;
}

.attachment-thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 0.25rem;
    margin-right: 0.5rem;
}

.ml-2 {
    margin-left: 0.5rem;
}

.ml-auto {
    margin-left: auto;
}

/* Call related styles */
.call-buttons {
    display: flex;
    margin-right: 0.5rem;
}

.call-btn {
    margin-left: 0.5rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-white);
    cursor: pointer;
    transition: all 0.2s ease;
}

    .call-btn:hover {
        transform: scale(1.1);
    }

.call-btn-audio {
    background-color: var(--call-audio);
}

.call-btn-video {
    background-color: var(--call-video);
}

.call-btn-end {
    background-color: var(--call-end);
}

/* Call screen styles */
.call-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--call-bg-screen);
    z-index: 2000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

    .call-screen.active {
        display: flex;
    }

.call-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1rem;
    color: var(--text-white);
    text-align: center;
    z-index: 2010;
}

.call-status {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.call-peer-name {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.call-timer {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
}

.call-videos {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    padding: 4rem 1rem 7rem 1rem;
}

.video-container {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    margin: 0.5rem;
    background-color: var(--text-gray);
}

    .video-container.remote {
        flex: 1;
        min-width: 320px;
        max-width: 800px;
        height: 60vh;
    }

    .video-container.local {
        position: absolute;
        bottom: 1rem;
        right: 1rem;
        width: 240px;
        height: 180px;
        z-index: 2010;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    }

video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background-color: var(--video-bg);
}

.video-name-tag {
    position: absolute;
    bottom: 0.5rem;
    left: 0.5rem;
    background-color: var(--overlay-bg);
    color: var(--text-white);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.call-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 1rem;
    display: flex;
    justify-content: center;
    background-color: var(--overlay-bg);
    z-index: 2010;
}

.call-control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin: 0 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background-color: var(--call-control-bg);
    color: var(--text-white);
    transition: all 0.2s ease;
}

    .call-control-btn:hover {
        background-color: var(--call-control-hover);
    }

    .call-control-btn.muted, .call-control-btn.video-off {
        background-color: var(--call-end);
    }

    .call-control-btn.end-call {
        background-color: var(--call-end);
    }

        .call-control-btn.end-call:hover {
            background-color: var(--bly-danger);
        }

/* Incoming call dialog */
.incoming-call {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--bg-card);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow-xl);
    z-index: 3000;
    width: 350px;
    display: none;
    text-align: center;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.4);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(33, 150, 243, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(33, 150, 243, 0);
    }
}

.incoming-call.active {
    display: block;
}

.incoming-call-header {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.incoming-call-name {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.incoming-call-type {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.incoming-call-buttons {
    display: flex;
    justify-content: space-around;
}

.incoming-call-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-white);
    cursor: pointer;
    font-size: 1.5rem;
}

    .incoming-call-btn.answer {
        background-color: var(--call-audio);
    }

    .incoming-call-btn.decline {
        background-color: var(--call-end);
    }

/* Group call styles */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    grid-auto-rows: 240px;
    gap: 10px;
    width: 100%;
    height: 100%;
    padding: 6rem 1rem 7rem 1rem;
}

    .video-grid.participants-1 .video-container {
        grid-column: span 1;
    }

    .video-grid.participants-2 .video-container {
        grid-column: span 1;
    }

    .video-grid.participants-3 .video-container,
    .video-grid.participants-4 .video-container {
        grid-column: span 1;
    }

    .video-grid.participants-5 .video-container,
    .video-grid.participants-6 .video-container {
        grid-column: span 1;
    }

/* Responsive adjustments */
/* Badge for unread messages */
.unread-badge {
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .unread-badge .badge {
        font-size: 0.7rem;
        padding: 0.25em 0.5em;
        min-width: 1.5em;
        text-align: center;
    }

#total-unread-badge {
    margin-left: 5px;
}

/* Pinned chats styles */
.sidebar-heading {
    font-size: 0.8rem;
    letter-spacing: 0.05rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: bold;
}

.pinned-contacts-list {
    border-bottom: 1px solid var(--overlay-medium);
    padding-bottom: 0.5rem;
}

.contact-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--avatar-bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-icon {
    color: var(--icon-color);
}

.contact-actions {
    display: flex;
    align-items: center;
}

.btn-icon {
    border: none;
    background: transparent;
    padding: 0.25rem;
    border-radius: 50%;
    color: var(--icon-color);
    transition: all 0.2s;
}

    .btn-icon:hover {
        background-color: var(--overlay-light);
        color: var(--icon-hover);
    }

.pin-icon.pin-active {
    color: var(--pin-active) !important;
    stroke: var(--pin-active) !important;
    fill: var(--pin-active) !important;
}

    /* Per sicurezza colora anche il poligono dentro SVG */
    .pin-icon.pin-active polygon {
        fill: var(--pin-active) !important;
    }

.volume-control-container {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: 10px;
}

.volume-slider {
    width: 100px;
}
/* Submenu positioning */
.dropdown-submenu .submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    margin-top: -0.25rem;
    margin-left: 0.1rem;
    z-index: 1000;
}

.dropdown-submenu:hover .submenu {
    display: block;
}

.flag-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-hover);
    font-size: 16px;
    box-shadow: var(--shadow-sm);
}

.flag-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: var(--shadow-sm);
}

.message-status {
    font-size: 0.8em;
    text-align: right;
    color: var(--text-secondary);
    margin-top: 4px;
}

.status-icon.read {
    color: var(--status-read);
}

.status-icon.delivered {
    color: var(--status-delivered);
}

.status-icon.sent {
    color: var(--status-sent);
}

.navbar .container {
    display: flex;
    flex-wrap: nowrap; /* evita che vada a capo */
    align-items: center;
    /*overflow-x: auto;*/
    z-index: 1055;
}

#userDropdown + .dropdown-menu,
#friendRequestsDropdown + .dropdown-menu {
    min-width: 150px; /* o quello che ti serve */
    max-width: 200px;
}

.navbar .navbar-nav {
    flex-wrap: nowrap; /* evita che le voci del nav si vadano a capo */
}

.navbar .dropdown-menu {
    white-space: nowrap; /* evita line-break all’interno del menu */
    position: absolute !important;
    top: 100%;
    left: auto;
    /*right: 0;  per dropdown a destra*/
}

#userMenu {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    margin-left: auto; /* spinge tutto a destra */
}

    #userMenu ul.navbar-nav {
        display: flex;
        flex-direction: row; /* forza in orizzontale */
        flex-wrap: nowrap;
    }

        #userMenu ul.navbar-nav li {
            white-space: nowrap; /* evita che testo o badge vadano a capo */
        }

.navbar-bly .container {
    flex-wrap: nowrap;
}

/* ===== Icona stato connessione ===== */
.connection-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: rgba(255,255,255,0.15);
    color: var(--icon-color);
    font-size: 1.2rem;
    transition: color 0.3s ease, opacity 0.3s ease;
}

    .connection-icon.connected i {
        color: var(--text-white);
    }

    .connection-icon.disconnected i {
        color: var(--bly-danger);
    }

    .connection-icon.connecting i {
        color: var(--bly-warning);
        opacity: 0.6;
        animation: pulse 1s infinite;
    }

/* effetto respiro durante la riconnessione */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* Divisore data chat */
.date-divider {
    position: relative;
    text-align: center;
    margin: 15px 0 10px 0;
}

    .date-divider small {
        display: inline-block;
        background-color: var(--bg-active);
        color: var(--text-primary);
        font-weight: 500;
        font-size: 0.85rem;
        padding: 4px 12px;
        border-radius: 15px;
        box-shadow: var(--shadow-sm);
    }

.message-footer {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.message-sender {
    color: var(--text-heading);
}

.message-header {
    margin-bottom: 3px;
}


/* Add mobile specific styles */
@media screen and (orientation: landscape) and (max-width: 768px) {
    body::before {
        content: "Ruota il dispositivo in verticale per continuare";
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: var(--bg-overlay);
        color: var(--text-white);
        z-index: 9999;
        font-size: 1.2rem;
        display: flex;
        justify-content: center;
        align-items: center;
        text-align: center;
        padding: 1rem;
    }

    #app, .chat-container, .chat-area, .sidebar {
        display: none !important; /* Nascondi il contenuto in landscape */
    }
}

@media (max-width: 768px) {
    .date-divider small {
        font-size: 0.75rem;
        padding: 3px 8px;
        background-color: var(--bg-hover);
        color: var(--text-primary);
        border: 1px solid var(--overlay-light);
    }
    /* Nasconde il nome utente testuale nella barra superiore su dispositivi mobili */
    #userMenu .navbar-text,
    #userMenu .dropdown-toggle span {
        display: none !important;
    }
    /* Mantiene visibile solo il cerchio con l'iniziale */
    #userMenu .avatar-circle {
        margin-left: 0;
    }

    /* Riduce leggermente la bandiera per lasciare più spazio */
    .language-button {
        width: 37px !important;
        height: 37px !important;
        background-size: cover !important;
        background-position: center;
        vertical-align: middle;
        margin-top: -1px; /* corregge disallineamento ottico */
    }

    #chat-area .card-header {
        padding: 0 0.4rem !important;
    }

    #chat-area {
        height: 100vh;
    }

    .modal.show {
        display: block !important;
    }

    .modal-dialog {
        width: 90% !important;
        max-width: 500px !important;
        margin: 1rem auto !important;
    }

    .modal-content {
        width: 100% !important;
        min-height: 200px !important;
        display: block !important;
    }
    /* Sidebar scroll con spazio finale corretto */
    #chat-sidebar .card-body {
        overflow-y: auto;
        /* Altezza del footer o margine inferiore: 1rem + safe-area + eventuale altezza header */
        padding-bottom: calc(1rem +100px);
    }

    /* Input di ricerca sempre visibile */
    #chat-sidebar .input-group {
        position: sticky;
        top: 0;
        z-index: 10;
        background-color: var(--bg-card);
    }

    /* Lista contatti */
    .chat-list-container {
        max-height: none;
        overflow-y: auto;
        padding-bottom: calc(1rem + 100px);
    }


    #message-form {
        flex-shrink: 0;
        padding: 10px 10px;
        background-color: var(--bg-card);
    }

    /* Base styles for mobile view */
    .sidebar {
        height: 100vh; /* Full height in mobile view */
        overflow-y: auto;
        transition: all 0.3s ease; /* Smooth transition for sidebar */
    }

    #contacts-list {
        max-height: calc(100vh - 160px); /* Regola se navbar/header occupano meno */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Scroll fluido su iOS */
    }

    #regular-contacts-section {
        flex: 1 1 auto;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .container-fluid {
        height: auto;
        min-height: 100vh;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .chat-area {
        height: 100vh;
        min-height: auto;
        transition: all 0.3s ease; /* Smooth transition for chat area */
    }

    .full-width-page {
        width: 100vw;
        margin: 0;
        padding: 0;
    }

    .card-body.messages-container {
        height: calc(100% - 120px); /* Adjust for card header and footer with more space for the footer */
        padding-bottom: 60px; /* Add padding to ensure content doesn't get hidden behind fixed footer */
    }

    #messages {
        position: relative;
        height: 100vh;
        overflow-y: auto;
        padding-bottom: 10px;
    }

    /* Ensure card footer stays fixed at the bottom on mobile */
    .chat-area .card-footer {
        /*position: fixed;*/
        bottom: 0;
        left: 0;
        width: 100%;
        background-color: var(--bg-card);
        border-top: 1px solid var(--border-color);
        z-index: 100;
        padding-bottom: 0px; /* calc(1rem + env(safe-area-inset-bottom));*/
    }

    .chat-area .messages-container {
        padding-bottom: 0px; /* calc(1rem + 100px + env(safe-area-inset-bottom));*/
    }
    /* Improve list items spacing and readability */
    .list-group-item {
        padding: 0.5rem 0.75rem;
    }

    .attachment-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .attachment-preview {
        max-width: 100%;
        margin-bottom: 0.5rem;
    }

    .video-container.local {
        width: 120px;
        height: 90px;
    }

    .video-grid {
        grid-template-columns: 1fr;
        grid-auto-rows: 180px;
    }

    /* Reduce navbar height on mobile */
    .navbar {
        padding-top: 0.2rem !important;
        padding-bottom: 0.2rem !important;
        min-height: 42px !important;
        max-height: 42px !important;
    }

        /* Make the navbar brand smaller on mobile */
        .navbar .navbar-brand {
            font-size: 1.1rem;
        }

        /* Adjust dropdown menus on mobile */
        .navbar .dropdown-menu {
            position: absolute !important;
            top: 100%;
            left: auto;
            right: 0;
            per dropdown a destra
        }

    /* Mobile fullscreen chat view */
    body.chat-fullscreen .sidebar {
        display: none !important; /* Ensure it's definitely hidden */
    }

    body.chat-fullscreen .chat-area {
        display: flex !important; /* Ensure it's definitely displayed */
        height: calc(100vh - 42px); /* Use the updated navbar height */
        width: 100% !important; /* Make sure it takes full width */
    }

    /* Back button for mobile */
    #back-to-contacts {
        display: flex; /* lo rendiamo visibile quando rimuovi d-none */
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        border: none;
        background-color: var(--bly-primary);
        color: var(--text-white);
        font-size: 16px;
        transition: all 0.2s ease;
        flex-shrink: 0; /* evita che si rimpicciolisca */
    }

        #back-to-contacts:hover,
        #back-to-contacts:focus {
            background-color: var(--bly-primary-dark);
            transform: scale(1.05); /* Slight enlarge on hover */
        }

    .status-dot {
        display: inline-block;
        width: 12px; /* Modifica la larghezza */
        height: 12px; /* Modifica l'altezza */
        border-radius: 50%;
        margin-right: 8px;
        border: 1px solid transparent;
    }

        .status-dot.online {
            background-color: var(--status-online);
        }

        .status-dot.offline {
            background-color: var(--status-offline);
        }
}
/* ===== Azioni messaggio: posizionate ai lati ===== */
.message-content {
    position: relative;
}

/* Contenitore delle azioni */
.message-actions {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 6px;
    opacity: 0;
    pointer-events: none;
    z-index: 20;
    transition: opacity 0.25s ease-in-out; /* entrata immediata */
}

    /* Mostra su hover o se sei sopra le azioni */
    .message-content:hover .message-actions,
    .message-actions:hover {
        opacity: 1;
        pointer-events: auto;
        transition-delay: 0s; /* 👈 ritardo di scomparsa */
    }

/* Quando si toglie l'hover → ritardo solo in uscita */
.message-content:not(:hover) .message-actions {
    transition-delay: 1.2s; /* 👈 ritardo solo alla scomparsa */
}


/* Posizionamento */
.message-own .message-actions {
    left: -45px;
}

.message-other .message-actions {
    right: -45px;
}

/* Singolo pulsante */
.msg-action {
    background: var(--bg-card);
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-gray);
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    pointer-events: auto; /* ✅ necessario per ricevere click */
}

    /* Effetto hover */
    .msg-action:hover {
        background: var(--whatsapp-green);
        color: var(--text-white);
        transform: scale(1.1);
    }

    .msg-action i {
        font-size: 0.85rem;
    }

:root {
    --chat-sent-bg: #dfe9f7; /* grigio-azzurro chiaro */
    --chat-receive-bg: #f5f5f7; /* grigio chiarissimo neutro */
    --chat-text-color: #212325; /* quasi nero */
    --chat-action-hover: #4a72b8; /* blu tenue per hover/icona */
}

/* Messaggi propri (inviati) */
.message-own .message-content {
    background-color: var(--chat-sent-bg);
    color: var(--chat-text-color);
}

/* Messaggi ricevuti */
.message-other .message-content {
    background-color: var(--chat-receive-bg);
    color: var(--chat-text-color);
}

/* Icone e hover */
.msg-action {
    color: var(--chat-action-hover);
}

    .msg-action:hover {
        background: var(--chat-action-hover);
        color: var(--text-white);
    }
/* === Uniforma colore sidebar ai messaggi inviati === */
.sidebar {
    background-color: var(--chat-sent-bg) !important;
}

    .sidebar .card {
        background-color: transparent !important;
        border: none !important;
    }

    .sidebar .list-group-item {
        background-color: transparent !important;
    }

        .sidebar .list-group-item.active {
            background-color: var(--bg-card) !important;
            border-color: var(--bly-primary-dark) !important;
            border-top: 1px solid var(--border-color-dark);
        }

 .modal-content {
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

 .modal-header {
    border-bottom: none;
    background-color: var(--bly-primary-dark);
    color: var(--text-white);
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

/* Contenitore perfettamente quadrato per l'avatar */
 .avatar-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto;
}

/* L'immagine resta sempre tonda */
 .profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--bly-primary-dark);
    background-color: var(--bg-hover);
    box-shadow: var(--shadow-sm);
    display: block;
}

/* Pulsante fotocamera preciso in basso a destra */
 .change-avatar-btn {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color-dark);
    color: var(--bly-primary-dark);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

     .change-avatar-btn:hover {
        background-color: var(--bly-primary-dark);
        color: var(--text-white);
    }

 .form-label {
    color: var(--text-primary);
}

 .btn-primary {
    background-color: var(--bly-primary-dark);
    border: none;
}

     .btn-primary:hover {
        background-color: var(--bly-primary);
    }

.avatar-circle,
.navbar-nav img.rounded-circle {
    transition: transform 0.2s ease;
}

    .avatar-circle:hover,
    .navbar-nav img.rounded-circle:hover {
        transform: scale(1.1);
    }
/* 🔹 Reset avatar su tutte le dimensioni */
.contact-avatar {
    background: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

    /* 🔹 Immagine rotonda perfetta */
    .contact-avatar img.avatar-img {
        display: block;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        object-fit: cover;
        background-color: transparent !important;
        border: none !important;
        box-shadow: none !important;
    }

/* 🔹 Evita che i contenitori Bootstrap aggiungano padding sul mobile */
.list-group-item.contact-item {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
}

/* 🔹 Ottimizza la dimensione su schermi piccoli */
@media (max-width: 768px) {
    .contact-avatar img.avatar-img {
        width: 32px;
        height: 32px;
    }

    .contact-avatar {
        margin-right: 0.4rem !important;
        padding: 0 !important;
        background: transparent !important;
    }

        /* Evita sfondi o cerchi automatici di Bootstrap */
        .contact-avatar::before,
        .contact-avatar::after {
            display: none !important;
            content: none !important;
        }
}

.message-text {
    white-space: pre-wrap; /* conserva i ritorni a capo */
    word-wrap: break-word;
}

#reply-text {
    white-space: pre-wrap;
}

.pinned-dropdown {
    position: relative;
}

/* Contenitore principale */
.pinned-menu {
    position: absolute;
    top: 100%;
    right: 0;
    width: 350px;
    background: var(--bg-card);
    border-radius: 10px;
    box-shadow: var(--shadow-xl);
    z-index: 999;
    overflow: hidden;
    animation: fadeIn 0.15s ease-out;
}

/* Animazione */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pinned-header {
    background: var(--bly-primary);
    color: var(--text-white);
    font-weight: bold;
    padding: 10px 15px;
}

.pinned-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 300px;
    overflow-y: auto;
}

    .pinned-list li {
        padding: 10px 15px;
        border-bottom: 1px solid var(--border-color);
        cursor: pointer;
    }

        .pinned-list li:hover {
            background: var(--bg-hover);
        }

.pinned-empty {
    text-align: center;
    padding: 15px;
    color: var(--text-light);
}

.pin-icon-btn {
    border: none;
    background: transparent;
    color: var(--icon-color);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.highlight-message {
    background-color: var(--bly-warning);
    opacity: 0.4;
    transition: background-color 0.8s ease;
}

    .highlight-message.fade-out {
        background-color: transparent;
    }


.table-responsive td {
    color: var(--text-light);
}

.scrollable-table-wrapper td {
    color: var(--text-light);
}
input, textarea {
    background-color: var(--bg-textarea) !important;
    color: var(--text-light) !important;
    border-color: var(--bly-primary)!important;
}

#emoji-button, #attach-button{
    border-color: var(--bly-primary) !important;
}
