/**
 * BERRYCHAT CORE DESIGN SYSTEM
 * Consolidating all "injected" styles into a single default UI
 */

:root {
    --bg-root: #050505;
    --bg-panel: #0a0a0a;
    --border-color: rgba(255, 255, 255, 0.08);
    --accent: #3b82f6; 
    --text-main: #ededed;
    --text-dim: #888888;
    --font-stack: 'Plus Jakarta Sans', ui-monospace, SFMono-Regular, monospace;
    --app-height: 100dvh;
}

.hidden { display: none !important; }

/* Global Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-root) !important;
    background-image: 
        linear-gradient(var(--border-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--border-color) 1px, transparent 1px);
    background-size: 40px 40px;
    background-position: center top;
    color: var(--text-main) !important;
    font-family: var(--font-stack) !important;
    height: var(--app-height);
    overflow: hidden; 
    overscroll-behavior-y: contain;
}

#app {
    height: var(--app-height);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Header Styles */
header {
    position: fixed !important;
    top: 0; left: 0; right: 0;
    height: 60px;
    background: rgba(5, 5, 5, 0.95) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color) !important;
    z-index: 50;
    display: flex;
    align-items: center;
    padding: 0 20px !important;
}

header img {
    border-radius: 4px !important; 
    border: 1px solid var(--border-color);
}

/* Messages Area */
#messages {
    width: 100% !important;
    height: 100% !important;
    padding: 80px 20px 100px 20px !important;
    margin: 0 !important;
    background: transparent !important;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden !important;
    scroll-behavior: smooth !important;
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg-root); }
::-webkit-scrollbar-thumb { background: #333; border-radius: 10px; }

/* Chat Bubbles */
.wa-bubble {
    border-radius: 4px !important;
    padding: 8px 12px !important;
    border: 1px solid var(--border-color) !important;
    font-size: 14px;
    font-family: var(--font-stack);
    letter-spacing: -0.01em;
    position: relative;
    backdrop-filter: blur(5px);
    overflow-wrap: anywhere !important; 
    word-break: break-word !important;  
    max-width: 100% !important;
    width: fit-content !important;
}

.wa-bubble p { 
    white-space: pre-wrap !important; 
    word-wrap: break-word !important;
    margin: 0;
    line-height: 1.5 !important;
}

.wa-bubble b, .wa-bubble strong, .berry-bold { font-weight: 700; color: #fff; }
.wa-bubble i, .wa-bubble em, .berry-italic { font-style: italic; color: var(--accent); }
.wa-bubble code, .berry-code { font-family: monospace; background: rgba(255,255,255,0.1); padding: 2px 4px; border-radius: 3px; }
.wa-bubble a, .berry-link { 
    color: #3b82f6 !important; 
    text-decoration: underline; 
    word-break: break-all !important; 
    display: inline !important;
}

/* Chat Image Container 1:1 (WhatsApp Style) */
.wa-chat-img-container {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 8px;
    margin-bottom: 8px;
    background: #000;
    border: 1px solid rgba(255,255,255,0.08);
}

.wa-bubble-has-image {
    width: fit-content !important;
    max-width: 250px !important; /* Harus sama dengan max-width wa-chat-img-container */
    padding: 6px !important; /* Bubble gambar biasanya lebih ketat paddingnya */
}

.wa-bubble-has-image .wa-chat-img-container {
    width: 238px !important; /* padding bubble disesuaikan agar pas */
    max-width: 100% !important;
}

.wa-chat-img-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.3s;
}

.wa-chat-img-container img:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.berry-strike { text-decoration: line-through; opacity: 0.7; }

.tail-me::after, .tail-them::after { display: none !important; }

.tail-them {
    background: #0f0f0f !important;
    color: var(--text-main) !important;
    border-left: 2px solid var(--border-color) !important;
}

.tail-them .text-blue-400 {
    color: var(--text-dim) !important;
    font-size: 10px !important;
    letter-spacing: 1px;
    font-weight: 600;
    margin-bottom: 6px;
}

.tail-me {
    background: rgba(59, 130, 246, 0.08) !important;
    color: #60a5fa !important;
    border: 1px solid rgba(59, 130, 246, 0.3) !important;
    text-align: right;
}

.tail-me p { text-align: left; display: inline-block; } 

.group {
    max-width: 85% !important; /* Batas lebar chat di HP */
    width: auto !important;
}

/* Reply Box in Bubbles */
.reply-box {
    background: rgba(0, 0, 0, 0.2);
    border-left: 3px solid #426ae6;
    border-radius: 0 4px 4px 0;
    padding: 6px 10px;
    margin-bottom: 8px;
    font-size: 12px;
    overflow: hidden;
}

.reply-name {
    font-weight: 700;
    margin-bottom: 2px;
    font-size: 11px;
}

/* Input Styles */
.berry-input-fix {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 100;
    background: var(--bg-root);
    border-top: 1px solid var(--border-color);
    padding: 10px 12px calc(15px + env(safe-area-inset-bottom));
    pointer-events: none;
}

.wa-pill {
    background: var(--bg-panel) !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
    border-radius: 24px !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 15px 45px rgba(0,0,0,0.7);
    pointer-events: auto;
    width: 92%; 
    max-width: 800px;
    margin: 0 auto; 
}

/* Mobile adjustments for wa-pill */
@media (max-width: 768px) {
    .wa-pill {
        max-width: 96vw !important;
        left: 2vw !important;
        right: 2vw !important;
    }
}

.wa-reply {
    background: rgba(0,0,0,0.3); 
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: grid;
    grid-template-columns: 4px 1fr 24px; 
    gap: 10px;
    align-items: center;
    width: 100% !important;
    overflow: hidden !important;
}

.wa-reply-content {
    min-width: 0; 
    overflow: hidden;
    display: flex; 
    flex-direction: column;
    justify-content: center;
}

#waReplyName {
    font-size: 11px; font-weight: bold; text-transform: uppercase;
    white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important;
    max-width: 100% !important;
}

#waReplyText {
    color: #94a3b8; font-size: 12px; 
    display: -webkit-box !important;
    -webkit-line-clamp: 2;         
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.2 !important;
    max-width: 100% !important;
    word-break: break-word !important; 
}

#berryInput {
    all: unset !important;
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;
    color: white !important;
    font-size: 16px !important;
    padding: 12px 16px !important;
    max-height: 120px;
    overflow-y: hidden !important;
    line-height: 1.4;
    caret-color: #426ae6;
    background: transparent !important;
}

#berryInput::placeholder { color: rgba(255,255,255,0.25); }

.wa-actions { display: flex; align-items: flex-end; padding: 4px 8px 8px; gap: 4px; }

.wa-btn {
    width: 42px; height: 42px; display: flex; align-items: center; 
    justify-content: center; border-radius: 50%; color: #94a3b8;
    cursor: pointer; transition: 0.2s; flex-shrink: 0;
}

.wa-send {
    background: var(--accent) !important;
    color: white !important;
    margin-left: auto;
}

#onlineCount {
    background: rgba(34, 197, 94, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(34, 197, 94, 0.2);
    font-family: monospace;
}

/* Modals */
#imagePreviewModal {
    background: rgba(0, 0, 0, 0.96) !important;
    backdrop-filter: blur(12px) !important;
    z-index: 9999 !important;
    display: flex;
    position: fixed;
    inset: 0;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

#imagePreviewModal > div {
    background: #0a0a0a !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 4px !important;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.02), 0 30px 60px rgba(0,0,0,0.9) !important;
    max-width: 420px !important;
    width: 100%;
}

#previewImg {
    border-radius: 2px !important;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background-color: #050505;
    padding: 2px;
    width: 100%;
}

#imageCaption {
    background: #111 !important;
    border: 1px solid #222 !important;
    border-radius: 4px !important;
    color: #ededed !important;
    font-family: 'Plus Jakarta Sans', monospace !important;
    padding: 12px !important;
    margin-top: 15px !important;
    font-size: 13px !important;
    width: 100%;
}

#sendImage {
    background: var(--accent) !important;
    color: #000 !important;
    border-radius: 4px !important;
    text-transform: uppercase;
    font-weight: 800 !important;
    letter-spacing: 1px;
    font-family: monospace !important;
    font-size: 12px !important;
    margin-top: 15px !important;
    border: none !important;
    padding: 14px !important;
    width: 100%;
}

/* Animations */
.animate-in { animation: none !important; opacity: 1 !important; }

/* RECAPTCHA HIDE */
body:has(#messages) .grecaptcha-badge {
    visibility: hidden !important;
    opacity: 0 !important;
}

/* AUTH UI (from login.js) */
.auth-container { display: flex; min-height: 100vh; background: #000; color: #fff; font-family: 'Plus Jakarta Sans', sans-serif; overflow: hidden; }
.hero-section { flex: 1.2; display: none; padding: 24px; }
@media (min-width: 1024px) { .hero-section { display: flex; } }
.hero-card { width: 100%; border-radius: 32px; background: radial-gradient(circle at 30% 20%, #4c1d95 0%, #000000 70%); position: relative; overflow: hidden; display: flex; flex-direction: column; padding: 60px; }
.hero-card::after { content: ""; position: absolute; inset: 0; opacity: 0.12; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.hero-content { position: relative; z-index: 2; }
.step-pill { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); border-radius: 16px; padding: 16px 22px; display: flex; align-items: center; gap: 16px; margin-top: 12px; transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1); color: rgba(255,255,255,0.4); }
.step-pill.active { background: #fff; color: #000; transform: translateX(10px); }
.step-num { width: 24px; height: 24px; border: 1.5px solid currentColor; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; }
.form-section { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 30px; position: relative; }
.form-wrapper { width: 100%; max-width: 400px; z-index: 5; }
.social-group { display: flex; gap: 14px; margin-bottom: 28px; }
.social-btn { flex: 1; height: 50px; background: transparent; border: 1px solid rgba(255,255,255,0.08); border-radius: 14px; color: #fff; font-size: 14px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer; transition: 0.3s; }
.social-btn:hover { background: #111; border-color: #444; }
.divider { display: flex; align-items: center; gap: 15px; margin-bottom: 28px; color: #444; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: rgba(255,255,255,0.08); }
.field { margin-bottom: 20px; }
.f-label { display: block; font-size: 13px; color: #a1a1aa; margin-bottom: 8px; font-weight: 600; }
.f-input { width: 100%; background: #161616; border: 1px solid rgba(255,255,255,0.08); border-radius: 14px; padding: 14px 18px; color: #fff; font-size: 15px; outline: none; transition: 0.2s; }
.f-input:focus { border-color: #7c3aed; background: #1a1a1a; box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.1); }
.btn-main { width: 100%; height: 54px; background: #fff; color: #000; border: none; border-radius: 16px; font-weight: 800; font-size: 16px; cursor: pointer; transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1); margin-top: 15px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.btn-main:hover { transform: translateY(-3px); box-shadow: 0 15px 30px rgba(255,255,255,0.15); }
.btn-main:active { transform: scale(0.97); }
.btn-main:disabled { opacity: 0.5; cursor: not-allowed; }
.error-box { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.2); color: #ef4444; padding: 12px; border-radius: 12px; font-size: 13px; margin-bottom: 20px; display: none; text-align: center; }
.fade { animation: f 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes f { from { opacity: 0; transform: translateY(20px); filter: blur(10px); } to { opacity: 1; transform: translateY(0); filter: blur(0); } }
.loader { width: 20px; height: 20px; border: 3px solid #000; border-bottom-color: transparent; border-radius: 50%; display: inline-block; animation: rotation 1s linear infinite; }
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); filter: blur(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}
.scale-in {
    animation: scaleIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.glass {
    background: rgba(15, 15, 15, 0.7) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

@keyframes pulse-blue {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.9); }
    70% { box-shadow: 0 0 0 20px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

.tutorial-glow {
    animation: pulse-blue 1.5s infinite !important;
    border: 3px solid #3b82f6 !important;
    background: #3b82f6 !important;
    color: white !important;
    z-index: 200000 !important;
    transform: scale(1.1);
}

.tutorial-tip {
    position: fixed;
    top: 75px; 
    right: 20px;
    background: #3b82f6;
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    box-shadow: 0 15px 30px rgba(0,0,0,0.5);
    z-index: 200000;
    pointer-events: none;
    animation: fadeIn 0.5s ease forwards;
}

.tutorial-tip::after {
    content: '';
    position: absolute;
    top: -8px;
    right: 125px; /* Aligned to Request Button */
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #3b82f6;
}

.tutorial-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9); /* Lebih gelap untuk kontras maksimal */
    z-index: 100000;
    animation: fadeIn 0.5s ease forwards;
}

.tutorial-active-header {
    z-index: 100001 !important;
    position: relative; /* Memastikan z-index bekerja di atas overlay */
}
