/* =====================
   Messaging / Chat Styles
   ===================== */

/* ---- Chat Bubbles (shared) ---- */
.chat-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 0.88rem;
    line-height: 1.45;
    word-wrap: break-word;
    position: relative;
}

.chat-bubble .chat-sender {
    font-size: 0.72rem;
    font-weight: 700;
    margin-bottom: 3px;
    opacity: 0.8;
}

.chat-bubble .chat-time {
    font-size: 0.68rem;
    opacity: 0.6;
    margin-top: 3px;
    text-align: right;
}

.chat-bubble.sent {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--warm-orange), var(--soft-coral));
    color: white;
    border-bottom-right-radius: 6px;
}

.chat-bubble.sent .chat-sender {
    color: rgba(255, 255, 255, 0.85);
}

.chat-bubble.sent .chat-time {
    color: rgba(255, 255, 255, 0.7);
}

.chat-bubble.received {
    align-self: flex-start;
    background: white;
    color: var(--deep-ocean);
    border: 1px solid #eee;
    border-bottom-left-radius: 6px;
}

.chat-bubble.received .chat-sender {
    color: var(--tropical-teal);
}

.chat-bubble.received .chat-time {
    color: #aaa;
}

.chat-empty {
    text-align: center;
    padding: 40px 20px;
    color: #aaa;
    font-size: 0.9rem;
}

/* =====================
   Floating Chat Widget (Parent Dashboard)
   ===================== */

.chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Nunito', sans-serif;
}

/* The floating bubble button */
.chat-widget-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--warm-orange), #FF6B35);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 24px rgba(255, 140, 66, 0.45);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.chat-widget-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 30px rgba(255, 140, 66, 0.55);
}

.chat-widget-bubble.open {
    background: linear-gradient(135deg, #555, #333);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.chat-widget-icon,
.chat-widget-close-icon {
    width: 26px;
    height: 26px;
}

/* Unread badge on bubble */
.chat-widget-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: var(--soft-coral);
    color: white;
    font-size: 0.72rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Chat panel */
.chat-widget-panel {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 370px;
    max-height: 520px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes chatSlideUp {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Panel header */
.chat-widget-header {
    background: linear-gradient(135deg, var(--warm-orange), #FF6B35);
    color: white;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-widget-header-title {
    font-family: 'Baloo 2', cursive;
    font-size: 1.15rem;
    font-weight: 700;
}

.chat-widget-header-subtitle {
    font-size: 0.75rem;
    opacity: 0.85;
    margin-top: 1px;
}

.chat-widget-header-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chat-widget-header-close:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* Messages area */
.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 200px;
    max-height: 340px;
    background: #fafafa;
}

.chat-widget-messages::-webkit-scrollbar {
    width: 5px;
}

.chat-widget-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-widget-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

/* Input area */
.chat-widget-input {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #f0f0f0;
    background: white;
    align-items: flex-end;
    flex-shrink: 0;
}

.chat-widget-input textarea {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #eee;
    border-radius: 12px;
    font-family: 'Nunito', sans-serif;
    font-size: 0.88rem;
    resize: none;
    outline: none;
    min-height: 40px;
    max-height: 80px;
    transition: border-color 0.2s;
    color: var(--deep-ocean);
}

.chat-widget-input textarea:focus {
    border-color: var(--warm-orange);
}

.chat-widget-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--warm-orange), #FF6B35);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.chat-widget-send:hover {
    transform: scale(1.08);
    box-shadow: 0 3px 12px rgba(255, 140, 66, 0.4);
}

/* New message notification toast */
.chat-widget-toast {
    position: absolute;
    bottom: 72px;
    right: 0;
    background: white;
    border-radius: 14px;
    padding: 14px 18px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
    max-width: 300px;
    cursor: pointer;
    animation: chatSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 4px solid var(--warm-orange);
}

.chat-widget-toast-sender {
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--warm-orange);
    margin-bottom: 2px;
}

.chat-widget-toast-text {
    font-size: 0.82rem;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =====================
   Admin Chat Layout
   ===================== */

.admin-messages-layout {
    display: flex;
    gap: 0;
    min-height: 500px;
    border-radius: 16px;
    overflow: hidden;
    background: white;
}

.admin-chat-sidebar {
    width: 300px;
    flex-shrink: 0;
    border-right: 1px solid #eee;
    overflow-y: auto;
    background: #fafafa;
}

.admin-chat-sidebar-header {
    padding: 16px;
    font-family: 'Baloo 2', cursive;
    font-size: 1.1rem;
    color: var(--deep-ocean);
    border-bottom: 1px solid #eee;
    background: white;
    position: sticky;
    top: 0;
}

.admin-chat-item {
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
}

.admin-chat-item:hover {
    background: #f5f5f5;
}

.admin-chat-item.active {
    background: rgba(255, 140, 66, 0.08);
    border-left: 3px solid var(--warm-orange);
}

.admin-chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.admin-chat-item-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--deep-ocean);
}

.admin-chat-item-time {
    font-size: 0.7rem;
    color: #aaa;
}

.admin-chat-item-preview {
    font-size: 0.8rem;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.admin-chat-main-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    font-weight: 700;
    color: var(--deep-ocean);
    background: white;
}

.admin-chat-main .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fafafa;
    min-height: 300px;
}

.admin-chat-main .chat-input-area {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #eee;
    align-items: flex-end;
}

.admin-chat-main .chat-input-area textarea {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #eee;
    border-radius: 14px;
    font-family: 'Nunito', sans-serif;
    font-size: 0.9rem;
    resize: none;
    outline: none;
    min-height: 44px;
    max-height: 100px;
    transition: border-color 0.3s;
}

.admin-chat-main .chat-input-area textarea:focus {
    border-color: var(--warm-orange);
}

.chat-send-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--warm-orange), var(--soft-coral));
    color: white;
    border: none;
    border-radius: 14px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.chat-send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(255, 140, 66, 0.4);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.admin-chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
    font-size: 0.95rem;
}

.admin-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--soft-coral);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
}

/* =====================
   Responsive
   ===================== */

@media (max-width: 768px) {
    .admin-messages-layout {
        flex-direction: column;
    }

    .admin-chat-sidebar {
        width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid #eee;
    }

    .chat-bubble {
        max-width: 88%;
    }
}

@media (max-width: 480px) {
    .chat-widget {
        bottom: 16px;
        right: 16px;
    }

    .chat-widget-bubble {
        width: 54px;
        height: 54px;
    }

    .chat-widget-icon,
    .chat-widget-close-icon {
        width: 22px;
        height: 22px;
    }

    .chat-widget-panel {
        width: calc(100vw - 32px);
        right: -8px;
        bottom: 66px;
        max-height: 70vh;
    }
}
