/* ===============================================
   VREYA - CSS CHAT PROFESSIONISTA
   Layout full-width per sistema messaggistica - Estende dashboard-cliente.css
   =============================================== */

/* IMPORTANTE: Layout ottimizzato per chat a 3 colonne
   Sidebar chat + Area messaggi + Pannello info */

/* ===============================================
   CHAT CONTAINER - LAYOUT PRINCIPALE
   =============================================== */
.chat-container {
    display: grid;
    grid-template-columns: 320px 1fr 300px;
    height: calc(100vh - 200px);
    gap: 0;
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ===============================================
   CHAT SIDEBAR - LISTA CONVERSAZIONI
   =============================================== */
.chat-sidebar {
    background: var(--color-gray-light);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--color-border);
    background: white;
}

.sidebar-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.sidebar-title h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
    line-height: 1.25;
    letter-spacing: -0.015em;
}

.chat-count {
    font-size: 12px;
    color: var(--color-secondary);
    background: rgba(45, 90, 61, 0.1);
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.sidebar-search {
    position: relative;
}

.chat-search-input {
    width: 100%;
    resize: none;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid var(--color-light);
    background-color: var(--color-background);
    color: var(--color-text);
    padding: 0 16px;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.4;
    height: 40px;
    outline: none;
    transition: border-color 0.3s ease;
}

.chat-search-input:focus {
    border-color: var(--color-primary);
}

.chat-search-input::placeholder {
    color: var(--color-secondary);
}

/* ===============================================
   CHAT LIST - CONVERSAZIONI
   =============================================== */
.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.chat-item {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.chat-item:hover {
    background: var(--color-gray-light);
}

.chat-item.active {
    background: rgba(45, 90, 61, 0.05);
    border-left: 4px solid var(--color-primary);
}

.chat-avatar {
    position: relative;
    flex-shrink: 0;
}

.chat-avatar img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--color-border);
}

.status-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
}

.status-indicator.online {
    background: #10b981;
}

.status-indicator.offline {
    background: var(--color-secondary);
}

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

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.client-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time {
    font-size: 12px;
    color: var(--color-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.chat-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.last-message {
    font-size: 13px;
    color: var(--color-secondary);
    margin: 0;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    margin-right: 8px;
}

.unread-badge {
    background: var(--color-red);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.chat-service {
    margin-top: 4px;
}

.service-tag {
    font-size: 11px;
    color: var(--color-primary);
    background: rgba(45, 90, 61, 0.1);
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 600;
    display: inline-block;
}

/* ===============================================
   QUICK TEMPLATES - RISPOSTE RAPIDE
   =============================================== */
.quick-templates {
    padding: 16px 20px;
    border-top: 1px solid var(--color-border);
    background: white;
}

.quick-templates h5 {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 12px 0;
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.template-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.template-btn {
    background: var(--color-gray-light);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    font-weight: 500;
}

.template-btn:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* ===============================================
   CHAT MAIN - AREA CONVERSAZIONE
   =============================================== */
.chat-main {
    display: flex;
    flex-direction: column;
    background: white;
    border-right: 1px solid var(--color-border);
}

.chat-main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--color-border);
    background: white;
}

.client-info-header {
    display: flex;
    align-items: center;
    gap: 16px;
}

.client-avatar-large {
    position: relative;
    flex-shrink: 0;
}

.client-avatar-large img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--color-border);
}

.client-details h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 4px 0;
    line-height: 1.4;
}

.client-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.client-type {
    font-size: 13px;
    color: var(--color-primary);
    background: rgba(45, 90, 61, 0.1);
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.separator {
    color: var(--color-secondary);
    font-size: 12px;
}

.service-info {
    font-size: 13px;
    color: var(--color-secondary);
    font-weight: 500;
}

.client-status .status-text {
    font-size: 12px;
    color: #10b981;
    font-weight: 500;
}

.chat-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--color-gray-light);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* ===============================================
   CHAT MESSAGES - AREA MESSAGGI
   =============================================== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    background: #f8fafc;
}

.messages-container {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
}

.message.system-message {
    align-self: center;
    max-width: 60%;
    margin: 8px 0;
}

.message.client-message {
    align-self: flex-start;
}

.message.professional-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    flex-shrink: 0;
}

.message-avatar img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--color-border);
}

.message-content {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 12px 16px;
    position: relative;
}

.message.system-message .message-content {
    background: rgba(100, 116, 139, 0.1);
    border-color: rgba(100, 116, 139, 0.2);
    text-align: center;
    color: var(--color-secondary);
    font-size: 13px;
}

.message.professional-message .message-content {
    background: rgba(45, 90, 61, 0.05);
    border-color: rgba(45, 90, 61, 0.2);
}

.message-content p {
    font-size: 14px;
    color: var(--color-text);
    margin: 0 0 8px 0;
    line-height: 1.5;
    word-wrap: break-word;
}

.message-time {
    font-size: 11px;
    color: var(--color-secondary);
    font-weight: 500;
}

.message-status {
    font-size: 11px;
    color: var(--color-secondary);
    font-weight: 500;
    margin-left: 8px;
}

/* ===============================================
   TYPING INDICATOR
   =============================================== */
.typing-indicator {
    align-self: flex-start;
    opacity: 0.7;
}

.typing-content {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 12px 16px;
}

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

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--color-secondary);
    border-radius: 50%;
    animation: typing 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 typing {

    0%,
    60%,
    100% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    30% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===============================================
   CHAT INPUT AREA
   =============================================== */
.chat-input-area {
    padding: 20px;
    border-top: 1px solid var(--color-border);
    background: white;
}

.input-container {
    max-width: 100%;
}

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

#messageInput {
    flex: 1;
    resize: none;
    border-radius: 8px;
    border: 1px solid var(--color-light);
    background-color: var(--color-background);
    color: var(--color-text);
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.3s ease;
    min-height: 44px;
    max-height: 120px;
    font-family: "Plus Jakarta Sans", "Noto Sans", sans-serif;
}

#messageInput:focus {
    border-color: var(--color-primary);
}

#messageInput::placeholder {
    color: var(--color-secondary);
}

.input-actions {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.input-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--color-gray-light);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.input-action:hover {
    background: var(--color-light);
    color: white;
    border-color: var(--color-light);
}

.send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--color-primary);
    border: 1px solid var(--color-primary);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.send-btn:hover:not(:disabled) {
    background: var(--color-dark);
    border-color: var(--color-dark);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--color-secondary);
    border-color: var(--color-secondary);
}

.input-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.char-count {
    font-size: 12px;
    color: var(--color-secondary);
    font-weight: 500;
}

.input-note {
    font-size: 11px;
    color: var(--color-secondary);
    font-style: italic;
}

/* ===============================================
   CHAT INFO PANEL - DETTAGLI CLIENTE
   =============================================== */
.chat-info-panel {
    background: var(--color-gray-light);
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.info-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--color-border);
    background: white;
}

.info-panel-header h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
    line-height: 1.4;
}

.close-panel-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--color-gray-light);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.close-panel-btn:hover {
    background: var(--color-red);
    color: white;
    border-color: var(--color-red);
}

.info-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* ===============================================
   INFO SECTIONS
   =============================================== */
.info-section {
    padding: 20px;
    border-bottom: 1px solid var(--color-border);
    background: white;
}

.info-section:last-child {
    border-bottom: none;
}

.info-section h5 {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 16px 0;
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Client Card */
.client-card {
    display: flex;
    gap: 12px;
    align-items: center;
}

.client-avatar-info img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--color-border);
}

.client-info-details h6 {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 4px 0;
    line-height: 1.4;
}

.client-info-details p {
    font-size: 13px;
    color: var(--color-secondary);
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.client-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: white;
    font-weight: 500;
}

/* Booking Info Card */
.booking-info-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.booking-detail {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border);
}

.booking-detail:last-child {
    border-bottom: none;
}

.detail-label {
    font-size: 13px;
    color: var(--color-secondary);
    font-weight: 500;
}

.detail-value {
    font-size: 13px;
    color: var(--color-text);
    font-weight: 500;
    text-align: right;
}

.detail-value.status-paid {
    color: var(--color-primary);
    font-weight: 600;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    cursor: pointer;
    border-radius: 8px;
    height: 40px;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    border: none;
    transition: all 0.3s ease;
}

.action-button.primary {
    background-color: var(--color-primary);
    color: white;
}

.action-button.primary:hover {
    background-color: var(--color-dark);
}

.action-button.secondary {
    background-color: var(--color-light);
    color: white;
}

.action-button.secondary:hover {
    background-color: var(--color-primary);
}

/* History List */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    background: var(--color-gray-light);
    border: 1px solid var(--color-border);
    border-radius: 6px;
}

.history-service {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.4;
}

.history-date {
    font-size: 11px;
    color: var(--color-secondary);
    font-weight: 500;
}

.history-status {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-status.completed {
    color: var(--color-primary);
}

/* ===============================================
   RESPONSIVE DESIGN - CHAT LAYOUT
   =============================================== */
@media (max-width: 1200px) {
    .chat-container {
        grid-template-columns: 280px 1fr 280px;
    }
}

@media (max-width: 1024px) {
    .chat-container {
        grid-template-columns: 260px 1fr;
        height: calc(100vh - 180px);
    }

    .chat-info-panel {
        display: none;
    }
}

@media (max-width: 768px) {
    .chat-container {
        grid-template-columns: 1fr;
        height: calc(100vh - 160px);
    }

    .chat-sidebar {
        display: none;
    }

    .chat-main-header {
        padding: 16px;
    }

    .client-info-header {
        gap: 12px;
    }

    .client-avatar-large img {
        width: 44px;
        height: 44px;
    }

    .client-details h3 {
        font-size: 16px;
    }

    .chat-actions {
        gap: 6px;
    }

    .action-btn {
        width: 36px;
        height: 36px;
    }

    .messages-container {
        padding: 16px;
    }

    .chat-input-area {
        padding: 16px;
    }

    .input-wrapper {
        gap: 8px;
    }

    #messageInput {
        padding: 10px 14px;
        min-height: 40px;
    }

    .input-action,
    .send-btn {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    .chat-container {
        height: calc(100vh - 140px);
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .chat-main-header {
        padding: 12px;
        flex-wrap: wrap;
        gap: 12px;
    }

    .client-info-header {
        flex: 1;
        min-width: 200px;
    }

    .chat-actions {
        flex-shrink: 0;
    }

    .messages-container {
        padding: 12px;
        gap: 12px;
    }

    .message {
        max-width: 95%;
    }

    .message-content {
        padding: 10px 12px;
    }

    .message-content p {
        font-size: 13px;
    }

    .chat-input-area {
        padding: 12px;
    }

    .input-info {
        flex-direction: column;
        gap: 4px;
        align-items: flex-start;
    }

    .input-note {
        display: none;
    }
}

/* ===============================================
   MOBILE CHAT TOGGLES
   =============================================== */
@media (max-width: 1024px) {
    .mobile-chat-toggle {
        display: flex;
        gap: 8px;
        padding: 12px 20px;
        background: var(--color-gray-light);
        border-bottom: 1px solid var(--color-border);
    }

    .toggle-btn {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 8px 12px;
        background: white;
        border: 1px solid var(--color-border);
        border-radius: 6px;
        font-size: 13px;
        font-weight: 600;
        color: var(--color-text);
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .toggle-btn.active {
        background: var(--color-primary);
        color: white;
        border-color: var(--color-primary);
    }
}

/* ===============================================
   SCROLLBAR CUSTOMIZATION
   =============================================== */
.chat-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar,
.info-panel-content::-webkit-scrollbar {
    width: 6px;
}

.chat-list::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track,
.info-panel-content::-webkit-scrollbar-track {
    background: var(--color-gray-light);
}

.chat-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb,
.info-panel-content::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

.chat-list::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover,
.info-panel-content::-webkit-scrollbar-thumb:hover {
    background: var(--color-secondary);
}