/* ==========================================================
   Mini Project MUT — LINE-Style Team Chat CSS
   ========================================================== */

:root {
    --line-green: #06C755;
    --line-green-dark: #05B04C;
    --line-green-hover: #049B43;
    --line-bg-light: #7E96AE;
    --line-bg-dark: #141C24;
    --line-bubble-other-bg: #FFFFFF;
    --line-bubble-other-text: #1E293B;
    --line-bubble-me-bg: #06C755;
    --line-bubble-me-text: #FFFFFF;
    --line-bubble-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
    --line-date-bg: rgba(0, 0, 0, 0.22);
    --line-time-text: #8E9EA7;
}

[data-theme="dark"] {
    --line-bg-light: #121820;
    --line-bubble-other-bg: #222C38;
    --line-bubble-other-text: #F1F5F9;
    --line-bubble-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    --line-date-bg: rgba(0, 0, 0, 0.45);
    --line-time-text: #64748B;
}

/* Chat Layout Container */
.chat-wrapper {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    max-height: calc(100dvh - 110px);
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    overflow: hidden;
    border: 1px solid var(--border-color);
    position: relative;
}

/* Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.25rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.chat-header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #06C755, #05B04C);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(6, 199, 85, 0.3);
    flex-shrink: 0;
}

.chat-header-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-main);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--line-green);
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(6, 199, 85, 0.25);
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Messages Area (LINE Wallpaper Feel) */
.chat-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 1.25rem;
    background: var(--line-bg-light);
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.05) 0%, transparent 20%),
        radial-gradient(circle at 80% 80%, rgba(0, 0, 0, 0.05) 0%, transparent 20%);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
    position: relative;
}

[data-theme="dark"] .chat-body {
    background: var(--line-bg-dark);
}

/* Date Separator */
.chat-date-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0.75rem 0;
}

.chat-date-pill {
    background: var(--line-date-bg);
    color: #FFFFFF;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.85rem;
    border-radius: 50px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* Message Rows */
.chat-message-row {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
    max-width: 85%;
    position: relative;
}

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

.chat-message-row.other {
    align-self: flex-start;
    flex-direction: row;
}

/* Sender Avatar */
.chat-sender-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366F1, #8B5CF6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 600;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 2px;
}

/* Message Content Box */
.chat-message-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-message-row.me .chat-message-content {
    align-items: flex-end;
}

.chat-message-row.other .chat-message-content {
    align-items: flex-start;
}

/* Sender Meta (Name & Role) */
.chat-sender-meta {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.2rem;
    padding-left: 0.25rem;
}

.chat-sender-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .chat-sender-name {
    color: #CBD5E1;
}

.chat-sender-badge {
    font-size: 0.65rem;
    padding: 0.05rem 0.35rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.25);
    color: #FFFFFF;
    font-weight: 500;
}

.chat-sender-badge.admin {
    background: #EF4444;
    color: #FFFFFF;
}

/* Message Bubble & Meta container */
.chat-bubble-container {
    display: flex;
    align-items: flex-end;
    gap: 0.4rem;
}

.chat-message-row.me .chat-bubble-container {
    flex-direction: row;
}

.chat-message-row.other .chat-bubble-container {
    flex-direction: row-reverse;
}

/* Bubbles */
.chat-bubble {
    padding: 0.55rem 0.85rem;
    border-radius: 18px;
    word-break: break-word;
    font-size: 0.93rem;
    line-height: 1.45;
    position: relative;
    box-shadow: var(--line-bubble-shadow);
    max-width: 100%;
}

/* Others' Bubble */
.chat-message-row.other .chat-bubble {
    background: var(--line-bubble-other-bg);
    color: var(--line-bubble-other-text);
    border-top-left-radius: 4px;
}

/* My Bubble */
.chat-message-row.me .chat-bubble {
    background: var(--line-bubble-me-bg);
    color: var(--line-bubble-me-text);
    border-top-right-radius: 4px;
}

.chat-bubble a {
    color: inherit;
    text-decoration: underline;
    font-weight: 500;
}

.chat-message-row.other .chat-bubble a {
    color: var(--primary);
}

/* Bubble Meta (Timestamp & Status) */
.chat-bubble-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.75);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
    user-select: none;
}

[data-theme="dark"] .chat-bubble-meta {
    color: #64748B;
}

.chat-bubble-status {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    transition: all 0.15s ease;
}

.chat-bubble-status.is-read {
    color: #DCFCE7;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline dotted;
}

.chat-bubble-status.is-read:hover {
    color: #FFFFFF;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.6);
}

[data-theme="dark"] .chat-bubble-status.is-read {
    color: #4ADE80;
}

.online-dot.pulsing {
    box-shadow: 0 0 0 0 rgba(6, 199, 85, 0.7);
    animation: pulse-green 1.8s infinite;
}

@keyframes pulse-green {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(6, 199, 85, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(6, 199, 85, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(6, 199, 85, 0); }
}

.member-online-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    padding: 0.18rem 0.55rem;
    border-radius: 50px;
}

.member-online-badge.online {
    background: rgba(34, 197, 94, 0.15);
    color: #16A34A;
    font-weight: 600;
}

.member-online-badge.offline {
    background: rgba(100, 116, 139, 0.12);
    color: #64748B;
}

[data-theme="dark"] .member-online-badge.online {
    background: rgba(34, 197, 94, 0.25);
    color: #4ADE80;
}

[data-theme="dark"] .member-online-badge.offline {
    background: rgba(148, 163, 184, 0.15);
    color: #94A3B8;
}

/* Image Attachment */
.chat-attachment-image {
    max-width: 280px;
    max-height: 280px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    margin-top: 0.25rem;
    transition: transform 0.15s ease, opacity 0.15s ease;
    display: block;
}

.chat-attachment-image:hover {
    opacity: 0.92;
    transform: scale(1.01);
}

.chat-attachment-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* File Attachment Card */
.chat-attachment-file {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.05);
    margin-top: 0.35rem;
    text-decoration: none !important;
    color: inherit;
    border: 1px solid rgba(0, 0, 0, 0.08);
    transition: background 0.15s ease;
}

.chat-message-row.me .chat-attachment-file {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    color: #FFFFFF;
}

.chat-attachment-file:hover {
    background: rgba(0, 0, 0, 0.1);
}

.chat-message-row.me .chat-attachment-file:hover {
    background: rgba(255, 255, 255, 0.25);
}

.chat-file-icon {
    font-size: 1.6rem;
    line-height: 1;
}

.chat-file-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-file-name {
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.chat-file-size {
    font-size: 0.72rem;
    opacity: 0.8;
}

/* Delete Message Action */
.chat-delete-btn {
    opacity: 0;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 0.85rem;
    transition: opacity 0.15s ease, color 0.15s ease;
}

.chat-message-row:hover .chat-delete-btn {
    opacity: 1;
}

.chat-delete-btn:hover {
    color: #EF4444;
}

/* Bottom Quick Replies Bar */
.chat-quick-replies {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.85rem;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.chat-quick-replies::-webkit-scrollbar {
    display: none;
}

.quick-reply-btn {
    font-size: 0.78rem;
    padding: 0.2rem 0.65rem;
    border-radius: 50px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.quick-reply-btn:hover {
    background: var(--line-green);
    border-color: var(--line-green);
    color: #FFFFFF;
}

/* Sticky Input Bar */
.chat-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    position: relative;
    z-index: 10;
}

.chat-btn-action {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.chat-btn-action:hover {
    background: var(--bg-main);
    color: var(--line-green);
}

.chat-input-container {
    flex: 1;
    min-width: 0;
    position: relative;
}

.chat-textarea {
    width: 100%;
    resize: none;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 0.55rem 1rem;
    font-size: 0.92rem;
    line-height: 1.4;
    background: var(--bg-main);
    color: var(--text-main);
    max-height: 120px;
    min-height: 38px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-textarea:focus {
    border-color: var(--line-green);
    box-shadow: 0 0 0 3px rgba(6, 199, 85, 0.15);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--line-green);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(6, 199, 85, 0.35);
    transition: transform 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: var(--line-green-dark);
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    background: #CBD5E1;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Floating Scroll to Bottom button */
.chat-scroll-bottom-btn {
    position: absolute;
    right: 1.25rem;
    bottom: 80px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
    transition: all 0.2s ease;
    opacity: 0;
    pointer-events: none;
}

.chat-scroll-bottom-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

.chat-scroll-bottom-btn .unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #EF4444;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 50px;
    padding: 0.1rem 0.35rem;
}

/* Empty State */
.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: auto;
    color: rgba(255, 255, 255, 0.85);
    text-align: center;
    padding: 2rem;
}

.chat-empty-icon {
    font-size: 3.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.85;
}

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
    .chat-wrapper {
        height: calc(100dvh - 90px);
        max-height: calc(100dvh - 90px);
        border-radius: 0;
        border-left: none;
        border-right: none;
        margin: -0.75rem -0.65rem -1.5rem;
    }

    .chat-header {
        padding: 0.6rem 0.85rem;
    }

    .chat-header-avatar {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
    }

    .chat-body {
        padding: 0.75rem 0.65rem;
    }

    .chat-message-row {
        max-width: 90%;
    }

    .chat-input-bar {
        padding: 0.5rem 0.65rem;
    }

    .chat-attachment-image {
        max-width: 220px;
        max-height: 220px;
    }
}
