/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: radial-gradient(circle at 20% 20%, #1e1e24, #0b0b0e);
    /* min-height: 100vh;
    min-height: 100dvh; */
    display: flex;
    align-items: center;
    justify-content: center;
    /* padding: 1.5rem; */
    margin: 0;
}

/* ===== CHAT CONTAINER ===== */
.chat-container {
    width: 100%;
    height: 100vh; 
    /* max-height: 90vh;  */
    /* max-height: 90dvh;   */
    background: rgba(18, 18, 22, 0.8);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    /* border-radius: 2.5rem; */
    box-shadow: 0 30px 50px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 140, 0, 0.15), 0 0 30px rgba(255, 100, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 140, 0, 0.25);
}

/* ===== HEADER ===== */
.header {
    background: rgba(20, 20, 26, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 1.2rem 1.5rem 0.8rem;
    border-bottom: 1px solid rgba(255, 140, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.avatar-group {
    display: flex;
    align-items: center;
    position: relative;
}

.avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(145deg, #2a2a35, #0f0f14);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 140, 0, 0.7);
    box-shadow: 0 0 15px rgba(255, 100, 0, 0.5);
    font-size: 1.5rem;
    color: #ff8c00;
    background: #1c1c24;
}

.online-dot {
    position: absolute;
    bottom: 4px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #ff7b00;
    border-radius: 50%;
    border: 2px solid #0b0b0e;
    box-shadow: 0 0 12px #ff7700;
}

.header-text h2 {
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: -0.3px;
    background: linear-gradient(to right, #ffffff, #ffb87c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-text span {
    font-size: 0.75rem;
    color: #ff9f4b;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.header-actions i {
    font-size: 1.3rem;
    color: #ff8c00;
    background: rgba(255, 140, 0, 0.1);
    padding: 0.6rem;
    border-radius: 50%;
    backdrop-filter: blur(10px);
    transition: 0.2s;
    cursor: pointer;
    border: 1px solid rgba(255, 140, 0, 0.3);
}
.header-actions i:hover {
    background: rgba(255, 120, 0, 0.25);
    color: #fff;
    box-shadow: 0 0 18px #ff7b00;
}

/* ===== TOOLBAR ===== */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1.5rem;
    background: rgba(10, 10, 14, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 140, 0, 0.15);
    flex-shrink: 0;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #ddd;
    font-size: 0.85rem;
    font-weight: 500;
    min-width: 0;
    flex: 1 1 auto;
}

.user-info img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255, 140, 0, 0.4);
    object-fit: cover;
    flex-shrink: 0;
}

.user-info i {
    font-size: 1.4rem;
    color: #ff8c00;
    flex-shrink: 0;
}

.user-info span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.auth-buttons {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.auth-buttons button {
    padding: 0.4rem 1rem;
    border: none;
    border-radius: 2rem;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: 0.2s;
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    touch-action: manipulation;
    white-space: nowrap;
}

.btn-login {
    background: linear-gradient(135deg, #ff7b00, #ff5500);
    color: #fff;
    box-shadow: 0 0 18px rgba(255, 100, 0, 0.4);
}
.btn-login:hover {
    transform: scale(1.03);
    box-shadow: 0 0 28px rgba(255, 100, 0, 0.6);
}

.btn-logout {
    background: rgba(255, 255, 255, 0.08);
    color: #ff7b00;
    border: 1px solid rgba(255, 140, 0, 0.3) !important;
}
.btn-logout:hover {
    background: rgba(255, 60, 0, 0.2);
}

/* ===== CHAT BOX ===== */
.chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 1.2rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: transparent;
    scrollbar-width: thin;
    scrollbar-color: #ff8c00 #1e1e24;
    -webkit-overflow-scrolling: touch;
}
.chat-box::-webkit-scrollbar {
    width: 5px;
}
.chat-box::-webkit-scrollbar-track {
    background: #1a1a20;
    border-radius: 10px;
}
.chat-box::-webkit-scrollbar-thumb {
    background: #ff7b00;
    border-radius: 10px;
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.5);
}

.empty-chat {
    text-align: center;
    color: #888;
    margin-top: 2rem;
    font-style: italic;
    font-size: 0.95rem;
    opacity: 0.6;
}

/* ===== MESSAGE BUBBLE ===== */
.message-row {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    animation: fadeInUp 0.25s ease-out;
}
.message-row.sent {
    align-self: flex-end;
    align-items: flex-end;
}
.message-row.received {
    align-self: flex-start;
    align-items: flex-start;
}

.bubble {
    padding: 0.8rem 1.2rem;
    border-radius: 1.5rem;
    font-weight: 500;
    font-size: 0.92rem;
    line-height: 1.4;
    word-break: break-word;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
}

.sent .bubble {
    background: linear-gradient(135deg, rgba(255, 120, 0, 0.3), rgba(255, 70, 0, 0.15));
    border-top-right-radius: 0.4rem;
    color: #fff5ec;
    border: 1px solid rgba(255, 140, 0, 0.45);
    box-shadow: 0 0 18px rgba(255, 85, 0, 0.25);
    top: 5px;
    right: 20px;
    box-shadow: 5px 5px 10px #a9a9a980;
}

.received .bubble {
    background: rgba(25, 25, 32, 0.8);
    backdrop-filter: blur(16px);
    border-top-left-radius: 0.4rem;
    color: #eaeaea;
    border: 1px solid rgba(255, 255, 255, 0.08);
    top: 5px;
    left: 20px;
    box-shadow: 5px 5px 10px #a9a9a980;
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 5px;
    font-size: 0.65rem;
    color: #999;
    padding: 0 0.2rem;
}
.sent .message-meta {
    justify-content: flex-end;
    color: #ffbd7a;
}
.name {
    font-weight: 700;
    color: #ff8c00;
    letter-spacing: -0.2px;
    text-shadow: 0 0 6px rgba(255, 140, 0, 0.5);
}
.received .name {
    color: #ffaa5e;
}
.time {
    color: #9a9a9a;
}

/* Avatar di dalam pesan (untuk received) */
.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(255, 140, 0, 0.3);
    object-fit: cover;
    margin-right: 0.4rem;
}
.message-header {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 2px;
}

/* ===== INPUT AREA ===== */
.input-area {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.2rem 1.2rem;
    background: rgba(15, 15, 20, 0.8);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid rgba(255, 140, 0, 0.35);
    box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.7);
    flex-shrink: 0;
}

.input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: rgba(30, 30, 38, 0.7);
    backdrop-filter: blur(14px);
    border-radius: 2.5rem;
    padding: 0.2rem 0.2rem 0.2rem 1.2rem;
    border: 1px solid rgba(255, 140, 0, 0.4);
    box-shadow: 0 0 18px rgba(255, 100, 0, 0.15);
    transition: 0.2s;
}
.input-wrapper:focus-within {
    border-color: #ff7b00;
    box-shadow: 0 0 22px #ff6200;
}

.input-wrapper input {
    background: transparent;
    border: none;
    padding: 0.8rem 0;
    font-size: 0.9rem;
    color: #fff;
    width: 100%;
    outline: none;
    font-weight: 500;
}
.input-wrapper input::placeholder {
    color: #888;
    font-weight: 400;
}
.input-wrapper input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.send-btn {
    background: linear-gradient(135deg, #ff7b00, #ff5500);
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 0 22px rgba(255, 100, 0, 0.6);
    transition: 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    flex-shrink: 0;
    touch-action: manipulation;
}
.send-btn:hover:not(:disabled) {
    background: #ff6600;
    box-shadow: 0 0 30px #ff7b00;
    transform: scale(1.03);
}
.send-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
}
.send-btn i {
    filter: drop-shadow(0 0 5px black);
}

/* ===== ANIMASI ===== */
@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(12px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== RESPONSIF ===== */
@media (max-width: 600px) {
    body {
        /* padding: 0.5rem; */
    }
    .chat-container {
        /* max-width: 100%;
        max-height: 100dvh;
        border-radius: 1.2rem; */
        height: 100vh;
        border: 1px solid rgba(255, 140, 0, 0.15);
    }
    .header {
        padding: 0.8rem 1rem 0.6rem;
    }
    .header-text h2 {
        font-size: 1.1rem;
    }
    .header-text span {
        font-size: 0.65rem;
    }
    .avatar {
        width: 38px;
        height: 38px;
        font-size: 1.2rem;
    }
    .online-dot {
        width: 12px;
        height: 12px;
        bottom: 2px;
        right: 1px;
    }
    .header-actions i {
        font-size: 1.1rem;
        padding: 0.5rem;
    }
    .toolbar {
        padding: 0.4rem 0.8rem;
        gap: 0.3rem;
        flex-wrap: wrap;
    }
    .user-info {
        font-size: 0.75rem;
        gap: 0.3rem;
    }
    .user-info img {
        width: 28px;
        height: 28px;
    }
    .user-info i {
        font-size: 1.2rem;
    }
    .auth-buttons button {
        padding: 0.3rem 0.7rem;
        font-size: 0.7rem;
        gap: 0.2rem;
    }
    .chat-box {
        padding: 0.8rem 0.8rem;
        gap: 0.8rem;
    }
    .message-row {
        max-width: 92%;
    }
    .bubble {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }
    .sent .bubble {
        top: 3px;
        right: 10px;
        box-shadow: 3px 3px 8px #a9a9a980;
    }
    .received .bubble {
        top: 3px;
        left: 10px;
        box-shadow: 3px 3px 8px #a9a9a980;
    }
    .message-meta {
        font-size: 0.6rem;
        gap: 4px;
    }
    .message-avatar {
        width: 22px;
        height: 22px;
    }
    .input-area {
        padding: 0.5rem 0.8rem 0.8rem;
        gap: 0.4rem;
    }
    .input-wrapper {
        padding: 0.1rem 0.1rem 0.1rem 1rem;
        border-radius: 2rem;
    }
    .input-wrapper input {
        padding: 0.6rem 0;
        font-size: 0.85rem;
    }
    .send-btn {
        width: 42px;
        height: 42px;
        font-size: 1rem;
        flex-shrink: 0;
    }
    .empty-chat {
        font-size: 0.85rem;
        margin-top: 1.5rem;
    }
}

/* ===== PERBAIKAN UNTUK LAYAR SANGAT KECIL ( < 380px ) ===== */
@media (max-width: 380px) {
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.3rem;
    }
    .auth-buttons {
        justify-content: flex-end;
    }
    .auth-buttons button {
        font-size: 0.65rem;
        padding: 0.25rem 0.6rem;
    }
    .user-info {
        font-size: 0.7rem;
    }
    .user-info img {
        width: 24px;
        height: 24px;
    }
    .header-text h2 {
        font-size: 1rem;
    }
    .header {
        padding: 0.6rem 0.8rem 0.4rem;
    }
    .chat-box {
        padding: 0.6rem 0.6rem;
        gap: 0.6rem;
    }
    .bubble {
        padding: 0.5rem 0.8rem;
        font-size: 0.8rem;
    }
     .sent .bubble {
        top: 1px;
        right: 10px;
        box-shadow: 3px 3px 8px #a9a9a980;
    }
    .received .bubble {
        top: 1px;
        left: 10px;
        box-shadow: 3px 3px 8px #a9a9a980;
    }
    .message-meta {
        font-size: 0.6rem;
        gap: 4px;
    }
    .send-btn {
        width: 38px;
        height: 38px;
        font-size: 0.9rem;
    }
    .input-wrapper {
        padding: 0.1rem 0.1rem 0.1rem 0.8rem;
    }
    .input-wrapper input {
        padding: 0.5rem 0;
        font-size: 0.8rem;
    }
    .input-area {
        padding: 0.4rem 0.6rem 0.6rem;
        gap: 0.3rem;
    }
}

/* ===== MODAL LOGIN ===== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: modalFadeIn 0.25s ease-out;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.modal-content {
    position: relative;
    max-width: 400px;
    width: 100%;
    background: rgba(20, 20, 28, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 2rem;
    padding: 2rem 1.8rem 1.8rem;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 140, 0, 0.2), 0 0 40px rgba(255, 100, 0, 0.15);
    border: 1px solid rgba(255, 140, 0, 0.25);
    text-align: center;
    animation: modalSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.modal-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, rgba(255, 120, 0, 0.2), rgba(255, 70, 0, 0.1));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 140, 0, 0.4);
    box-shadow: 0 0 30px rgba(255, 100, 0, 0.2);
}

.modal-icon i {
    font-size: 2rem;
    color: #ff8c00;
}

.modal-header h3 {
    color: #fff;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    margin: 0;
    background: linear-gradient(to right, #ffffff, #ffb87c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-body {
    color: #ccc;
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.modal-body p {
    margin: 0.2rem 0;
}

.modal-sub {
    color: #999;
    font-size: 0.85rem;
    margin-top: 0.3rem;
}

.modal-footer {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    align-items: center;
}

.modal-btn {
    width: 100%;
    justify-content: center;
    padding: 0.7rem 1.5rem;
    font-size: 0.95rem;
    border-radius: 3rem;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    touch-action: manipulation;
}

.btn-modal-close {
    background: transparent;
    border: none;
    color: #999;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.3rem 1rem;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.btn-modal-close:hover {
    color: #fff;
}

/* Animasi modal */
@keyframes modalFadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes modalSlideUp {
    0% { opacity: 0; transform: scale(0.95) translateY(20px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Responsif modal */
@media (max-width: 480px) {
    .modal {
        padding: 1rem;
    }
    .modal-content {
        padding: 1.5rem 1.2rem 1.2rem;
        border-radius: 1.5rem;
    }
    .modal-icon {
        width: 52px;
        height: 52px;
    }
    .modal-icon i {
        font-size: 1.6rem;
    }
    .modal-header h3 {
        font-size: 1.1rem;
    }
    .modal-body {
        font-size: 0.85rem;
    }
    .modal-btn {
        font-size: 0.85rem;
        padding: 0.6rem 1.2rem;
    }
}