/* ===== Chat Widget Styles — LSP UNTAN Modern ===== */
:root {
    --chat-primary: #004a8d;
    --chat-primary-light: #e0eaf5;
    --chat-accent: #f59e0b;
    --chat-bg-glass: rgba(255, 255, 255, 0.85);
    --chat-border: rgba(226, 232, 240, 0.8);
    --chat-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.2);
    --chat-radius: 1.25rem;
}

/* ===== Widget Container ===== */
#chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 100000;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ===== Toggle Button ===== */
.chat-toggle {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    border: none;
    background: var(--chat-primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 74, 141, 0.35);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.chat-toggle::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(255,255,255,0.1), transparent);
}

.chat-toggle:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 74, 141, 0.45);
}

.chat-toggle .badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--chat-accent);
    color: #000;
    font-size: 10px;
    font-weight: 800;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #fff;
    z-index: 2;
}

/* ===== Chat Panel ===== */
.chat-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 400px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--chat-bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--chat-border);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: bounceIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes bounceIn {
    0% { opacity: 0; transform: scale(0.8) translateY(40px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* ===== Header ===== */
.chat-header {
    background: var(--chat-primary);
    color: #fff;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -20%;
    width: 140%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
    pointer-events: none;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 14px;
    z-index: 1;
}

.avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #ffffff; /* Explicit white color */
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    margin-right: 6px;
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
}

.status-text {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9); /* Explicit light color */
}

.minimize-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 10px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 1;
}

.minimize-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* ===== Messages Area ===== */
.chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: transparent;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    animation: messageIn 0.3s ease-out;
}

@keyframes messageIn {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

.message.bot { align-self: flex-start; }
.message.user { align-self: flex-end; }

.message-content {
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 14.5px;
    line-height: 1.55;
    word-wrap: break-word;
}

.message.bot .message-content {
    background: #fff;
    color: #1e293b;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.message.user .message-content {
    background: var(--chat-primary);
    color: #fff;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 74, 141, 0.15);
}

.message-time {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 6px;
    font-weight: 500;
}

.message.user .message-time { text-align: right; }

/* Typing animation */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 4px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #cbd5e1;
    border-radius: 50%;
    animation: typing 1s infinite alternate;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    from { opacity: 0.4; transform: translateY(0); }
    to { opacity: 1; transform: translateY(-4px); }
}

/* ===== Quick Replies ===== */
.quick-replies {
    padding: 8px 20px 16px;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
    flex-shrink: 0;
}

.quick-replies::-webkit-scrollbar { display: none; } /* Chrome/Safari */

.quick-btn {
    padding: 8px 16px;
    white-space: nowrap;
    background: #fff;
    border: 1px solid rgba(0, 74, 141, 0.1);
    border-radius: 100px;
    color: var(--chat-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.quick-btn:hover {
    background: var(--chat-primary);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 74, 141, 0.2);
}

/* ===== Chat Input ===== */
.chat-input {
    padding: 20px;
    background: #fff;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

#chat-input-field {
    flex: 1;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 12px 18px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s;
}

#chat-input-field:focus {
    outline: none;
    border-color: var(--chat-primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(0, 74, 141, 0.08);
}

.send-btn {
    width: 46px;
    height: 46px;
    background: var(--chat-primary);
    color: #fff;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.send-btn:hover:not(:disabled) {
    background: #003d75;
    border-radius: 16px;
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Custom Scrollbar ===== */
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* ===== Status Check Card (tanya_hasil intent) ===== */
.message.message--card { max-width: 92%; }

.message.message--card .message-content {
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
}

.status-check-card {
    background: #fff;
    border: 1px solid rgba(0, 74, 141, 0.12);
    border-radius: 16px;
    border-bottom-left-radius: 6px;
    padding: 16px 18px;
    box-shadow: 0 4px 14px rgba(0, 74, 141, 0.08);
    transition: opacity 0.3s ease;
}

.status-check-card__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14.5px;
    font-weight: 700;
    color: var(--chat-primary);
    letter-spacing: -0.01em;
}

.status-check-card__subtitle {
    margin-top: 4px;
    font-size: 13px;
    color: #475569;
    line-height: 1.45;
}

.status-check-card__nik-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
}

.status-check-card__nik-input {
    flex: 1 1 auto;
    min-width: 0;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    color: #1e293b;
    letter-spacing: 0.04em;
    transition: all 0.25s ease;
}

.status-check-card__nik-input::placeholder {
    color: #94a3b8;
    letter-spacing: normal;
}

.status-check-card__nik-input:focus {
    outline: none;
    background: #fff;
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(0, 74, 141, 0.1);
}

.status-check-card__nik-input:disabled {
    background: #f1f5f9;
    color: #64748b;
    cursor: not-allowed;
}

.status-check-card__submit {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    background: var(--chat-primary);
    color: #fff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    position: relative;
}

.status-check-card__submit:hover:not(:disabled) {
    background: #003d75;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 74, 141, 0.25);
}

.status-check-card__submit:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.status-check-card__spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: status-check-spin 0.7s linear infinite;
}

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

.status-check-card--loading .status-check-card__submit-icon { display: none; }
.status-check-card--loading .status-check-card__spinner { display: block; }
.status-check-card--loading .status-check-card__submit { opacity: 1; }
.status-check-card--submitted { opacity: 0.95; }

.status-check-card__hint {
    margin-top: 8px;
    font-size: 11.5px;
    color: #94a3b8;
    font-weight: 500;
}

/* ===== Links inside bot messages ===== */
.message.bot .message-content a {
    color: var(--chat-primary);
    text-decoration: underline;
    font-weight: 500;
    word-break: break-all;
}

.message.bot .message-content a:hover {
    opacity: 0.75;
}

/* ===== Mobile Adjustments ===== */
@media (max-width: 640px) {
    #chat-widget {
        bottom: 16px;
        right: 16px;
    }
    .chat-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        transform-origin: center;
    }

    /* Hide floating toggle when panel is open (mobile only) — the panel
       header has its own minimize button, so the toggle would just
       overlap the input bar / send button. */
    #chat-widget:has(#chat-panel[style*="flex"]) .chat-toggle {
        display: none;
    }

    .status-check-card { padding: 14px; }
    .status-check-card__nik-input { padding: 10px 12px; font-size: 13.5px; }
}
