/**
 * widget.css — общий CSS для всех форм и селектора приложения «Результат задачи».
 *
 * Раздаётся через API Gateway по роуту /widget.css.
 * Подключается в формах через <link> с $config['css_url'].
 *
 * Контракт: docs/form-contract.md (v1.2)
 *
 * Правила:
 *   - Общие стили (дублируются в 2+ формах) — здесь.
 *   - Уникальные стили (1 форма) — в форме, в отдельном <style>.
 *   - Уникальные цвета (subtask — оранжевые кнопки) — через CSS-переменные.
 *
 * Версионирование: ?v=N в config['css_url'] (bump при обновлении).
 */

/* ============================================================
   БАЗОВЫЕ
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    background: #eef2f4;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    padding: 16px;
    margin: 0;
}

/* ============================================================
   КАРТОЧКА
   ============================================================ */
.widget-card {
    max-width: 1000px;
    margin: 0 auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.widget-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e6e9eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.widget-header h3 {
    font-size: 16px;
    font-weight: 500;
    color: #1d2b36;
    margin: 0;
}
.widget-body {
    padding: 20px;
}

/* ============================================================
   ФОРМЫ
   ============================================================ */
.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #58616b;
}
.form-group label .required {
    color: #e92f2f;
}
.b24-input {
    width: 100%;
    padding: 9px 12px;
    font-size: 14px;
    border: 1px solid #cfd4d9;
    border-radius: 6px;
    background: #fff;
    transition: 0.2s;
}
.b24-input:focus {
    outline: none;
    border-color: #2fc6f6;
    box-shadow: 0 0 0 2px rgba(47,198,246,0.2);
}
.b24-select {
    width: 100%;
    padding: 9px 12px;
    font-size: 14px;
    border: 1px solid #cfd4d9;
    border-radius: 6px;
    background: #fff;
    transition: 0.2s;
    cursor: pointer;
    appearance: auto;
}
.b24-select:focus {
    outline: none;
    border-color: #2fc6f6;
    box-shadow: 0 0 0 2px rgba(47,198,246,0.2);
}
textarea.b24-input {
    resize: vertical;
    min-height: 80px;
}

/* ============================================================
   КНОПКИ
   ============================================================ */
.button-row {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
.b24-button {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: 0.2s;
}
/* Акцентный цвет — через CSS-переменную.
   По умолчанию — синий (2fc6f6). Форма может переопределить. */
.b24-button-primary {
    background: var(--widget-accent, #2fc6f6);
    color: #fff;
    flex: 1;
}
.b24-button-primary:hover {
    background: var(--widget-accent-hover, #1da9d6);
}
.b24-button-primary:disabled {
    background: #cfd4d9;
    cursor: not-allowed;
}
.b24-button-secondary {
    background: #eef2f4;
    color: #58616b;
}
.b24-button-secondary:hover {
    background: #e2e6e9;
}
.b24-button-success {
    background: #9dcf00;
    color: #fff;
}
.b24-button-success:hover {
    background: #89b800;
}
.b24-button-success:disabled {
    background: #cfd4d9;
    cursor: not-allowed;
}
.b24-button-danger {
    background: #e92f2f;
    color: #fff;
}
.b24-button-danger:hover {
    background: #d02525;
}
.b24-button-danger:disabled {
    background: #cfd4d9;
    cursor: not-allowed;
}

/* ============================================================
   УВЕДОМЛЕНИЯ
   ============================================================ */
.b24-notify {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    color: #fff;
    font-size: 13px;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s;
    max-width: 350px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.b24-notify.show {
    opacity: 1;
}
.b24-notify-success {
    background: #9dcf00;
}
.b24-notify-error {
    background: #e92f2f;
}
.b24-notify-info {
    background: #2fc6f6;
}

/* ============================================================
   СКРЫТЫЕ ФОРМЫ
   ============================================================ */
.hidden-form {
    display: none;
}

/* ============================================================
   ЧИПСЫ
   ============================================================ */
.chip-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.chip {
    padding: 6px 14px;
    border-radius: 16px;
    border: 1px solid #cfd4d9;
    background: #fafbfc;
    font-size: 12px;
    color: #58616b;
    cursor: pointer;
    transition: 0.2s;
    user-select: none;
}
.chip:hover {
    background: #eef2f4;
    border-color: #a3acb6;
}
.chip.selected {
    background: var(--widget-chip-bg, #f0f9fd);
    border-color: var(--widget-accent, #2fc6f6);
    color: #1d2b36;
}

/* ============================================================
   ФАЙЛЫ (одиночная загрузка)
   ============================================================ */
.file-upload-box {
    border: 2px dashed #cfd4d9;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: 0.2s;
    background: #fafbfc;
}
.file-upload-box:hover {
    border-color: var(--widget-accent, #2fc6f6);
    background: var(--widget-chip-bg, #f0f9fd);
}
.file-upload-box .text {
    font-size: 13px;
    color: #58616b;
}
.file-upload-box .hint {
    font-size: 11px;
    color: #a3acb6;
    margin-top: 4px;
}
.file-selected {
    display: none;
    background: #eef9ee;
    border: 1px solid #8dc779;
    border-radius: 6px;
    padding: 12px;
    margin-top: 8px;
    align-items: center;
    gap: 12px;
}
.file-selected.show {
    display: flex;
}
.file-selected .file-name {
    flex: 1;
    font-size: 14px;
    color: #1d2b36;
}
.file-selected .file-remove {
    background: none;
    border: none;
    color: #e92f2f;
    cursor: pointer;
    font-size: 18px;
}

/* ============================================================
   ПОИСК ПОЛЬЗОВАТЕЛЯ
   ============================================================ */
.user-search {
    position: relative;
}
.user-search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #cfd4d9;
    border-radius: 6px;
    margin-top: 4px;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.user-search-results.show {
    display: block;
}
.user-search-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #e6e9eb;
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-search-item:hover {
    background: #eef2fc;
}
.user-search-item .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--widget-accent, #2fc6f6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
}
.user-search-item .info {
    font-size: 13px;
}
.user-search-item .info .name {
    color: #1d2b36;
}
.user-search-item .info .hint {
    font-size: 11px;
    color: #a3acb6;
}
.selected-user {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 6px;
    background: var(--widget-chip-bg, #f0f9fd);
    border: 1px solid var(--widget-accent, #2fc6f6);
    border-radius: 16px;
    margin-top: 8px;
    font-size: 12px;
    color: #1d2b36;
    width: fit-content;
    max-width: 100%;
}
.selected-user.show {
    display: inline-flex;
}
.selected-user .avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--widget-accent, #2fc6f6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 500;
    flex-shrink: 0;
}
.selected-user .info {
    overflow: hidden;
}
.selected-user .info .name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
}
.selected-user .remove-user {
    margin-left: auto;
    background: none;
    border: none;
    color: #e92f2f;
    cursor: pointer;
    font-size: 16px;
}

/* === Multi-select: чипсы выбранных пользователей === */
.selected-users {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.selected-users .user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 6px;
    background: var(--widget-chip-bg, #f0f9fd);
    border: 1px solid var(--widget-accent, #2fc6f6);
    border-radius: 16px;
    font-size: 12px;
    color: #1d2b36;
}
.selected-users .user-chip .avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--widget-accent, #2fc6f6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 500;
}
.selected-users .user-chip .remove-user {
    background: none;
    border: none;
    color: #e92f2f;
    cursor: pointer;
    font-size: 14px;
    padding: 0 2px;
    margin-left: 0;
}

/* ============================================================
   PRELOADER
   ============================================================ */
.preloader {
    display: none;
    text-align: center;
    padding: 40px 20px;
    color: #58616b;
    font-size: 14px;
}
.preloader.show {
    display: block;
}
.preloader .spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid #e6e9eb;
    border-top-color: #2fc6f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
