/**
 * BeMoveChat — Custom Styles
 *
 * Styling spesifik BeMoveChat di luar yang disediakan AdminLTE.
 * Mobile-first — semua halaman harus berfungsi di 360px–1440px.
 *
 * @version 1.1.0 — Fase 7
 */

/* ===================================================================
 * LOGIN PAGE
 * =================================================================== */

/* Brand logo di atas form login */
.bemove-login-logo {
    font-size: 1.75rem;
    font-weight: 700;
    color: #007bff;
    text-align: center;
    margin-bottom: 1.5rem;
}

.bemove-login-logo i {
    font-size: 2rem;
    vertical-align: middle;
    margin-right: 0.25rem;
}

.bemove-login-logo a {
    color: #007bff;
    text-decoration: none;
}

.bemove-login-subtitle {
    text-align: center;
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

/* ===================================================================
 * RESPONSIVE: Login Box
 * =================================================================== */
.login-box {
    width: 90vw;
    max-width: 400px;
}

@media (min-width: 768px) {
    .login-box {
        width: 400px;
    }
}

/* ===================================================================
 * CHAT APP CONTAINER — WhatsApp Web style
 * =================================================================== */
.bemove-chat-container {
    width: 100%;
    height: 100vh;
    height: 100dvh; /* dynamic viewport untuk mobile browser */
    display: flex;
    flex-direction: column;
    background: #fff;
}

@media (min-width: 480px) {
    .bemove-chat-container {
        max-width: 480px;
        margin: 0 auto;
        border-left: 1px solid #dee2e6;
        border-right: 1px solid #dee2e6;
        box-shadow: 0 0 20px rgba(0,0,0,0.05);
    }
}

/* ===================================================================
 * HEADER
 * =================================================================== */
.bemove-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: #fff;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
    min-height: 56px;
}

.bemove-header-logo {
    font-size: 1.15rem;
    font-weight: 700;
    color: #212529;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.bemove-header-logo i {
    font-size: 1.3rem;
}

/* Dropdown user menu di header — manual toggle (tanpa Bootstrap dropdown.js) */
.bemove-header-user {
    position: relative;
}
.bemove-header-user .dropdown-toggle::after {
    display: none;
}
.bemove-header-user .dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 1100;
    min-width: 200px;
    margin-top: 0.5rem;
    overflow: visible;
}
.bemove-header-user.open .dropdown-menu {
    display: block;
}

/* ===================================================================
 * AVATAR
 * =================================================================== */
.bemove-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
    overflow: hidden;
}

.bemove-avatar-sm {
    width: 34px;
    height: 34px;
    font-size: 0.75rem;
}

.bemove-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* ===================================================================
 * CONVERSATION LIST
 * =================================================================== */
.bemove-conversation-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Override AdminLTE .chat-contact untuk layout kita */
.bemove-conversation-list .chat-contact {
    display: flex;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    text-decoration: none;
    color: inherit;
    transition: background 0.1s;
    align-items: center;
}

.bemove-conversation-list .chat-contact:hover {
    background: #f8f9fa;
}

.bemove-conversation-list .chat-contact:active {
    background: #e9ecef;
}

/* Empty state */
.bemove-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 2rem;
    color: #6c757d;
}

/* ===================================================================
 * FLOATING ACTION BUTTON
 * =================================================================== */
.bemove-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: #007bff;
    color: #fff;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
    cursor: pointer;
    z-index: 100;
    transition: transform 0.2s, box-shadow 0.2s;
}

.bemove-fab:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 123, 255, 0.5);
}

.bemove-fab:active {
    transform: scale(0.95);
}

/* Di desktop, FAB mengikuti container width */
@media (min-width: 480px) {
    .bemove-fab {
        position: absolute;
    }

    /* FAB ikut container yang centered */
    .bemove-chat-container {
        position: relative;
    }
}

/* ===================================================================
 * NEW CHAT MODAL — daftar kontak
 * =================================================================== */
.bemove-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: flex-end;  /* bottom sheet di mobile */
    justify-content: center;
}

.bemove-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
}

.bemove-modal-content {
    position: relative;
    background: #fff;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-height: 80vh;
    max-height: 80dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@media (min-width: 480px) {
    .bemove-modal-overlay {
        align-items: center;
    }

    .bemove-modal-content {
        border-radius: 12px;
        width: 420px;
        max-height: 70vh;
        max-height: 70dvh;
    }
}

.bemove-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
}

.bemove-modal-search {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.bemove-modal-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.5rem 0;
}

/* User item dalam modal */
.bemove-user-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    cursor: pointer;
    transition: background 0.1s;
}

.bemove-user-item:hover {
    background: #f8f9fa;
}

.bemove-user-item:active {
    background: #e9ecef;
}

/* ===================================================================
 * CHAT ROOM HEADER
 * =================================================================== */
.bemove-room-header {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: #fff;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
    min-height: 56px;
    gap: 0;
}

/* 3-dot menu di header room */
.bemove-room-menu {
    position: relative;
    flex-shrink: 0;
    margin-left: auto;
}
.bemove-room-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 1100;
    min-width: 180px;
    margin-top: 0.5rem;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    list-style: none;
    padding: 0.25rem 0;
}
.bemove-room-menu.open .bemove-room-dropdown {
    display: block;
}
.bemove-room-dropdown li a {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    color: #dc3545;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
}
.bemove-room-dropdown li a:hover {
    background: #f8f9fa;
}

/* ===================================================================
 * MESSAGES AREA
 * =================================================================== */
.bemove-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.75rem 0.5rem;
    background: #efeae2;            /* WhatsApp-style background */
    background-image:
        linear-gradient(rgba(255,255,255,0.3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.3) 1px, transparent 1px);
    background-size: 20px 20px;
}

@media (min-width: 480px) {
    .bemove-messages {
        padding: 1rem 1.5rem;
    }
}

/* Message wrapper */
.bemove-message-wrapper {
    display: flex;
    margin-bottom: 0.25rem;
    will-change: transform, opacity;
}

/* New message highlight (brief flash) */
.bemove-message-wrapper.new-message {
    animation: bemove-flash 1.5s ease-out;
}

@keyframes bemove-flash {
    0% { background: rgba(0,123,255,0.1); }
    100% { background: transparent; }
}

.bemove-message-wrapper.me {
    justify-content: flex-end;
}

.bemove-message-wrapper.them {
    justify-content: flex-start;
}

/* Bubble */
.bemove-bubble {
    max-width: 85%;
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

@media (min-width: 480px) {
    .bemove-bubble {
        max-width: 70%;
    }
}

/* Saya — biru */
.bemove-message-wrapper.me .bemove-bubble {
    background: #d9fdd3;       /* WhatsApp green-ish, or use primary */
    border-top-right-radius: 2px;
}

/* Lawan — putih */
.bemove-message-wrapper.them .bemove-bubble {
    background: #fff;
    border-top-left-radius: 2px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.05);
}

/* Text */
.bemove-bubble-text {
    display: inline;
}

/* Timestamp */
.bemove-bubble-time {
    display: inline-block;
    font-size: 0.65rem;
    color: #667781;
    margin-left: 6px;
    white-space: nowrap;
    float: right;
    margin-top: 0.35rem;
    margin-bottom: -0.1rem;
}

/* Checkmark status */
.bemove-bubble-status {
    font-size: 0.7rem;
    color: #8696a0;
    float: right;
    clear: right;
    margin-left: 4px;
    margin-top: 1px;
}

.bemove-bubble-status.read {
    color: #53bdeb;   /* Biru WhatsApp untuk centang dibaca */
}

.bemove-bubble-status.failed {
    color: #dc3545;
    cursor: pointer;
}

/* Sending spinner */
.bemove-spinner-sending {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid #8696a0;
    border-top-color: transparent;
    border-radius: 50%;
    animation: bemove-spin 0.6s linear infinite;
}

@keyframes bemove-spin {
    to { transform: rotate(360deg); }
}

/* Image in bubble */
.bemove-bubble-image {
    max-width: 240px;
    max-height: 320px;
    border-radius: 4px;
    cursor: pointer;
    display: block;
    margin-bottom: 0.2rem;
    object-fit: cover;
}

@media (max-width: 479px) {
    .bemove-bubble-image {
        max-width: 200px;
        max-height: 260px;
    }
}

/* ===================================================================
 * DATE DIVIDER
 * =================================================================== */
.bemove-date-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0.75rem 0;
}

.bemove-date-divider span {
    background: #e1f3fb;
    color: #54656f;
    font-size: 0.7rem;
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    font-weight: 500;
    box-shadow: 0 1px 1px rgba(0,0,0,0.06);
}

/* ===================================================================
 * COMPOSER
 * =================================================================== */
.bemove-composer {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.6rem;
    background: #f0f2f5;
    border-top: 1px solid #dee2e6;
    flex-shrink: 0;
}

.bemove-composer input[type="text"] {
    flex: 1;
    border-radius: 20px;
    border: 1px solid #dee2e6;
    padding: 0.45rem 1rem;
    font-size: 0.9rem;
    background: #fff;
    outline: none;
}

.bemove-composer input[type="text"]:focus {
    border-color: #007bff;
    box-shadow: none;
}

.bemove-composer .btn {
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.bemove-composer .btn-outline-secondary {
    border: none;
    color: #54656f;
}

.bemove-composer .btn-outline-secondary:hover {
    background: #d9d9d9;
}

.bemove-composer .btn-primary {
    border: none;
}

/* ===================================================================
 * LIGHTBOX — Fullscreen image viewer
 * =================================================================== */
.bemove-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.bemove-lightbox img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    cursor: default;
}

.bemove-lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    font-size: 1.3rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    transition: background 0.2s;
}

.bemove-lightbox-close:hover {
    background: rgba(255,255,255,0.3);
}

/* ===================================================================
 * PROFILE PAGE
 * =================================================================== */
.bemove-profile-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
}

.bemove-profile-avatar-section {
    text-align: center;
    padding: 1.5rem 0;
}

.bemove-profile-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    font-size: 2rem;
    font-weight: 700;
    cursor: pointer;
    overflow: hidden;
    transition: opacity 0.2s;
    border: 3px solid #dee2e6;
}

.bemove-profile-avatar:hover {
    opacity: 0.85;
}

.bemove-profile-section {
    padding: 0.9rem 0;
    border-bottom: 1px solid #f0f0f0;
}

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

/* ===================================================================
 * UTILITY
 * =================================================================== */
.bemove-spinner {
    color: #007bff;
}
