/**
 * Agent Chat Sidebar Styles
 *
 * Styles for the agent chat widget in the profile sidebar.
 * Uses AI brand colors for consistency with React AI components.
 * Supports RTL layout via [dir='rtl'] selectors.
 */
/**
 * AI Brand Variables
 *
 * Shared color variables for AI widgets.
 * Consistent with app-react/client/src/styles/ai-colors.ts
 */
.genai-icon {
    display: inline-flex;
    align-items: center;
}

.genai-icon svg {
    display: inline-block;
    vertical-align: middle;
    fill: #c218f4;
    width: 1em;
    height: 1em;
}

.genai-icon--loading {
    animation: genai-icon-pulse 1.5s ease-in-out infinite;
}

.genai-icon--lg svg {
    width: 48px;
    height: 48px;
}

@keyframes genai-icon-pulse {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

.agent-widget {
    margin-top: 1rem;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    background: #f5f5f5;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
}

.agent-widget::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #c218f4 0%, #ff6b00 100%);
    border-radius: 8px 8px 0 0;
    z-index: 1;
}

.agent-widget__header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #d9d9d9;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #fff;
}

.agent-widget__header > i:first-child {
    color: #c218f4;
    font-size: 1.1em;
}

.agent-widget__icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: #c218f4;
    transition: transform 0.3s ease;
}

.agent-widget__icon--loading {
    animation: genai-icon-pulse 1.5s ease-in-out infinite;
}

.agent-widget__title {
    flex-shrink: 0;
}

.agent-widget__title-expanded {
    flex-shrink: 0;
    display: none;
}

.agent-widget__context {
    display: none;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85em;
    font-weight: 500;
    color: #c218f4;
    background: rgba(194, 24, 244, 0.08);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    margin-inline-start: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-widget__context i {
    font-size: 0.9em;
    flex-shrink: 0;
}

.agent-widget__expand {
    flex-shrink: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 4px;
    color: #666;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.agent-widget__expand:hover {
    background: #f0f0f0;
    color: #c218f4;
}

.agent-widget__expand:focus {
    outline: 2px solid #c218f4;
    outline-offset: 2px;
}

.agent-widget__messages {
    max-height: 300px;
    min-height: 100px;
    overflow-y: auto;
    padding: 0.75rem;
    background: #f5f5f5;
}

.agent-widget__messages::-webkit-scrollbar {
    width: 6px;
}

.agent-widget__messages::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 3px;
}

.agent-widget__messages::-webkit-scrollbar-thumb {
    background: #d9d9d9;
    border-radius: 3px;
}

.agent-widget__messages::-webkit-scrollbar-thumb:hover {
    background: #666;
}

.agent-widget__input {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid #d9d9d9;
    background: #fff;
}

.agent-widget__input textarea {
    flex: 1;
    resize: none;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    padding: 0.5rem;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.5;
    min-height: 36px;
    max-height: 100px;
    background: #fff;
    color: #333;
    transition: border-color 0.2s ease;
}

.agent-widget__input textarea::placeholder {
    color: #666;
}

.agent-widget__input textarea:focus {
    outline: none;
    border-color: #c218f4;
    box-shadow: 0 0 0 2px rgba(194, 24, 244, 0.15);
}

.agent-widget__input textarea:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.agent-widget__input button,
.agent-widget__send {
    align-self: flex-end;
    flex-shrink: 0;
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(90deg, #c218f4 0%, #ff6b00 100%) !important;
    border: none !important;
    border-radius: 4px;
    color: #fff !important;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.agent-widget__input button:hover:not(:disabled),
.agent-widget__send:hover:not(:disabled) {
    opacity: 0.9;
    transform: scale(1.02);
    background: linear-gradient(90deg, #c218f4 0%, #ff6b00 100%) !important;
}

.agent-widget__input button:active:not(:disabled),
.agent-widget__send:active:not(:disabled) {
    transform: scale(0.98);
    background: linear-gradient(90deg, #c218f4 0%, #ff6b00 100%) !important;
}

.agent-widget__input button:disabled,
.agent-widget__send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.agent-widget__input button i,
.agent-widget__send i {
    font-size: 0.9em;
    color: #fff !important;
}

.agent-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem 1rem;
    height: 100%;
    min-height: 150px;
}

.agent-empty-state__icon {
    margin-bottom: 1rem;
}

.agent-empty-state__icon svg {
    fill: #999 !important;
    width: 48px !important;
    height: 48px !important;
}

.agent-empty-state__text {
    color: #666;
    font-size: 0.95rem;
    line-height: 1.6;
    max-width: 280px;
}

.agent-message-row {
    display: flex;
    width: 100%;
    margin-bottom: 0.5rem;
}

.agent-message-row:last-child {
    margin-bottom: 0;
}

.agent-message-row--user {
    justify-content: flex-end;
}

.agent-message-row--assistant {
    justify-content: flex-start;
}

.agent-message {
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 80%;
}

.agent-message--user {
    background: #fff;
    color: #333;
    border: 1px solid #d9d9d9;
}

.agent-message--assistant {
    background: linear-gradient(#fff, #fff) padding-box, linear-gradient(90deg, #c218f4 0%, #ff6b00 100%) border-box;
    border: 1px solid transparent;
    color: #333;
}

.agent-message--loading {
    text-align: center;
    color: #666;
    background: linear-gradient(#fff, #fff) padding-box, linear-gradient(90deg, #c218f4 0%, #ff6b00 100%) border-box;
    border: 1px solid transparent;
    padding: 0.75rem;
    max-width: 100%;
}

.agent-message--loading i {
    font-size: 1.2em;
    color: #c218f4;
}

.agent-entity-link {
    color: #c218f4;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s ease;
    cursor: pointer;
}

.agent-entity-link:hover {
    text-decoration: underline;
    color: #a20acf;
}

.agent-entity-link:active {
    color: #8f09b7;
}

.agent-entity-link:focus {
    outline: 2px solid #c218f4;
    outline-offset: 2px;
    border-radius: 2px;
}

.agent-interrupt {
    background: #fffbe6;
    border: 1px solid #ffe58f;
    border-radius: 8px;
    padding: 0.75rem;
    margin-top: 0.5rem;
    width: 100%;
}

.agent-interrupt__header {
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #d48806;
    font-size: 1em;
    line-height: 1.4;
}

.agent-interrupt__actions-list {
    margin-bottom: 1rem;
}

.agent-interrupt__action {
    background: #fff;
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.95em;
    color: #333;
    border: 1px solid #ffe58f;
}

.agent-interrupt__action:last-child {
    margin-bottom: 0;
}

.agent-interrupt__action-desc {
    color: #8c8c8c;
    font-weight: 400;
}

.agent-interrupt__buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 0.75rem;
}

.agent-interrupt__buttons .btn {
    padding: 0.5rem 1.5rem;
    font-size: 0.9em;
    border-radius: 6px;
}

.agent-interrupt__approve {
    background: #52c41a;
    border-color: #52c41a;
    color: #fff;
}

.agent-interrupt__approve:hover {
    background: #73d13d;
    border-color: #73d13d;
    color: #fff;
}

.agent-interrupt__reject {
    background: #fff;
    border-color: #d9d9d9;
    color: #333;
}

.agent-interrupt__reject:hover {
    border-color: #ff4d4f;
    color: #ff4d4f;
}

@media (max-width: 768px) {
    .agent-widget:not(.agent-widget--expanded) .agent-widget__messages {
        display: none;
    }

    .agent-widget.agent-widget--expanded .agent-widget__messages {
        display: block;
    }

    .agent-message {
        max-width: 90%;
    }
}

@keyframes agent-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.agent-message--loading .fa-spinner {
    animation: agent-spin 1s linear infinite;
}

.agent-widget.agent-widget--expanded {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 1050 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    background: #fff !important;
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
}

.agent-widget.agent-widget--expanded .agent-widget__header {
    border-radius: 0;
    padding: 1rem 1.5rem;
    font-size: 1.1em;
    flex-shrink: 0;
}

.agent-widget.agent-widget--expanded .agent-widget__title {
    display: none !important;
}

.agent-widget.agent-widget--expanded .agent-widget__title-expanded {
    display: block !important;
    flex-grow: 1;
}

.agent-widget.agent-widget--expanded .agent-widget__context {
    display: flex !important;
    flex-grow: 1;
}

.agent-widget.agent-widget--expanded .agent-widget__expand i::before {
    content: "\f066";
}

.agent-widget.agent-widget--expanded .agent-widget__messages {
    flex: 1 !important;
    max-height: none !important;
    min-height: 0;
    padding: 1.5rem;
    overflow-y: auto;
}

.agent-widget.agent-widget--expanded .agent-widget__input {
    padding: 1rem 1.5rem;
    flex-shrink: 0;
}

.agent-widget.agent-widget--expanded .agent-widget__input textarea {
    font-size: 1rem;
    padding: 0.75rem;
}

.agent-widget.agent-widget--expanded .agent-message {
    max-width: 70%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
}

.agent-widget-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.agent-widget-backdrop--visible {
    opacity: 1;
    visibility: visible;
}
