/**
 * SkillSum Innovations - AI Agent Floating Widget Stylesheet
 * High performance, accessible, responsive, premium olive brand aesthetics
 */

:root {
    --ss-ai-primary: #556b2f;
    --ss-ai-primary-dark: #3e4f21;
    --ss-ai-primary-light: #6b8e23;
    --ss-ai-accent: #9bcc60;
    --ss-ai-bg: #ffffff;
    --ss-ai-surface: #f7f9f5;
    --ss-ai-text: #1f2421;
    --ss-ai-muted: #647067;
    --ss-ai-border: rgba(85, 107, 47, 0.16);
    --ss-ai-shadow: 0 18px 45px rgba(0, 0, 0, 0.16), 0 2px 10px rgba(85, 107, 47, 0.08);
    --ss-ai-bot-bubble: #f3f6f0;
    --ss-ai-user-bubble: linear-gradient(135deg, #556b2f, #6b8e23);
    --ss-ai-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ==========================================================================
   Widget Container & Launcher
   ========================================================================== */
.ss-ai-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 99999;
    font-family: var(--ss-ai-font);
    line-height: 1.5;
    box-sizing: border-box;
}

.ss-ai-widget *,
.ss-ai-widget *::before,
.ss-ai-widget *::after {
    box-sizing: inherit;
}

/* Floating Launcher Button */
.ss-ai-launcher {
    position: relative;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: linear-gradient(135deg, #556b2f, #6b8e23);
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 8px 25px rgba(85, 107, 47, 0.42);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    padding: 0;
    margin-right: 100px;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
    outline: none;
    user-select: none;
}

.ss-ai-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 30px rgba(85, 107, 47, 0.55);
}

.ss-ai-launcher:focus-visible {
    box-shadow: 0 0 0 4px rgba(155, 204, 96, 0.6), 0 8px 25px rgba(85, 107, 47, 0.4);
}

.ss-ai-launcher-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

/* Status indicator pulse on launcher */
.ss-ai-badge-pulse {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background-color: #28a745;
    border: 2px solid #ffffff;
    border-radius: 50%;
}

.ss-ai-badge-pulse::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #28a745;
    animation: ssAiRipple 2.2s infinite ease-out;
}

@keyframes ssAiRipple {
    0% { transform: scale(1); opacity: 0.9; }
    100% { transform: scale(2.2); opacity: 0; }
}

/* Tooltip on Desktop */
.ss-ai-launcher-tooltip {
    position: absolute;
    right: calc(100% + 14px);
    top: 50%;
    transform: translateY(-50%);
    background: #1f2421;
    color: #ffffff;
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.ss-ai-launcher:hover .ss-ai-launcher-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(-4px);
}

/* ==========================================================================
   Chat Window Container
   ========================================================================== */
.ss-ai-window,
.ss-ai-window *,
.ss-ai-window *::before,
.ss-ai-window *::after {
    box-sizing: border-box;
}

.ss-ai-window {
    font-family: var(--ss-ai-font);
    position: absolute;
    bottom: 78px;
    right: 0;
    width: 390px;
    max-width: calc(100vw - 32px);
    height: 590px;
    max-height: calc(100vh - 120px);
    background: var(--ss-ai-bg);
    border-radius: 22px;
    border: 1px solid var(--ss-ai-border);
    box-shadow: var(--ss-ai-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.ss-ai-window.ss-ai-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Standalone Full-Page / Embedded Mode */
.ss-ai-window.ss-ai-standalone {
    position: relative;
    bottom: auto;
    right: auto;
    width: 100%;
    max-width: 100%;
    height: 700px;
    max-height: 82vh;
    opacity: 1;
    transform: none;
    pointer-events: all;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
}

@media (max-width: 768px) {
    .ss-ai-window.ss-ai-standalone {
        height: 600px;
        max-height: 75vh;
        border-radius: 16px;
    }
}

/* ==========================================================================
   Chat Header
   ========================================================================== */
.ss-ai-header {
    background: linear-gradient(135deg, #556b2f, #3b4c1f);
    color: #ffffff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

.ss-ai-header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ss-ai-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #ffffff;
    flex-shrink: 0;
}

.ss-ai-status-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #28a745;
    border: 2px solid #556b2f;
}

.ss-ai-title-wrap {
    display: flex;
    flex-direction: column;
}

.ss-ai-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.ss-ai-subtitle {
    font-size: 0.76rem;
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
}

.ss-ai-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ss-ai-btn-icon {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    outline: none;
}

.ss-ai-btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.ss-ai-btn-icon:focus-visible {
    box-shadow: 0 0 0 2px #ffffff;
}

/* ==========================================================================
   Messages Area
   ========================================================================== */
.ss-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: #fafbf9;
    scroll-behavior: smooth;
}

.ss-ai-messages::-webkit-scrollbar {
    width: 5px;
}

.ss-ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ss-ai-messages::-webkit-scrollbar-thumb {
    background: rgba(85, 107, 47, 0.2);
    border-radius: 10px;
}

/* Individual Message Row */
.ss-ai-msg-row {
    display: flex;
    width: 100%;
}

.ss-ai-msg-row.ss-ai-bot {
    justify-content: flex-start;
}

.ss-ai-msg-row.ss-ai-user {
    justify-content: flex-end;
}

.ss-ai-msg-content {
    max-width: 86%;
    display: flex;
    flex-direction: column;
}

.ss-ai-msg-row.ss-ai-bot .ss-ai-msg-content {
    align-items: flex-start;
}

.ss-ai-msg-row.ss-ai-user .ss-ai-msg-content {
    align-items: flex-end;
}

/* Bot Message Bubble */
.ss-ai-msg-row.ss-ai-bot .ss-ai-bubble {
    background: var(--ss-ai-bg);
    color: var(--ss-ai-text);
    border: 1px solid rgba(85, 107, 47, 0.14);
    border-radius: 18px 18px 18px 4px;
    padding: 12px 15px;
    font-size: 0.91rem;
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    word-break: break-word;
}

.ss-ai-bubble strong {
    color: #1f2421;
}

.ss-ai-bubble a {
    color: var(--ss-ai-primary);
    text-decoration: underline;
    font-weight: 600;
}

.ss-ai-bubble a:hover {
    color: var(--ss-ai-primary-light);
}

/* User Message Bubble */
.ss-ai-msg-row.ss-ai-user .ss-ai-bubble {
    background: var(--ss-ai-user-bubble);
    color: #ffffff;
    border-radius: 18px 18px 4px 18px;
    padding: 11px 15px;
    font-size: 0.91rem;
    line-height: 1.45;
    box-shadow: 0 4px 12px rgba(85, 107, 47, 0.25);
    word-break: break-word;
}

/* Timestamps */
.ss-ai-time {
    font-size: 0.70rem;
    color: var(--ss-ai-muted);
    margin-top: 4px;
    padding: 0 4px;
}

/* ==========================================================================
   Typing Indicator
   ========================================================================== */
.ss-ai-typing-wrap {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    background: var(--ss-ai-bg);
    border: 1px solid rgba(85, 107, 47, 0.12);
    border-radius: 18px 18px 18px 4px;
    width: fit-content;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.ss-ai-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--ss-ai-primary);
    animation: ssAiBounce 1.4s infinite ease-in-out both;
}

.ss-ai-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ss-ai-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes ssAiBounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   Quick Action Chips Bar
   ========================================================================== */
.ss-ai-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 14px 10px;
    background: #fafbf9;
    border-top: 1px solid rgba(85, 107, 47, 0.08);
    max-height: 110px;
    overflow-y: auto;
}

.ss-ai-chip {
    background: #ffffff;
    color: var(--ss-ai-primary);
    border: 1px solid rgba(85, 107, 47, 0.25);
    border-radius: 50rem;
    padding: 5px 12px;
    font-size: 0.81rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    outline: none;
}

.ss-ai-chip:hover {
    background: var(--ss-ai-primary);
    color: #ffffff;
    border-color: var(--ss-ai-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(85, 107, 47, 0.2);
}

.ss-ai-chip:focus-visible {
    box-shadow: 0 0 0 2px var(--ss-ai-accent);
}

/* ==========================================================================
   Input Form & Footer
   ========================================================================== */
.ss-ai-input-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 14px;
    background: #ffffff;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

.ss-ai-textarea {
    flex: 1;
    border: 1px solid #d5decb;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 0.90rem;
    font-family: inherit;
    line-height: 1.4;
    resize: none;
    max-height: 110px;
    min-height: 40px;
    outline: none;
    background: #fafbf9;
    color: var(--ss-ai-text);
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}

.ss-ai-textarea:focus {
    border-color: var(--ss-ai-primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(85, 107, 47, 0.15);
}

.ss-ai-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--ss-ai-primary);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
    outline: none;
    padding: 0;
}

.ss-ai-send-btn:hover:not(:disabled) {
    background: var(--ss-ai-primary-light);
    transform: scale(1.05);
}

.ss-ai-send-btn:disabled {
    background: #d3dbca;
    cursor: not-allowed;
    opacity: 0.8;
}

.ss-ai-send-btn:focus-visible {
    box-shadow: 0 0 0 3px var(--ss-ai-accent);
}

.ss-ai-footer-note {
    font-size: 0.70rem;
    color: var(--ss-ai-muted);
    text-align: center;
    padding: 4px 10px 8px;
    background: #ffffff;
    user-select: none;
    border-top: 1px solid rgba(0, 0, 0, 0.03);
}

/* ==========================================================================
   Mobile Viewport Styles (Screen <= 576px)
   ========================================================================== */
@media (max-width: 576px) {
    .ss-ai-widget {
        right: 18px;
        bottom: 18px;
    }

    .ss-ai-launcher {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }

    .ss-ai-launcher-tooltip {
        display: none !important;
    }

    .ss-ai-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        border: none;
        box-shadow: none;
        z-index: 100000;
    }

    .ss-ai-header {
        padding: 16px 18px;
        border-radius: 0;
    }

    .ss-ai-msg-content {
        max-width: 90%;
    }
}
