/* ============================================================
   APOTEK ALPRO - AI AGENT CHATBOT STYLES
   Intelligent Department Assistant
   ============================================================ */

/* ---- Floating Button ---- */
#alpro-ai-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    filter: drop-shadow(0 8px 24px rgba(79,70,229,0.45));
    transition: transform 0.25s cubic-bezier(.34,1.56,.64,1);
    user-select: none;
}
#alpro-ai-fab:hover { transform: scale(1.08) translateY(-3px); }
#alpro-ai-fab:active { transform: scale(0.96); }

#alpro-ai-fab-btn {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 60%, #a855f7 100%);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 6px 20px rgba(79,70,229,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
}
#alpro-ai-fab-btn i { font-size: 26px; color: #fff; transition: transform 0.3s; }
#alpro-ai-fab.open #alpro-ai-fab-btn i { transform: rotate(45deg); }

.alpro-fab-pulse {
    position: absolute;
    top: -4px; right: -4px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: #22c55e;
    border: 2.5px solid #fff;
    animation: fabPulse 2s infinite;
}
@keyframes fabPulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.6); }
    50% { box-shadow: 0 0 0 7px rgba(34,197,94,0); }
}

#alpro-ai-fab-label {
    background: linear-gradient(135deg,#4f46e5,#7c3aed);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    padding: 7px 14px;
    border-radius: 20px;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(79,70,229,0.3);
    letter-spacing: 0.02em;
    animation: labelBounce 0.6s 1.5s both;
}
@keyframes labelBounce {
    from { opacity: 0; transform: translateX(15px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ---- Chat Window ---- */
#alpro-ai-window {
    position: fixed;
    bottom: 104px;
    right: 28px;
    width: 420px;
    max-width: calc(100vw - 24px);
    height: 620px;
    max-height: calc(100vh - 130px);
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 32px 80px rgba(30,20,80,0.22), 0 2px 8px rgba(79,70,229,0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99998;
    transform: scale(0.85) translateY(30px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.32s cubic-bezier(.34,1.56,.64,1), opacity 0.24s ease;
    border: 1px solid rgba(79,70,229,0.1);
}
#alpro-ai-window.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* ---- Header ---- */
#alpro-ai-header {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 60%, #a855f7 100%);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}
#alpro-ai-header::before {
    content: '';
    position: absolute;
    top: -40px; right: -40px;
    width: 120px; height: 120px;
    border-radius: 50%;
    background: rgba(255,255,255,0.07);
}
#alpro-ai-header::after {
    content: '';
    position: absolute;
    bottom: -30px; left: 20px;
    width: 80px; height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
}

.alpro-ai-avatar {
    width: 46px; height: 46px;
    border-radius: 50%;
    background: rgba(255,255,255,0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.3);
    position: relative;
    z-index: 1;
}
.alpro-ai-header-info { flex: 1; position: relative; z-index: 1; }
.alpro-ai-header-info h4 {
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.01em;
}
.alpro-ai-header-info p {
    color: rgba(255,255,255,0.8);
    font-size: 11.5px;
    margin: 2px 0 0;
}
.alpro-ai-status {
    display: flex;
    align-items: center;
    gap: 5px;
    color: rgba(255,255,255,0.85);
    font-size: 11px;
    margin-top: 4px;
}
.alpro-ai-status-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #4ade80;
    animation: statusPulse 2s infinite;
}
@keyframes statusPulse {
    0%,100% { opacity: 1; } 50% { opacity: 0.4; }
}

.alpro-ai-header-actions { display: flex; gap: 6px; position: relative; z-index: 1; }
.alpro-ai-header-actions button {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    width: 32px; height: 32px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: background 0.2s;
}
.alpro-ai-header-actions button:hover { background: rgba(255,255,255,0.28); }

/* ---- Department Selector ---- */
#alpro-dept-bar {
    background: linear-gradient(90deg, #f8f7ff 0%, #faf5ff 100%);
    border-bottom: 1px solid #ede9fe;
    padding: 10px 14px;
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
#alpro-dept-bar::-webkit-scrollbar { display: none; }
#alpro-dept-bar-inner {
    display: flex;
    gap: 7px;
    min-width: max-content;
}
.alpro-dept-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
    background: #fff;
    color: #6b7280;
    border-color: #e5e7eb;
}
.alpro-dept-chip:hover {
    border-color: #a5b4fc;
    color: #4f46e5;
    background: #eef2ff;
    transform: translateY(-1px);
}
.alpro-dept-chip.active {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 3px 10px rgba(79,70,229,0.35);
    transform: translateY(-1px);
}
.alpro-dept-chip i { font-size: 10px; }

/* ---- Messages Area ---- */
#alpro-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
    background: #f9f8ff;
}
#alpro-ai-messages::-webkit-scrollbar { width: 4px; }
#alpro-ai-messages::-webkit-scrollbar-track { background: transparent; }
#alpro-ai-messages::-webkit-scrollbar-thumb { background: #c4b5fd; border-radius: 10px; }

/* ---- Message Bubbles ---- */
.alpro-msg {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    animation: msgIn 0.28s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(12px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.alpro-msg.user { flex-direction: row-reverse; }

.alpro-msg-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}
.alpro-msg.bot .alpro-msg-avatar {
    background: linear-gradient(135deg,#4f46e5,#7c3aed);
    color: #fff;
}
.alpro-msg.user .alpro-msg-avatar {
    background: linear-gradient(135deg,#059669,#10b981);
    color: #fff;
}

.alpro-msg-bubble {
    max-width: 82%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.55;
    position: relative;
    word-break: break-word;
}
.alpro-msg.bot .alpro-msg-bubble {
    background: #fff;
    color: #1e1b4b;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 10px rgba(79,70,229,0.1);
    border: 1px solid #ede9fe;
}
.alpro-msg.user .alpro-msg-bubble {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    border-bottom-right-radius: 5px;
    box-shadow: 0 4px 14px rgba(79,70,229,0.35);
}

.alpro-msg-bubble strong { font-weight: 700; }
.alpro-msg-bubble ul { margin: 6px 0 0 16px; padding: 0; }
.alpro-msg-bubble li { margin-bottom: 4px; }
.alpro-msg-bubble p { margin: 0 0 6px; }
.alpro-msg-bubble p:last-child { margin-bottom: 0; }
.alpro-msg-bubble h4 {
    font-size: 13px;
    font-weight: 700;
    margin: 8px 0 5px;
    color: #4f46e5;
}
.alpro-msg.user .alpro-msg-bubble h4 { color: #c7d2fe; }
.alpro-msg-bubble code {
    background: rgba(79,70,229,0.1);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
}
.alpro-msg.user .alpro-msg-bubble code { background: rgba(255,255,255,0.2); }

.alpro-msg-time {
    font-size: 10px;
    color: #a0a0b8;
    margin-top: 4px;
    padding: 0 4px;
}
.alpro-msg.user .alpro-msg-time { text-align: right; }

/* Typing Indicator */
.alpro-typing-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
}
.alpro-typing-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #a5b4fc;
    animation: typingDot 1.2s infinite;
}
.alpro-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.alpro-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
    0%,60%,100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Quick Suggestions */
#alpro-ai-suggestions {
    padding: 8px 14px 6px;
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    border-top: 1px solid #f3f0ff;
    flex-shrink: 0;
    background: #faf8ff;
}
.alpro-suggestion-chip {
    font-size: 11.5px;
    padding: 5px 11px;
    border-radius: 14px;
    border: 1.5px solid #c4b5fd;
    color: #5b21b6;
    background: #f5f3ff;
    cursor: pointer;
    transition: all 0.18s;
    white-space: nowrap;
    font-weight: 500;
}
.alpro-suggestion-chip:hover {
    background: #4f46e5;
    color: #fff;
    border-color: #4f46e5;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(79,70,229,0.3);
}

/* ---- Input Area ---- */
#alpro-ai-input-area {
    padding: 12px 14px 14px;
    border-top: 1px solid #ede9fe;
    background: #fff;
    flex-shrink: 0;
}
#alpro-ai-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
#alpro-ai-input {
    flex: 1;
    border: 2px solid #e0d9ff;
    border-radius: 16px;
    padding: 11px 16px;
    font-size: 13.5px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 110px;
    min-height: 44px;
    line-height: 1.45;
    color: #1e1b4b;
    background: #f9f8ff;
    transition: border-color 0.2s, box-shadow 0.2s;
    scrollbar-width: thin;
}
#alpro-ai-input:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
    background: #fff;
}
#alpro-ai-input::placeholder { color: #a094c5; }

#alpro-ai-send {
    width: 44px; height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(79,70,229,0.4);
}
#alpro-ai-send:hover { transform: scale(1.08); box-shadow: 0 6px 18px rgba(79,70,229,0.5); }
#alpro-ai-send:active { transform: scale(0.94); }
#alpro-ai-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

#alpro-ai-footer-note {
    text-align: center;
    font-size: 10px;
    color: #b0a8cc;
    margin-top: 7px;
    letter-spacing: 0.02em;
}
#alpro-ai-footer-note span { color: #7c3aed; font-weight: 600; }

/* ---- Dept Context Banner ---- */
#alpro-dept-context {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(90deg, #eef2ff, #f5f3ff);
    border-bottom: 1px solid #e0e7ff;
    font-size: 11.5px;
    color: #4338ca;
    font-weight: 600;
    flex-shrink: 0;
    transition: all 0.3s;
}
#alpro-dept-context i { color: #7c3aed; }
#alpro-dept-context.hidden { display: none; }

/* ---- Welcome Card ---- */
.alpro-welcome-card {
    background: linear-gradient(135deg, #f5f3ff, #eef2ff);
    border: 1px solid #ddd6fe;
    border-radius: 16px;
    padding: 16px;
    text-align: center;
}
.alpro-welcome-card h3 {
    font-size: 15px;
    font-weight: 700;
    color: #4f46e5;
    margin: 0 0 6px;
}
.alpro-welcome-card p {
    font-size: 12.5px;
    color: #6b7280;
    margin: 0 0 12px;
    line-height: 1.5;
}
.alpro-welcome-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    text-align: left;
    margin-top: 10px;
}
.alpro-welcome-feat {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11.5px;
    color: #5b21b6;
    font-weight: 500;
    background: rgba(255,255,255,0.7);
    padding: 7px 10px;
    border-radius: 10px;
}
.alpro-welcome-feat i { font-size: 13px; color: #7c3aed; }

/* ---- Insight Cards ---- */
.alpro-insight-card {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border: 1px solid #bbf7d0;
    border-left: 4px solid #22c55e;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 12px;
    color: #166534;
    margin-top: 8px;
}
.alpro-insight-card.warning {
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    border-color: #fcd34d;
    border-left-color: #f59e0b;
    color: #92400e;
}
.alpro-insight-card.info {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border-color: #bfdbfe;
    border-left-color: #3b82f6;
    color: #1e40af;
}

/* ---- Action Buttons ---- */
.alpro-action-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.alpro-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    padding: 5px 12px;
    border-radius: 10px;
    border: 1.5px solid #a5b4fc;
    color: #4f46e5;
    background: #eef2ff;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.18s;
    text-decoration: none;
}
.alpro-action-btn:hover {
    background: #4f46e5;
    color: #fff;
    border-color: #4f46e5;
    transform: translateY(-1px);
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
    #alpro-ai-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 24px 24px 0 0;
        height: 88vh;
        max-height: 88vh;
    }
    #alpro-ai-fab { bottom: 20px; right: 18px; }
    #alpro-ai-fab-label { display: none; }
}

/* ---- Settings Panel ---- */
#alpro-ai-settings {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #fff;
    z-index: 10;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    border-radius: 24px;
    overflow: hidden;
}
#alpro-ai-settings.open { transform: translateX(0); }

.alpro-settings-header {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    padding: 18px 20px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
}
.alpro-settings-header h4 { margin: 0; font-size: 16px; font-weight: 700; flex: 1; }
.alpro-settings-body { flex: 1; overflow-y: auto; padding: 20px; }

.alpro-settings-section h5 {
    font-size: 12px;
    font-weight: 700;
    color: #7c3aed;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0 0 10px;
}
.alpro-settings-section { margin-bottom: 20px; }

.alpro-api-key-input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e0d9ff;
    border-radius: 12px;
    font-size: 13px;
    color: #1e1b4b;
    outline: none;
    font-family: monospace;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.alpro-api-key-input:focus { border-color: #7c3aed; }

.alpro-save-btn {
    width: 100%;
    padding: 11px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 8px;
    transition: opacity 0.2s;
}
.alpro-save-btn:hover { opacity: 0.9; }

.alpro-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f3f0ff;
}
.alpro-toggle-label { font-size: 13px; color: #374151; }
.alpro-toggle {
    width: 40px; height: 22px;
    border-radius: 11px;
    background: #e5e7eb;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}
.alpro-toggle.on { background: #4f46e5; }
.alpro-toggle::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.alpro-toggle.on::after { transform: translateX(18px); }

/* ---- Smooth stream effect ---- */
.alpro-streaming::after {
    content: '▋';
    animation: blink 0.7s infinite;
    margin-left: 2px;
    color: #7c3aed;
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* ---- Login Gate — ARIA hidden until authenticated ---- */
/* Default: container is hidden via JS (style.display='none').
   CSS reinforces this so it cannot be un-hidden via DevTools class removal alone. */
#alpro-ai-container:not(.aria-logged-in) {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
}
