/* Chatbox Styles */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: inherit;
}

.chat-toggle-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background-color 0.2s;
    position: relative;
}

.chat-toggle-btn:hover {
    transform: scale(1.05);
    background-color: var(--primary-dark);
}

.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #d32f2f;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.75rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.2s, transform 0.2s;
}

.chat-badge.visible {
    opacity: 1;
    transform: scale(1);
}

.chat-toggle-icon {
    width: 30px;
    height: 30px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    min-width: 260px;
    min-height: 320px;
    max-width: 90vw;
    max-height: 90vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transition: transform 0.3s cubic-bezier(0.19, 1, 0.22, 1), opacity 0.3s ease;
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.chat-window.open {
    opacity: 1;
    transform: scale(1);
    pointer-events: all;
}

.chat-banner {
    display: none;
    background: #fee2e2;
    color: #991b1b;
    padding: 10px 14px;
    font-weight: 700;
    border-bottom: 1px solid #fecaca;
}

.chat-resize-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    right: 4px;
    bottom: 4px;
    cursor: se-resize;
    background: linear-gradient(135deg, transparent 0, transparent 50%, rgba(0,0,0,0.15) 50%, rgba(0,0,0,0.3) 100%);
    border-radius: 3px;
}

.chat-layout {
    display: flex;
    flex: 1;
    min-height: 0;
}

.chat-threads {
    width: 35%;
    max-width: 180px;
    border-right: 1px solid #eee;
    background-color: #fafafa;
    overflow-y: auto;
}

.chat-conversation {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header {
    background-color: var(--primary-color);
    color: white;
    padding: 16px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.8;
}

.chat-close-btn:hover {
    opacity: 1;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background-color: #f5f5f5;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-user-row {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-user-row:hover {
    background-color: #e3f2fd;
}

.chat-user-row.has-new {
    background-color: #fff7ed;
    border-left: 4px solid #f97316;
    font-weight: 700;
}

.chat-user-row.has-new:hover {
    background-color: #ffedd5;
}

.chat-user-row.active {
    background-color: #bbdefb;
    font-weight: 600;
}

.chat-thread-new {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 6px;
    font-size: 0.7rem;
    border-radius: 999px;
    background-color: #d32f2f;
    color: #fff;
    font-weight: 600;
}

.chat-message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 0.95rem;
    position: relative;
    word-wrap: break-word;
    white-space: pre-wrap; /* Preserve newlines and spaces */
}

.chat-message.me {
    align-self: flex-end;
    background-color: #f9f9f9;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-right-radius: 4px;
}

.chat-message.other {
    align-self: flex-start;
    background-color: var(--primary-color);
    color: #fff;
    border-bottom-left-radius: 4px;
}

.message-meta {
    font-size: 0.75rem;
    margin-bottom: 4px;
    opacity: 0.8;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.role-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background-color: rgba(0,0,0,0.1);
    font-weight: 600;
}

.message-user-info {
    font-size: 0.7rem;
    margin-bottom: 4px;
    opacity: 0.9;
    font-weight: 500;
    padding: 2px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.chat-input-area {
    padding: 12px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
}

.chat-upload-btn {
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-weight: 800;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-upload-btn svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 0.95rem;
    outline: none;
}

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

.chat-send-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.chat-send-btn:hover {
    background-color: var(--primary-dark);
}

.chat-send-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chat-message img.chat-img {
    max-width: 220px;
    border-radius: 10px;
    cursor: pointer;
}

.chat-viewer {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.chat-viewer img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.avail-cal {
    background: #fff;
    color: #111827;
    border-radius: 12px;
    padding: 10px 10px 12px;
    border: 1px solid rgba(0,0,0,0.08);
}

.avail-cal-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.avail-cal-subtitle {
    font-size: 0.8rem;
    color: #6b7280;
    margin-bottom: 10px;
}

.avail-cal-month {
    margin-top: 10px;
}

.avail-cal-month-title {
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 6px;
}

.avail-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.avail-cal-dow {
    font-size: 0.7rem;
    color: #6b7280;
    text-align: center;
    font-weight: 600;
}

.avail-cal-empty {
    height: 28px;
}

.avail-cal-day {
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    user-select: none;
    border: 1px solid rgba(0,0,0,0.08);
}

.avail-cal-day.available {
    background: #22c55e;
    border-color: rgba(0,0,0,0.05);
    color: #fff;
}

.avail-cal-day.booked {
    background: #ef4444;
    border-color: rgba(0,0,0,0.05);
    color: #fff;
}

.avail-cal-day.out {
    background: #f3f4f6;
    color: #9ca3af;
}

.avail-cal-legend {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    align-items: center;
    font-size: 0.8rem;
    color: #374151;
    flex-wrap: wrap;
}

.avail-cal-legend-item {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.avail-cal-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
    border: 1px solid rgba(0,0,0,0.08);
}

.avail-cal-swatch.available {
    background: #22c55e;
}

.avail-cal-swatch.booked {
    background: #ef4444;
}

@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 40px);
        bottom: 90px;
        right: 20px;
        height: 60vh;
    }
    .chat-threads {
        display: none;
    }
    .chat-layout {
        display: block;
    }
}
