/* ============================================================
   SJS Corporate Website - AI Chat Styles
   Path: C:\xampp\htdocs\sjs-website\public\assets\css\ai.css
   ============================================================ */

/* ===== Full Page Chat ===== */
.ai-page {
    background: var(--sjs-bg);
    min-height: calc(100vh - 80px);
    padding-bottom: 60px;
}

.ai-chat-container {
    background: var(--sjs-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 70vh;
    min-height: 500px;
    max-height: 700px;
}

.ai-chat-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    background: linear-gradient(135deg, var(--sjs-navy), var(--sjs-blue));
    color: var(--sjs-white);
}

.ai-chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Penting untuk gambar avatar */
    padding: 0;       /* Penting untuk gambar avatar */
}

.ai-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.ai-chat-info strong {
    display: block;
    font-size: var(--fs-base);
}

.ai-chat-status {
    font-size: var(--fs-xs);
    opacity: 0.8;
}

.ai-chat-status::before {
    content: '●';
    color: #4ade80;
    margin-right: 4px;
}

.ai-chat-messages {
    flex: 1;
    padding: var(--space-5);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    background: var(--sjs-bg);
}

.ai-message {
    display: flex;
    max-width: 85%;
}

.ai-message-user {
    align-self: flex-end;
}

.ai-message-assistant {
    align-self: flex-start;
}

.ai-message-bubble {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    line-height: 1.6; /* Jarak antar baris yang nyaman */
    font-size: var(--fs-sm);
    word-wrap: break-word;
    text-align: left;
}

.ai-message-user .ai-message-bubble {
    background: var(--sjs-blue);
    color: var(--sjs-white);
    border-bottom-right-radius: 4px;
}

.ai-message-assistant .ai-message-bubble {
    background: var(--sjs-white);
    color: var(--sjs-text);
    border: 1px solid var(--sjs-border);
    border-bottom-left-radius: 4px;
}

/* FIX: Jarak Paragraf di dalam Bubble */
.ai-message-bubble p {
    margin: 0 0 8px 0;
    padding: 0;
}

.ai-message-bubble p:last-child {
    margin-bottom: 0;
}

/* FIX: Jarak List (UL & LI) agar proporsional */
.ai-message-bubble ul {
    margin: 8px 0 12px 0 !important;
    padding-left: 20px !important;
    list-style-type: disc;
}

.ai-message-bubble li {
    margin-bottom: 4px !important;
    padding: 0 !important;
    line-height: 1.4;
}

.ai-message-bubble li:last-child {
    margin-bottom: 0 !important;
}

.ai-chat-input {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-4);
    border-top: 1px solid var(--sjs-border);
    background: var(--sjs-white);
    align-items: flex-end;
}

.ai-chat-input textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--sjs-border);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-sans);
    font-size: var(--fs-sm);
    max-height: 120px;
    outline: none;
}

.ai-chat-input textarea:focus {
    border-color: var(--sjs-blue);
}

.ai-send-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--sjs-blue);
    color: var(--sjs-white);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.ai-send-btn:hover {
    background: var(--sjs-blue-dark);
}

.ai-chat-footer {
    padding: var(--space-2) var(--space-4);
    background: var(--sjs-white);
    text-align: center;
    border-top: 1px solid var(--sjs-border);
}

.ai-chat-footer small {
    color: var(--sjs-text-muted);
    font-size: var(--fs-xs);
}

.ai-chat-footer a {
    color: var(--sjs-blue);
}

/* ===== Typing indicator ===== */
.ai-typing {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.ai-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--sjs-text-light);
    animation: ai-bounce 1.2s infinite;
}

.ai-typing span:nth-child(2) { animation-delay: 0.15s; }
.ai-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ai-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* ===== Floating Widget ===== */
.ai-widget {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: calc(100vh - 120px);
    background: var(--sjs-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
} 

.ai-widget[hidden] {
    display: none !important;
}

.ai-widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4);
    background: linear-gradient(135deg, var(--sjs-navy), var(--sjs-blue));
    color: var(--sjs-white);
    font-weight: var(--fw-semibold);
    position: relative;
    z-index: 10;
}

.ai-widget-header button {
    background: transparent;
    border: none;
    color: var(--sjs-white);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
    position: relative;
    z-index: 20;
    pointer-events: auto;
    transition: background 0.2s;
}

.ai-widget-header button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.ai-widget-messages {
    flex: 1;
    padding: var(--space-4);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    background: var(--sjs-bg);
}

.ai-widget-input {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-3);
    border-top: 1px solid var(--sjs-border);
    background: var(--sjs-white);
}

.ai-widget-input input {
    flex: 1;
    border: 1px solid var(--sjs-border);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    font-size: var(--fs-sm);
    outline: none;
}

.ai-widget-input input:focus {
    border-color: var(--sjs-blue);
}

.ai-widget-input button {
    background: var(--sjs-blue);
    color: var(--sjs-white);
    border: none;
    border-radius: var(--radius-md);
    padding: 0 var(--space-3);
    cursor: pointer;
    font-size: 18px;
}

.ai-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--sjs-navy), var(--sjs-blue));
    color: var(--sjs-white);
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: var(--z-chat);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-base);
}

.ai-fab:hover {
    transform: scale(1.1);
}

/* Responsive */
@media (max-width: 640px) {
    .ai-chat-container {
        height: 75vh;
        border-radius: var(--radius-lg);
    }
    .ai-message {
        max-width: 90%;
    }
    .ai-widget {
        width: calc(100vw - 20px);
        right: 10px;
        height: 70vh;
    }
    .ai-fab {
        right: 15px;
        bottom: 15px;
        width: 54px;
        height: 54px;
    }
}