/**
 * AJJO Assistant Widget для Bitrix24
 * Стили для виджета анализа сообщений
 * Версия 1.0.0
 */

/* ==================== Блок интента ==================== */

.ajjo-intent-block {
    margin-top: 10px;
    width: 100%;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.ajjo-intent-block:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

/* ==================== Заголовок интента ==================== */

.ajjo-intent-header {
    background: #ffffff;
    padding: 0;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-weight: 500;
    border: 2px solid;
    display: flex;
    align-items: center;
    overflow: hidden;
    transition: all 0.3s ease;
}

.ajjo-intent-header:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.ajjo-intent-header[data-expanded="true"] {
    border-radius: 8px 8px 0 0;
}

/* ==================== Бейдж AJJO ==================== */

.ajjo-badge {
    letter-spacing: 1px;
    padding: 4px 10px;
    color: white;
    font-weight: bold;
    font-size: 11px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    border-radius: 5px 0 0 5px;
    margin-right: 12px;
}

/* ==================== Секция заголовка ==================== */

.ajjo-intent-title-section {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
}

/* ==================== Действия (лайк/дизлайк) ==================== */

.ajjo-intent-actions {
    display: flex;
    gap: 8px;
}

.ajjo-like-btn,
.ajjo-dislike-btn {
    cursor: pointer;
    opacity: 0.7;
    border-radius: 5px;
    padding: 4px 8px;
    transition: all 0.2s ease;
    border: 1px solid rgba(0, 0, 0, 0.15);
    background: #f9f9f9;
    font-size: 16px;
}

.ajjo-like-btn:hover {
    opacity: 1;
    border-color: rgba(40, 167, 69, 0.5);
    background: rgba(40, 167, 69, 0.1);
    transform: scale(1.1);
}

.ajjo-dislike-btn:hover {
    opacity: 1;
    border-color: rgba(220, 53, 69, 0.5);
    background: rgba(220, 53, 69, 0.1);
    transform: scale(1.1);
}

.ajjo-like-btn.ajjo-active {
    color: #28a745;
    border-color: #28a745;
    background: rgba(40, 167, 69, 0.15);
    cursor: default;
    opacity: 1;
}

.ajjo-dislike-btn.ajjo-active {
    color: #dc3545;
    border-color: #dc3545;
    background: rgba(220, 53, 69, 0.15);
    cursor: default;
    opacity: 1;
}

/* ==================== Загрузка ==================== */

.ajjo-loading-spinner {
    display: inline-block;
    animation: ajjo-spin 1s linear infinite;
}

@keyframes ajjo-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* ==================== Сообщение обратной связи ==================== */

.ajjo-feedback-message {
    color: #28a745;
    font-weight: 500;
    font-size: 13px;
    animation: ajjo-fadeInOut 2s ease-in-out;
}

@keyframes ajjo-fadeInOut {
    0% {
        opacity: 0;
    }
    20% {
        opacity: 1;
    }
    80% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* ==================== Контент интента ==================== */

.ajjo-intent-content {
    display: none;
    background: #ffffff;
    padding: 14px;
    border-radius: 0 0 8px 8px;
    border-top: 1px solid #e0e0e0;
}

.ajjo-intent-alert {
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.6;
    color: #333;
    margin-bottom: 12px;
}

/* ==================== Блок примера ==================== */

.ajjo-example-block {
    border: 1px solid rgba(0, 0, 0, 0.15);
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    margin-top: 12px;
}

.ajjo-example-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.ajjo-example-title {
    color: #28a745;
    font-weight: bold;
    font-size: 14px;
}

.ajjo-example-text {
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.5;
    color: #333;
}

.ajjo-copy-btn {
    padding: 6px 12px;
    font-size: 12px;
    white-space: nowrap;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.2);
    color: #333;
    transition: all 0.2s ease;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
}

.ajjo-copy-btn:hover {
    background: #28a745;
    border-color: #28a745;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

.ajjo-copy-btn:active {
    transform: translateY(0);
}

/* ==================== Светофор для исходящих сообщений ==================== */

.ajjo-traffic-light-container {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 15px;
    background: #ffffff;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-right: 12px;
    position: relative;
    transition: all 0.3s ease;
}

.ajjo-traffic-light-container:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.25);
}

.ajjo-label {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #9e9e9e;
    transition: color 0.3s ease;
    user-select: none;
    cursor: pointer;
}

.ajjo-label.ajjo-red {
    color: #ef5350;
}

.ajjo-label.ajjo-yellow {
    color: #ffca28;
}

.ajjo-label.ajjo-green {
    color: #66bb6a;
}

.ajjo-indicator-wrapper {
    position: relative;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.ajjo-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #9e9e9e;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ajjo-indicator.ajjo-red {
    background: #ef5350;
    box-shadow: 0 0 10px rgba(239, 83, 80, 0.4);
}

.ajjo-indicator.ajjo-yellow {
    background: #ffca28;
    box-shadow: 0 0 10px rgba(255, 202, 40, 0.4);
}

.ajjo-indicator.ajjo-green {
    background: #66bb6a;
    box-shadow: 0 0 10px rgba(102, 187, 106, 0.4);
}

.ajjo-loader {
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top-color: #3f51b5;
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 0;
    animation: ajjo-spin 1s linear infinite;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.ajjo-loader.ajjo-active {
    opacity: 1;
}

/* ==================== Тултип для индикатора ==================== */

.ajjo-indicator-tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 0;
    background: #ffffff;
    border-radius: 6px;
    padding: 12px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 13px;
    color: #333;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: translateY(5px);
    z-index: 10000;
    max-width: 400px;
    min-width: 250px;
    line-height: 1.5;
}

.ajjo-indicator-tooltip::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 20px;
    border: 6px solid transparent;
    border-top-color: #ffffff;
}

.ajjo-indicator-tooltip.ajjo-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* ==================== Настройки ==================== */

.ajjo-settings-btn {
    width: 20px;
    height: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    opacity: 0.6;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.ajjo-settings-btn:hover {
    opacity: 1;
    transform: rotate(90deg);
}

.ajjo-settings-icon {
    width: 18px;
    height: 18px;
    fill: #757575;
    transition: fill 0.2s ease;
}

.ajjo-settings-btn:hover .ajjo-settings-icon {
    fill: #424242;
}

/* ==================== Поддержка темной темы Битрикс24 ==================== */

.bx-dark-theme .ajjo-intent-block {
    background: #1a1a2e;
    border-color: #2a2a3e;
}

.bx-dark-theme .ajjo-intent-header {
    background: #1a1a2e;
}

.bx-dark-theme .ajjo-intent-content {
    background: #1a1a2e;
    border-top-color: #2a2a3e;
}

.bx-dark-theme .ajjo-intent-alert,
.bx-dark-theme .ajjo-example-text {
    color: #e0e0e0;
}

.bx-dark-theme .ajjo-example-block {
    background: #0e1621;
    border-color: #2a2a3e;
}

.bx-dark-theme .ajjo-copy-btn {
    background: #1a1a2e;
    border-color: #2a2a3e;
    color: #e0e0e0;
}

.bx-dark-theme .ajjo-copy-btn:hover {
    background: #28a745;
    border-color: #28a745;
    color: #ffffff;
}

.bx-dark-theme .ajjo-traffic-light-container {
    background: #1a1a2e;
    border-color: #2a2a3e;
}

.bx-dark-theme .ajjo-indicator-tooltip {
    background: #1a1a2e;
    border-color: #2a2a3e;
    color: #e0e0e0;
}

.bx-dark-theme .ajjo-indicator-tooltip::before {
    border-top-color: #1a1a2e;
}

.bx-dark-theme .ajjo-like-btn,
.bx-dark-theme .ajjo-dislike-btn {
    background: #0e1621;
    border-color: #2a2a3e;
}

/* ==================== Адаптивность ==================== */

@media (max-width: 768px) {
    .ajjo-intent-block {
        margin-top: 8px;
    }

    .ajjo-intent-title-section {
        padding: 8px 10px;
        font-size: 13px;
    }

    .ajjo-badge {
        font-size: 10px;
        padding: 3px 8px;
    }

    .ajjo-intent-content {
        padding: 10px;
    }

    .ajjo-example-block {
        padding: 10px;
    }

    .ajjo-traffic-light-container {
        padding: 6px 12px;
        gap: 8px;
    }

    .ajjo-label {
        font-size: 12px;
    }

    .ajjo-indicator-wrapper {
        width: 18px;
        height: 18px;
    }

    .ajjo-indicator {
        width: 18px;
        height: 18px;
    }

    .ajjo-indicator-tooltip {
        max-width: 280px;
        min-width: 200px;
        font-size: 12px;
    }
}

/* ==================== Анимации появления ==================== */

.ajjo-intent-block {
    animation: ajjo-slideIn 0.3s ease-out;
}

@keyframes ajjo-slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ajjo-traffic-light-container {
    animation: ajjo-fadeIn 0.3s ease-out;
}

@keyframes ajjo-fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ==================== Состояния загрузки ==================== */

@keyframes ajjo-pulse {
    0% {
        opacity: 0.5;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.5;
    }
}

.ajjo-intent-block.ajjo-loading {
    animation: ajjo-pulse 1.5s ease-in-out infinite;
}

/* ==================== Улучшенная типографика ==================== */

.ajjo-intent-block,
.ajjo-traffic-light-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ==================== Доступность ==================== */

.ajjo-like-btn:focus,
.ajjo-dislike-btn:focus,
.ajjo-copy-btn:focus,
.ajjo-settings-btn:focus {
    outline: 2px solid #3f51b5;
    outline-offset: 2px;
}

.ajjo-intent-header:focus {
    outline: 2px solid #3f51b5;
    outline-offset: 2px;
}

/* ==================== Печать ==================== */

@media print {
    .ajjo-traffic-light-container {
        display: none;
    }

    .ajjo-intent-block {
        page-break-inside: avoid;
    }

    .ajjo-intent-actions {
        display: none;
    }
}
