/* styles/tagging-service.css */
/* Стили для глобального TaggingService */

/* Wrapper контейнер */
.tagging-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    min-height: 38px;
    padding: 0 8px 0 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    transition:
        border-color 0.2s,
        box-shadow 0.2s;
}

.tagging-wrapper:focus-within {
    border-color: var(--border-hover);
    box-shadow: none;
}

/* Toggle кнопка */
.tagging-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    box-sizing: border-box;
    padding: 0;
    margin-right: 4px;
    background: transparent;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    /* [2026-09-18] Перечень вместо `all` (аудит Д1, закрытие хвоста).
       Ref: docs/AUDIT_UI_MOTION_2026-09-17.md Д1. Chat: ui-motion-fixes-2026-09-17. */
    transition:
        background-color 0.2s,
        border-color 0.2s,
        color 0.2s,
        box-shadow 0.2s,
        transform 0.2s;
    flex-shrink: 0;
}

.tagging-toggle i {
    font-size: 20px;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.tagging-toggle:hover {
    background: var(--bg-hover);
}

.tagging-toggle:focus-visible {
    outline: 1px solid var(--border-hover);
    outline-offset: -1px;
    box-shadow: none;
}

.tagging-toggle.active {
    background: var(--color-success-bg);
}

.tagging-toggle.active i {
    color: var(--color-success-text);
}

/* Input поле */
.tagging-input {
    flex: 1;
    min-width: 100px;
    padding: 4px 8px;
    border: none;
    background: transparent;
    font-size: 14px;
    outline: none;
}

.tagging-input::placeholder {
    color: var(--text-tertiary);
}

/* Ghost chips контейнер (legacy data inline with badges) */
.tagging-ghost-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.tagging-ghost-chips:empty {
    display: none;
}

/* Badges контейнер */
.tagging-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

/* Badge тега */
.tagging-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 12px;
    border: 1px solid;
    font-size: 12px;
    line-height: 1.4;
    white-space: nowrap;
}

.tagging-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tagging-badge-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tagging-badge-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    margin-left: 2px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0.6;
    transition:
        opacity 0.2s,
        background 0.2s;
}

.tagging-badge-remove:hover {
    opacity: 1;
    background: var(--bg-hover);
}

.tagging-badge-remove i {
    font-size: 14px;
}

/* Dropdown - теперь это flex контейнер для цепочки тегов */
.tagging-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tagging-dropdown.hidden {
    display: none;
}

/* Suggestion tag (badge style) */
.tagging-suggestion {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 14px;
    border: 1px solid;
    font-size: 13px;
    line-height: 1.3;
    cursor: pointer;
    transition: opacity var(--transition-fast);
    white-space: nowrap;
}

.tagging-suggestion:hover {
    opacity: 0.86;
}

.tagging-suggestion.active {
    font-weight: var(--font-weight-semibold);
    opacity: 1;
}

.tagging-suggestion-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tagging-suggestion-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tagging-empty {
    width: 100%;
    padding: 8px 12px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
}

/* Адаптация для маленьких экранов */
@media (width <= 600px) {
    .tagging-badge-name {
        max-width: 80px;
    }
}

/* ==========================================
   Стили для form-group (Create Activity Modal)
   Wrapper заменяет стили .input-field
   ========================================== */

/* Когда TaggingService обрамляет input-field, убираем стили с самого input */
.form-group .tagging-wrapper .input-field.tagging-input {
    width: auto !important;
    height: auto !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    padding: 4px 8px !important;
    box-shadow: none !important;
    outline: none !important;
}

.form-group .tagging-wrapper .input-field.tagging-input:focus {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Wrapper в form-group выглядит как input-field */
.form-group .tagging-wrapper {
    width: 100%;
    min-height: 38px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
}

.form-group .tagging-wrapper:focus-within {
    outline: none;
    box-shadow: none;
    background-color: var(--bg-primary);
    border-color: var(--border-hover);
}

/* ==========================================
   Специальные стили для Activity Modal Title
   ========================================== */

/* Wrapper в заголовке модалки - убираем бордер, делаем прозрачным */
.modal-title-editable .tagging-wrapper {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    gap: 6px;
    flex-wrap: nowrap; /* ✅ Не переносить на новую строку */
    min-height: auto;
    width: 100%;
}

.modal-title-editable .tagging-wrapper:focus-within {
    box-shadow: none;
}

.modal-title-editable .tagging-wrapper.tagging-enabled {
    border: none;
}

/* Toggle в заголовке сохраняет общий размер кнопки. */
.modal-title-editable .tagging-toggle {
    margin-right: 6px;
    border: none;
    background: transparent;
    flex-shrink: 0; /* ✅ Не сжимать кнопку */
    order: -1; /* ✅ Показывать первой */
}

.modal-title-editable .tagging-toggle:hover {
    background: var(--bg-hover);
}

.modal-title-editable .tagging-toggle.active {
    background: var(--color-success-bg);
}

/* Input в заголовке - сохраняем оригинальные стили modal-title-input */
.modal-title-editable .tagging-input {
    font-size: var(--font-size-xl, 1.25rem);
    font-weight: var(--font-weight-semibold, 600);
    color: var(--text-primary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 4px 8px;
    min-width: 0;
    transition:
        border-color 0.2s,
        background-color 0.2s;
}

.modal-title-editable .tagging-input:focus {
    background-color: var(--bg-secondary);
    border-color: var(--border-hover);
    box-shadow: none;
}

/* Badges в заголовке - меньше размер */
.modal-title-editable .tagging-badges {
    gap: 4px;
    flex-shrink: 0; /* ✅ Не сжимать badges */
    flex-wrap: nowrap;
}

.modal-title-editable .tagging-badge {
    font-size: 11px;
    padding: 1px 5px;
}

.modal-title-editable .tagging-badge-dot {
    width: 5px;
    height: 5px;
}

.modal-title-editable .tagging-badge-remove {
    width: 14px;
    height: 14px;
}

.modal-title-editable .tagging-badge-remove i {
    font-size: 12px;
}

/* Dropdown в заголовке */
.modal-title-editable .tagging-dropdown {
    margin-top: 8px;
    left: 0;
    right: auto;
    min-width: 280px;
}

/* ========================================
   Auto-tag Legacy Modal Styles
   ======================================== */

.autotag-legacy-modal {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.autotag-legacy-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.autotag-legacy-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    /* [2026-09-18] Перечень вместо `all` (аудит Д1).
       Ref: docs/AUDIT_UI_MOTION_2026-09-17.md Д1. Chat: ui-motion-fixes-2026-09-17. */
    transition:
        background-color 0.2s,
        border-color 0.2s,
        color 0.2s,
        box-shadow 0.2s,
        transform 0.2s;
}

.autotag-legacy-option:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-hover);
}

.autotag-legacy-option input[type='checkbox'] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    cursor: pointer;
}

.autotag-legacy-option span {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
}

.autotag-legacy-option strong {
    color: var(--text-primary);
}

/* ========================================
   Auto-tag Progress Styles (shared)
   ======================================== */

.autotag-progress {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 350px;
}

.autotag-progress-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
    text-align: center;
}

/* Spinner animation */
.autotag-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-primary);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    /* [2026-09-18] Д10: скорость — из общего токена (значение прежнее).
       Ref: docs/AUDIT_UI_MOTION_2026-09-17.md Д10. Chat: ui-motion-fixes-2026-09-17. */
    animation: autotag-spin var(--spinner-duration) linear infinite;
}

@keyframes autotag-spin {
    to {
        transform: rotate(360deg);
    }
}

.autotag-progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 999px;
    overflow: hidden;
}

.autotag-progress-bar {
    height: 100%;
    background: var(--brand-primary);
    border-radius: 999px;
}

/* Animated progress bar with stripes */
.autotag-progress-bar-animated {
    background: linear-gradient(
        90deg,
        var(--brand-primary) 0%,
        var(--brand-primary-light) 50%,
        var(--brand-primary) 100%
    );
    background-size: 200% 100%;
    animation: autotag-progress-shimmer 1.5s ease-in-out infinite;
}

@keyframes autotag-progress-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.autotag-progress-status {
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.autotag-progress-current {
    text-align: center;
    font-size: 13px;
    color: var(--text-tertiary);
    min-height: 1.25rem;
}

.autotag-progress-log {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
    font-size: 12px;
    padding: 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.autotag-log-success {
    color: var(--color-success-text);
}

.autotag-log-error {
    color: var(--color-error-text);
}

.autotag-progress-buttons {
    display: flex;
    justify-content: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-primary);
}

.autotag-progress-summary {
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
}
