/* --- Variables --- */
:root {
    --iaf-blue: #2187FF;
    --iaf-blue-hover: #1a70d9;
    --iaf-bg-dark: #1c1c1e;
    --iaf-bg-darker: #000000;
    --iaf-border: #38383a;
    --iaf-text: #ffffff;
    --iaf-text-dim: #8e8e93;
    --iaf-radius: 18px;
    --iaf-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* --- Inline Trigger Button --- */
.iaf-trigger-btn {
    background-color: var(--iaf-blue);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 500;
    border-radius: 999px;
    /* Pill shape */
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(33, 135, 255, 0.3);
    font-family: var(--iaf-font);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-transform: none;
    line-height: normal;
}

.iaf-trigger-btn:hover {
    background-color: var(--iaf-blue-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(33, 135, 255, 0.4);
}

/* --- Chat Widget Container --- */
.iaf-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 600px;
    max-height: 80vh;
    background-color: rgba(28, 28, 30, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    z-index: 999999;
    font-family: var(--iaf-font);

    /* Animation State: Hidden */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
}

.iaf-widget-container.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .iaf-widget-container {
        width: 100%;
        height: 100%;
        /* Full screen on super small devices or stick to bottom */
        bottom: 0;
        right: 0;
        border-radius: 24px 24px 0 0;
        max-height: 90vh;
    }
}

/* --- Header --- */
.iaf-header {
    padding: 16px;
    border-bottom: 1px solid var(--iaf-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(28, 28, 30, 0.5);
    border-radius: 24px 24px 0 0;
}

.iaf-header-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.iaf-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #007AFF 0%, #00C6FF 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.iaf-avatar svg {
    width: 24px;
    fill: white;
}

.iaf-status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #34c759;
    border: 2px solid var(--iaf-bg-dark);
    border-radius: 50%;
}

.iaf-header-text {
    display: flex;
    flex-direction: column;
}

.iaf-title {
    color: white;
    font-weight: 600;
    font-size: 15px;
}

.iaf-subtitle {
    color: var(--iaf-text-dim);
    font-size: 12px;
}

.iaf-close-btn {
    background: transparent;
    border: none;
    color: var(--iaf-text-dim);
    cursor: pointer;
    padding: 4px;
    display: flex;
    transition: color 0.2s;
}

.iaf-close-btn:hover {
    color: white;
}

/* --- Chat Area --- */
.iaf-chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Scrollbar */
.iaf-chat-area::-webkit-scrollbar {
    width: 5px;
}

.iaf-chat-area::-webkit-scrollbar-thumb {
    background: var(--iaf-border);
    border-radius: 10px;
}

/* Messages */
.iaf-message {
    padding: 10px 16px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.4;
    max-width: 85%;
    animation: iaf-slide-up 0.3s ease-out;
    word-wrap: break-word;
}

@keyframes iaf-slide-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.iaf-message.ai {
    background: var(--iaf-bg-dark);
    color: white;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.iaf-message.user {
    background: var(--iaf-blue);
    color: white;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

/* Typing Indicator */
.iaf-typing {
    padding: 12px 16px;
    background: var(--iaf-bg-dark);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    display: flex;
    gap: 4px;
}

.iaf-dot {
    width: 6px;
    height: 6px;
    background: var(--iaf-text-dim);
    border-radius: 50%;
    animation: iaf-pulse 1s infinite alternate;
}

.iaf-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.iaf-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes iaf-pulse {
    from {
        opacity: 0.4;
    }

    to {
        opacity: 1;
    }
}

/* --- Input Area --- */
.iaf-input-area {
    padding: 16px;
    border-top: 1px solid var(--iaf-border);
    background: rgba(28, 28, 30, 0.5);
}

.iaf-input-wrapper {
    display: flex;
    gap: 8px;
}

.iaf-input-wrapper input {
    flex: 1;
    background: #2c2c2e;
    border: none;
    border-radius: 20px;
    padding: 10px 16px;
    color: white;
    font-size: 15px;
    outline: none;
}

.iaf-input-wrapper input:focus {
    box-shadow: 0 0 0 2px var(--iaf-blue);
}

.iaf-input-wrapper button {
    background: var(--iaf-blue);
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.iaf-input-wrapper button:disabled {
    background: #3a3a3c;
    cursor: not-allowed;
}

.iaf-input-wrapper button:hover:not(:disabled) {
    transform: scale(1.05);
}

/* Options */
.iaf-options-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 0;
}

.iaf-options-wrapper:not(:empty) {
    margin-top: 10px;
}

.iaf-option-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--iaf-border);
    color: white;
    padding: 8px 14px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.iaf-option-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.iaf-option-btn.selected {
    background: var(--iaf-blue);
    border-color: var(--iaf-blue);
}

.iaf-confirm-btn {
    width: 100%;
    background: white;
    color: black;
    border: none;
    padding: 10px;
    border-radius: 12px;
    font-weight: 600;
    margin-top: 5px;
    cursor: pointer;
}

/* Rec Card */
.iaf-rec-card {
    background: #2c2c2e;
    border: 1px solid var(--iaf-border);
    padding: 16px;
    border-radius: 16px;
    margin-top: 8px;
}

.iaf-rec-title {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 8px;
    color: #0d87ff;
}

.iaf-rec-text {
    font-size: 14px;
    color: #e5e5ea;
    margin-bottom: 8px;
}

.iaf-rec-alt {
    border-top: 1px solid var(--iaf-border);
    padding-top: 8px;
    font-size: 12px;
    color: var(--iaf-text-dim);
}