/* activity-modal.css */
/* Activity modal: steps section, history section, step statuses, timeline */

/* --- Стили для секции шагов в модальном окне --- */
.section-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1.5rem 0;
}

.steps-section h4 {
    margin: 0;
    font-size: var(--font-size-lg);
    color: var(--text-color);
}

.steps-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

/* Steps container */
.steps-list {
    padding: 0;
    margin: 0;
}

/* Add Step button container */
.add-step-button-container {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
    position: relative; /* ✅ Positioning context for dropdown */
}

.add-step-button-container .btn {
    width: auto;
}

/* Secondary outline button (transparent) */
.btn-secondary-outline {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.btn-secondary-outline:hover {
    background-color: var(--bg-hover);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.btn-secondary-outline .material-icons {
    font-size: 18px;
}

/* Text button (no border, no background) */
.btn-text-secondary {
    background-color: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-normal);
    transition: color 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.btn-text-secondary:hover:not(:disabled) {
    color: var(--brand-primary);
}

.btn-text-secondary:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-text-secondary:disabled {
    color: var(--text-tertiary);
    cursor: not-allowed;
    opacity: 0.5;
    pointer-events: none;
}

.btn-text-secondary.active {
    color: var(--brand-primary);
    font-weight: var(--font-weight-medium);
}

/* Steps actions menu (three dots) */
.steps-actions-menu {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: auto;
}

/* When in activity-name-template-row, align with selector */
.activity-name-template-row .steps-actions-menu {
    display: none; /* Hidden by default, shown in Edit mode via JS */
    align-self: flex-end; /* Align with bottom of row (same as selector) */
    margin-bottom: var(--space-4); /* Match selector's margin-bottom for alignment */
}

.steps-actions-menu .btn-icon {
    opacity: 1 !important;
}

/* Base dropdown styles (restored from styles.css - removed in a8aaadc2) */
.dropdown-menu {
    display: none;
    position: absolute;
    background-color: var(--card-bg);
    min-width: 200px;
    box-shadow:
        0 10px 15px -3px rgb(0 0 0 / 0.1),
        0 4px 6px -4px rgb(0 0 0 / 0.1);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    z-index: 2250; /* Above modal header (modal is 2200) */
    overflow: hidden;
}

.dropdown-menu.show {
    display: block;
}

.steps-actions-menu .dropdown-menu {
    right: 0;
    left: auto;
    top: 100%; /* Position below the button */
}

/* Base dropdown-item styles (restored from styles.css) */
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    text-align: left;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.dropdown-item:hover {
    background-color: var(--bg-secondary);
}

/* Унифицированные стили для элементов меню действий */
#steps-actions-menu-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    min-height: 40px;
    margin: 0;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

#steps-actions-menu-dropdown .dropdown-item:hover {
    background-color: var(--bg-secondary);
}

#steps-actions-menu-dropdown .dropdown-item .material-icons {
    font-size: 18px;
    color: var(--text-secondary);
    width: 18px;
    flex-shrink: 0;
}

/* Delete Step Button and Dropdown */
#delete-step-btn-inline {
    position: relative;
    margin-left: 0.5rem;
}

#delete-step-btn-inline.active {
    background-color: var(--bg-secondary);
}

#delete-step-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: 2200; /* ✅ Above modal (2100) */
    padding: 0.25rem 0;
}

#delete-step-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color var(--transition-base);
}

#delete-step-dropdown .dropdown-item:hover:not(.disabled) {
    background-color: var(--bg-secondary);
}

#delete-step-dropdown .dropdown-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#delete-step-dropdown .dropdown-item .material-icons {
    font-size: 18px;
    color: var(--text-secondary);
}

/* Dropdown toggle items for deny switches */
.dropdown-toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    min-height: 40px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.dropdown-toggle-item:hover {
    background-color: var(--bg-secondary);
}

.dropdown-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
}

.dropdown-toggle-label .material-icons {
    font-size: 18px;
    color: var(--text-secondary);
    width: 18px;
    flex-shrink: 0;
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 0.25rem 0;
}

/* Toggle switch component */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
    flex-shrink: 0;
}

.toggle-switch input[type='checkbox'] {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: 0.3s;
    border-radius: 20px;
}

.toggle-slider:before {
    position: absolute;
    content: '';
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input[type='checkbox']:checked + .toggle-slider {
    background-color: var(--brand-primary);
}

input[type='checkbox']:checked + .toggle-slider:before {
    transform: translateX(20px);
}

input[type='checkbox']:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Steps table */
.steps-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

/* Table header (START) and footer (FINISH) rows */
.steps-table-header,
.steps-table-footer {
    background-color: var(--bg-secondary);
    border: none; /* Убираем borders, чтобы не было разрывов в таймлайне */
    margin: 0; /* Убираем зазоры между элементами display: table */
}

.steps-table-header td,
.steps-table-footer td {
    padding: 0.75rem 0.5rem; /* Совпадает с padding строк шагов для одинаковой высоты */
}

/* Date column в header/footer выравнивается по левому краю */
.steps-table-header td:not(.step-number-cell),
.steps-table-footer td:not(.step-number-cell) {
    text-align: left;
}

/* Separator line below header */
.steps-table-header td:not(.step-number-cell) {
    border-bottom: 1px solid var(--border-color);
}

/* Override border for circle column in header/footer */
.steps-table-header .step-number-cell,
.steps-table-footer .step-number-cell {
    border: none; /* Убираем все borders, чтобы не перекрывать вертикальную линию таймлайна */
}

/* Step row */
.step-row {
    transition: background-color 0.2s;
    margin: 0; /* Убираем зазоры между элементами display: table */
    cursor: default;
}

.step-row:hover {
    background-color: var(--bg-secondary);
}

/* Clickable step row (for Return/Skip mode) */
.step-row.step-clickable {
    cursor: pointer;
    background-color: rgba(var(--brand-primary-rgb, 59, 130, 246), 0.1);
    border-left: 3px solid var(--brand-primary);
}

.step-row.step-clickable:hover {
    background-color: rgba(var(--brand-primary-rgb, 59, 130, 246), 0.2);
}

.step-row td {
    padding: 0.75rem 0.5rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

/* Remove border from circle column to not overlap timeline */
.step-row .step-number-cell {
    border-bottom: none;
}

/* Column 1: Step number (NEW - separated) */
.step-number-cell {
    width: 60px;
    min-width: 60px;
    text-align: center;
    white-space: nowrap;
    position: relative;
    vertical-align: middle;
    padding: 0.75rem 0.5rem !important; /* Одинаковый padding для всех строк */
}

/* Column 2: Step name with progress (separated from number) */
.step-name-cell {
    width: 120px;
    min-width: 120px;
    max-width: 120px;
    padding-left: 0.5rem !important;
    overflow: hidden;
}

/* Step name wrapper - no longer used, kept for compatibility */
.step-name-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

/* Step name text */
.step-name {
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    max-width: 100%;
    flex-grow: 1;
    transition: color 0.2s;
    user-select: none;
}

.step-name.completed {
    text-decoration: line-through;
    color: var(--label-color);
}

/* Info line with progress and reject counter */
.step-info-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Progress displayed inline under step name */
.step-progress-inline {
    font-size: 0.6rem;
    color: var(--text-secondary);
    font-weight: var(--font-weight-normal);
}

.step-progress-inline.step-progress-invalid {
    color: var(--danger-color);
}

/* Reject counter displayed inline after progress */
.step-reject-inline {
    font-size: 0.6rem;
    border-left: 1px solid var(--border-color);
    padding-left: 0.5rem;
}

.step-reject-inline .reject-counter {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* Column 3: Status buttons (Start/Finish/Reject) */
.step-status-cell {
    width: 160px;
    max-width: 160px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
}

/* Column 4: Action buttons (share/edit/delete) */
.step-actions-cell {
    width: 80px;
    max-width: 80px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
}

.step-item-placeholder {
    color: var(--label-color);
    padding: 1rem;
    text-align: center;
    font-style: italic;
}

.step-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

/* Module-specific: hide delete button by default */
.delete-step-btn {
    opacity: 0;
}

.step-row:hover .delete-step-btn {
    opacity: 1;
}

/* Step date tag (in header/footer rows) */
.step-date-tag {
    background-color: transparent;
    color: var(--text-secondary);
    padding: 0.25rem 0.75rem 0.25rem 0;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    white-space: nowrap;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 0.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.step-date-tag:hover {
    background-color: var(--bg-hover);
    color: var(--brand-primary);
}

.step-date-icon {
    font-size: 18px;
}

.step-date-text {
    line-height: 1;
}

.step-status-text {
    font-size: 0.6rem;
    color: var(--text-secondary);
    font-weight: var(--font-weight-normal);
    line-height: 1;
}

.step-status-text.overdue {
    color: var(--color-error);
    font-weight: var(--font-weight-medium);
}

/* --- Стили для секции истории --- */
.history-section h4 {
    margin: 0;
    font-size: var(--font-size-lg);
    color: var(--text-color);
    margin-bottom: 1rem;
}

.history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 250px;
    overflow-y: auto;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
}

.history-item {
    display: grid;
    grid-template-columns: 160px 1fr 1fr;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    align-items: start;
}
.history-item:last-child {
    border-bottom: none;
}

.history-item-placeholder {
    color: var(--label-color);
    padding: 1rem;
    text-align: center;
    font-style: italic;
}

.history-item-placeholder.error {
    color: var(--color-error);
}

.history-item .timestamp {
    color: var(--label-color);
    white-space: nowrap;
}

.history-item .user {
    font-weight: var(--font-weight-semibold);
    color: var(--text-color);
    word-break: break-word;
}

.history-item .action {
    color: var(--text-primary);
    word-break: break-word;
}

#modal-share-btn {
    display: none;
    align-items: center;
    gap: 0.5rem;
}

#modal-share-btn .material-icons {
    font-size: 18px;
}

/* Стили для drag & drop шагов */
.step-row.drag-over {
    background-color: rgba(var(--color-info-rgb), 0.1);
    border-top: 2px solid var(--primary-color);
}

.step-row[draggable='true']:active {
    cursor: grabbing;
}

.drag-handle {
    flex-shrink: 0;
}

.drag-handle:hover {
    color: var(--primary-color) !important;
}

/* Контейнер для кнопок редактирования и удаления */
.step-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    flex-shrink: 0;
    justify-content: center;
}

.step-row:hover .step-actions {
    opacity: 1;
}

/* Buttons inside step-actions should be visible when container is visible */
.step-actions .btn-icon {
    opacity: 1;
}

/* Module-specific hover overrides for step icon buttons */
.edit-step-btn:hover {
    color: var(--primary-color);
}

.delete-step-btn:hover {
    color: var(--negative-diff);
}

/* ✅ Editable step names: click to edit with blue hover */
.step-name-editable {
    cursor: pointer;
}

.step-name-editable:hover {
    color: var(--primary-color);
}

/* Стили для сворачиваемых секций */
.collapsible-section {
    margin-bottom: 1rem;
}

.section-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    transition: background-color 0.2s;
}

.section-header:hover {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.section-title-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title-group h4 {
    margin: 0;
    font-size: var(--font-size-lg);
    color: var(--text-color);
}

.collapse-icon {
    color: var(--label-color);
    font-size: 24px;
    transition: transform 0.3s ease;
}

.collapsible-section.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.section-content {
    overflow: hidden;
    transition:
        max-height 0.3s ease,
        opacity 0.3s ease,
        margin-top 0.3s ease;
    max-height: 500px;
    opacity: 1;
    margin-top: 0.5rem;
}

.collapsible-section.collapsed .section-content {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    pointer-events: none;
}

/* Убираем margin у h4 внутри section-header */
.section-header h4 {
    margin: 0;
}

/* Красная подсветка для некорректной последовательности прогресса */
.step-progress-invalid {
    color: var(--color-error);
    font-weight: var(--font-weight-bold);
}

/* Стиль для пропущенных шагов */
.step-row.skipped {
    opacity: 0.5;
    background-color: var(--bg-secondary);
}

.step-row.skipped .step-name {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.step-row.skipped .step-checkbox {
    opacity: 0.5;
}

/* Процент прогресса шага (в кружке) */
.step-order {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--brand-primary);
    background-color: var(--bg-primary);
    color: var(--brand-primary);
    font-weight: var(--font-weight-semibold);
    font-size: 11px; /* Smaller font to fit "100%" */
    position: relative;
    z-index: 1;
    margin: 0.75rem 0; /* Центрируем кружок по вертикали, соответствует padding других ячеек */
}

/* Пустой кружок для header/footer - такого же размера, просто без номера */
.step-order-empty {
    /* Наследует все стили от .step-order (36px) */
}

/* Иконка внутри кружка (флаги start/finish) */
.step-order-icon {
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Status colors for circles */
.step-status-pending {
    border-color: var(--text-tertiary) !important;
    color: var(--text-tertiary) !important;
}

.step-status-in-progress {
    border-color: var(--brand-primary) !important;
    color: var(--brand-primary) !important;
}

.step-status-completed {
    border-color: var(--color-success) !important;
    color: var(--color-success) !important;
}

.step-status-skipped {
    border-color: var(--text-tertiary) !important;
    color: var(--text-tertiary) !important;
}

.step-status-rejected {
    border-color: var(--color-error) !important;
    color: var(--color-error) !important;
}

/* Rework status (yellow) - step that was returned to after reject */
.step-status-rework {
    border-color: var(--color-warning) !important;
    color: var(--color-warning) !important;
}

/* Checkmark icon for completed steps */
.step-order-check {
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Skip icon for skipped steps */
.step-order-skip {
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hide number when showing checkmark */
.step-status-completed .step-order-number {
    display: none;
}

/* Hide number when showing skip icon */
.step-status-skipped .step-order-number {
    display: none;
}

/* Hide number when showing reject icon */
.step-status-rejected .step-order-number {
    display: none;
}

/* Reject icon for rejected steps */
.step-order-reject {
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Rework icon for rework steps (yellow) */
.step-order-rework {
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hide number when showing rework icon */
.step-status-rework .step-order-number {
    display: none;
}

/* Module-specific hover override for share button */
.share-step-btn:hover {
    color: var(--primary-color);
}

/* Заблокированные шаги (completed/skipped) */
.step-row[data-locked='true'] {
    /* cursor removed - no visual indication needed */
}

.step-row[data-locked='true'] .drag-handle {
    cursor: default;
    opacity: 0.3;
}

.step-row[data-locked='true']:hover {
    /* hover works normally */
}

/* Tooltip для заблокированного перетаскивания */
.drag-locked-tooltip {
    background-color: var(--color-error);
    color: var(--text-inverse);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    z-index: 9999;
    pointer-events: none;
    box-shadow: var(--shadow-md);
    animation: fadeInOut 2s ease;
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* Кнопка Add Step как первый элемент списка */
.add-step-list-item {
    list-style: none;
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
}

.add-step-list-item button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* ==========================================
   НОВЫЕ СТИЛИ ДЛЯ КНОПОК И СТАТУСОВ ШАГОВ
   ========================================== */

/* Статусы шагов */
.step-status-pending .step-name {
    color: var(--text-tertiary); /* серый */
}

.step-status-inProgress .step-name {
    color: var(--text-primary); /* тёмно-серый, активный */
    font-weight: var(--font-weight-medium);
}

.step-status-completed .step-name {
    color: var(--text-tertiary); /* серый приглушенный */
}

.step-status-skipped {
    background-color: var(--bg-secondary);
}

.step-status-skipped .step-name {
    color: var(--text-tertiary);
    text-decoration: line-through;
}

/* Hide Assign User button for completed and skipped steps */
.step-status-completed .step-assign-btn-avatar,
.step-status-skipped .step-assign-btn-avatar {
    display: none !important;
}

.step-status-rejected .step-name {
    color: var(--color-error);
}

.step-status-rework .step-name {
    color: var(--color-warning);
}

/* ✅ Hover для редактируемых шагов - перекрывает цвета статусов */
.step-status-pending .step-name-editable:hover,
.step-status-inProgress .step-name-editable:hover {
    color: var(--primary-color) !important;
}

/* Счётчик отклонений */
.reject-counter {
    display: block;
    color: var(--text-secondary);
    font-size: 0.6rem;
    font-weight: var(--font-weight-normal);
    line-height: 1;
    cursor: help;
    margin-top: 2px;
}

/* Индикатор Hold */
.step-hold-indicator {
    color: var(--text-tertiary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
}

/* Отключенные кнопки Edit/Delete */
.step-actions button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ✅ Assigned users list */
.step-assigned-cell {
    padding: 0.5rem !important;
    vertical-align: top;
    width: auto;
    overflow: visible !important; /* Allow scaled avatars to be visible */
}

/* Column 4: Selected assigned user cell (пока пустой) */
.selected-assigned-user-cell {
    padding: 0.5rem !important;
    vertical-align: top;
    width: auto;
}

/* Column 5: Briefcase cell */
.step-briefcase-cell {
    padding: 0.25rem !important;
    vertical-align: middle;
    width: 48px;
    min-width: 48px;
    max-width: 48px;
}

.step-briefcase-cell .briefcase-icon {
    display: block;
    fill: var(--text-secondary, #666);
    cursor: pointer;
    transition:
        fill 0.2s,
        transform 0.2s;
}

.step-briefcase-cell .briefcase-icon:hover {
    fill: var(--primary-color, #4a90d9);
    transform: scale(1.1);
}

/* File Exchange Modal */
.file-exchange-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

.file-exchange-modal {
    background: var(--bg-primary, #fff);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    width: 500px;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.file-exchange-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.file-exchange-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary, #333);
}

.file-exchange-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: var(--text-secondary, #666);
    transition: background 0.2s;
}

.file-exchange-close:hover {
    background: var(--bg-hover, #f0f0f0);
}

.file-exchange-content {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    min-height: 200px;
}

.step-assigned-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85em;
}

.step-assigned-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    padding: 0.25rem 0;
}

/* Avatar wrapper with status ring */
.step-assigned-user .user-avatar-wrapper {
    position: relative;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 2px;
    box-sizing: border-box;
}

/* Status ring colors */
.step-assigned-user .user-avatar-wrapper.status-ring-pending {
    background: var(--text-tertiary);
}

.step-assigned-user .user-avatar-wrapper.status-ring-in-progress {
    background: var(--brand-primary);
}

.step-assigned-user .user-avatar-wrapper.status-ring-completed {
    background: var(--color-success);
}

.step-assigned-user .user-avatar-wrapper.status-ring-rejected {
    background: var(--color-error);
}

.step-assigned-user .user-avatar-wrapper.status-ring-cancelled {
    background: var(--text-secondary);
}

.step-assigned-user .user-avatar-wrapper.status-ring-rework {
    background: var(--color-warning);
}

.step-assigned-user .user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7em;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.step-assigned-user .user-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Inline action buttons for assigned users */
.step-assigned-user .step-action-btn {
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.step-assign-btn-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

/* Pattern icon in step list */
.step-pattern-icon {
    flex-shrink: 0;
    width: 24px !important;
    height: 24px !important;
}

/* Mini avatars row - same style as footer .frame-avatars */
.step-avatars-row {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
}

/* Stacked avatars with overlap */
.step-avatars-stacked {
    gap: 0; /* Remove gap for stacking */
}

.step-avatars-stacked .step-avatar-mini {
    margin-left: -8px; /* Overlap */
    border: 2px solid var(--bg-primary); /* White border for separation */
    position: relative;
    z-index: 1;
}

.step-avatars-stacked .step-avatar-mini:first-child {
    margin-left: 0; /* No overlap for first avatar */
}

/* Hidden avatars (beyond MAX_VISIBLE) */
.step-avatars-stacked .step-avatar-mini.avatar-hidden {
    display: none;
}

/* "+N" counter for hidden avatars - clickable to expand */
.step-avatars-stacked .avatar-more-count {
    cursor: pointer;
}

.step-avatars-stacked .avatar-more-count .user-avatar-mini {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 9px;
    font-weight: 600;
    transition: background-color 0.15s ease;
}

.step-avatars-stacked .avatar-more-count:hover .user-avatar-mini {
    background-color: var(--bg-hover);
}

/* Expanded state - show collapse button */
.step-avatars-stacked.expanded .avatar-more-count .user-avatar-mini {
    background-color: var(--brand-primary);
    color: var(--text-inverse);
    font-size: 12px;
}

/* Expanded state - avatars dropdown as overlay */
.step-avatars-stacked.expanded {
    position: relative;
}

/* Dropdown panel for expanded avatars */
.step-avatars-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 8px;
    z-index: 100;
    box-shadow: var(--shadow-md);
    flex-wrap: wrap;
    gap: 4px;
    min-width: 80px;
    max-width: 120px;
}

.step-avatars-stacked.expanded .step-avatars-dropdown {
    display: flex;
}

/* Avatars inside dropdown - no overlap */
.step-avatars-dropdown .step-avatar-mini {
    margin-left: 0 !important;
    border: none;
}

.step-avatars-stacked.expanded .step-avatar-mini:first-child {
    margin-left: 0;
}

/* Assign button in stacked row - now at the end */
.step-avatars-stacked .step-assign-btn-avatar {
    margin-left: 4px; /* Small gap before assign button */
    margin-right: 0;
}

/* Mini avatar wrapper - same style as .frame-avatar */
/* Status ring colors for step-avatar-mini */
.step-avatar-mini.status-ring-pending {
    box-shadow: 0 0 0 2px var(--text-tertiary);
}

.step-avatar-mini.status-ring-in-progress {
    box-shadow: 0 0 0 2px var(--brand-primary);
}

.step-avatar-mini.status-ring-completed {
    box-shadow: 0 0 0 2px var(--color-success);
}

.step-avatar-mini.status-ring-rejected {
    box-shadow: 0 0 0 2px var(--color-error);
}

.step-avatar-mini.status-ring-cancelled {
    box-shadow: 0 0 0 2px var(--text-secondary);
}

.step-avatar-mini.status-ring-rework {
    box-shadow: 0 0 0 2px var(--color-warning);
}

.step-avatar-mini {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    cursor: pointer;
    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease;
}

.step-avatar-mini:hover {
    transform: scale(1.1);
}

/* Selected avatar indicator - same as .frame-avatar.active */
.step-avatar-mini.selected,
.step-avatar-mini.selected:hover {
    box-shadow: 0 0 0 2px var(--brand-primary);
    transform: scale(1.08);
}

/* Z-index for stacked avatars - hover and selected should be on top */
.step-avatars-stacked .step-avatar-mini:hover {
    z-index: 10;
}

.step-avatars-stacked .step-avatar-mini.selected {
    z-index: 5;
}

.user-avatar-mini {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 10px;
    font-weight: 600;
}

/* User details row (name + buttons) - now in separate column */
.step-user-details-container {
    /* No margin needed - now in separate cell */
}

.step-user-details {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 28px;
}

/* Oval-shaped action buttons (Start/Finish/Reject) */
.step-user-details .step-action-btn {
    border-radius: 9999px;
}

.step-selected-user-name {
    color: var(--text-secondary);
    font-weight: var(--font-weight-normal);
}

/* Assign button as avatar with pattern icon inside - same size as avatars (24px) */
.step-assign-btn-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1.5px solid var(--border-secondary);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition:
        background-color 0.2s,
        border 0.2s,
        transform 0.15s ease,
        opacity 0.2s,
        z-index 0s;
    padding: 0;
    opacity: 0.7;
    position: relative;
    z-index: 1;
}

.step-assign-btn-avatar:hover {
    background-color: var(--brand-primary);
    border: 1.5px solid var(--brand-primary);
    transform: scale(1.1);
    opacity: 1;
    z-index: 10;
}

/* SVG plus icon inside assign button */
.step-assign-btn-avatar .assign-plus-icon {
    width: 12px;
    height: 12px;
    color: var(--text-secondary);
    transition: color 0.2s;
}

/* White icon on hover */
.step-assign-btn-avatar:hover .assign-plus-icon {
    color: white;
}

.step-actions button:disabled:hover {
    background-color: transparent;
    color: var(--label-color);
}

/* ==========================================
   OPERATION LOCK - LOADING STATES
   ========================================== */

.step-btn.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.step-btn .spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(var(--text-inverse-rgb, 255, 255, 255), 0.3);
    border-top-color: var(--text-inverse);
    border-radius: 50%;
    animation: spinner-rotate 0.6s linear infinite;
    margin-right: 4px;
    vertical-align: middle;
}

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

.step-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* ==========================================
   INSERT ZONES FOR ADDING STEPS
   ========================================== */

/* Insert zone row - appears between steps in insert mode */
.step-insert-zone {
    height: 0;
    opacity: 0;
    overflow: hidden;
    transition:
        height 0.3s ease,
        opacity 0.3s ease;
    cursor: pointer;
    position: relative;
}

.step-insert-zone.active {
    height: 40px;
    opacity: 1;
}

/* Empty timeline cell in insert zone */
.step-insert-zone-timeline-cell {
    width: 60px;
    min-width: 60px;
    padding: 0 !important;
    border: none !important;
}

/* Insert zone cell (spans remaining columns) */
.step-insert-zone-cell {
    padding: 0 !important;
    border: none !important;
    position: relative;
}

/* Insert zone content */
.step-insert-zone-content {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background-color: rgba(var(--brand-primary-rgb, 59, 130, 246), 0.1);
    border: 2px dashed var(--brand-primary);
    border-radius: var(--radius-sm);
    margin: 0 0.5rem;
    transition: all 0.2s ease;
}

.step-insert-zone:hover .step-insert-zone-content {
    background-color: rgba(var(--brand-primary-rgb, 59, 130, 246), 0.2);
    border-color: var(--brand-primary);
    transform: scaleY(1.05);
}

/* Plus icon in insert zone */
.step-insert-zone-icon {
    color: var(--brand-primary);
    font-size: 28px;
    font-weight: bold;
    transition: transform 0.2s ease;
}

.step-insert-zone:hover .step-insert-zone-icon {
    transform: scale(1.3);
}

/* Disabled insert zone */
.step-insert-zone.disabled {
    cursor: not-allowed;
}

.step-insert-zone.disabled .step-insert-zone-content {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
    opacity: 0.5;
}

.step-insert-zone.disabled:hover .step-insert-zone-content {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
    transform: none;
}

.step-insert-zone.disabled .step-insert-zone-icon {
    color: var(--text-tertiary);
}

/* ================================================
   Editable Modal Title (Activity Name in Header)
   ================================================ */

/* Override modal-header justify-content for step-by-step modal */
#modal-overlay .modal-header {
    justify-content: flex-start;
    gap: var(--space-4);
}

/* Close button should stay on the right */
#modal-overlay .modal-header .modal-close-btn {
    margin-left: auto;
}

.modal-title-container {
    display: flex;
    align-items: center;
    flex: 0 0 85%; /* ~75% of full modal width (accounting for header padding) */
    min-width: 0;
}

.modal-title-editable {
    display: flex;
    align-items: center;
    gap: 0.35rem; /* Gap for tags icon and badges */
    width: 100%;
    min-width: 0;
}

.modal-title-input {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 2px 4px;
    margin: 0;
    flex: 1; /* Fill available width */
    min-width: 0;
    max-width: 100%;
    outline: none;
    transition:
        border-color var(--transition-fast),
        background-color var(--transition-fast);
    /* Text overflow with ellipsis */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* No hover effect on input */

.modal-title-input.editing,
.modal-title-input:focus {
    background-color: var(--bg-secondary);
    border-bottom-color: var(--brand-primary);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    /* Allow text to be visible when editing */
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}

.modal-title-edit-btn {
    opacity: 0; /* Hidden by default */
    transition: opacity var(--transition-fast);
    flex-shrink: 0;
    margin-left: 2px; /* Small margin to stick close to text */
}

/* Show edit button on hover over title container */
.modal-title-editable:hover .modal-title-edit-btn {
    opacity: 0.6;
}

/* No hover effect on button itself */

/* Заблокированные элементы формы */
.input-field:disabled {
    background-color: var(--bg-tertiary);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Унаследованные значения (inherited from parent section) */
.input-field.input-inherited {
    color: var(--text-tertiary) !important;
    font-style: italic;
    background-color: var(--bg-tertiary);
}

/* Заблокированные кнопки */
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Frame Selection Modal */
.frame-modal-tabs {
    display: flex;
    margin-bottom: var(--space-4);
    gap: var(--space-1);
}

.frame-modal-tab {
    flex: 1;
    padding: var(--space-3);
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: all var(--transition-base);
}

.frame-modal-tab.active {
    border-bottom-color: var(--brand-primary);
    color: var(--text-primary);
    font-weight: var(--font-weight-semibold);
}

.frame-modal-tab:hover:not(.active) {
    color: var(--text-primary);
    background-color: var(--bg-hover);
}

/* Frames list container */
.frames-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-height: 300px;
    max-height: 500px;
    overflow-y: auto;
}

/* Empty state */
.frames-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: var(--text-tertiary);
    text-align: center;
}

.frames-empty.hidden {
    display: none;
}

/* Frame row */
.frame-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3);
    border: none;
    background-color: transparent;
    transition: all var(--transition-base);
    cursor: grab;
}

.frame-row:hover {
    background-color: var(--bg-hover);
}

.frame-row.dragging {
    opacity: 0.4;
    cursor: grabbing;
}

.frame-row.drag-over {
    border-top: 2px solid var(--brand-primary);
    padding-top: calc(var(--space-3) - 2px);
}

/* Personal row special styling */
.frame-row-personal .frame-row-icon {
    color: var(--brand-primary);
}

/* Frame row content */
.frame-row-content {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex: 1;
}

.frame-row-icon {
    color: var(--text-secondary);
    font-size: 24px;
}

.frame-row-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.frame-row-name {
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
}

.frame-row-owner {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: var(--font-weight-normal);
}

.frame-row-favorite-badge {
    color: var(--color-warning);
    font-size: 18px;
    margin-left: var(--space-2);
}

/* Frame row actions */
.frame-row-actions {
    display: flex;
    gap: var(--space-2);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.frame-row:hover .frame-row-actions {
    opacity: 1;
}

.frame-row-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background-color: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-base);
}

.frame-row-btn-icon:hover {
    color: var(--brand-primary);
    transform: scale(1.1);
}

.frame-row-btn-icon .material-icons {
    font-size: 20px;
}

.frame-row-btn-icon.frame-row-btn-danger:hover {
    color: var(--color-error);
}

/* Fade-out animation for moving activities */
@keyframes fadeOutRow {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

.row-fade-out {
    animation: fadeOutRow 0.3s ease-out forwards;
}

/* Frame selection modal - lower z-index so prompt modals appear above it */
#frame-selection-modal {
    z-index: 1900 !important;
}

/* Share Activity/Step Modal - must be above Edit Activity Modal (2100) */
#share-activity-modal {
    z-index: 2120 !important;
}

/* Fix: dropdown clipping in share modal - allow overflow for pattern dropdown */
#share-activity-modal-container {
    overflow: visible;
}

#share-activity-modal .modal-body {
    overflow: visible;
}

/* Date Management Modal - must be above Edit Activity Modal (2100) */
#date-management-modal {
    z-index: 2150 !important;
}

/* History Modal - same level as other secondary modals */
#history-modal {
    z-index: 2120 !important;
}

/* History Modal - stretch list to fill modal body */
#history-modal .history-list {
    max-height: none;
    height: calc(70vh - 100px); /* modal min-height minus header/padding */
    overflow-y: auto;
}

/* ModalService overlay for Create/Edit prompts - must be above all modals */
#modal-service-overlay {
    z-index: 2200 !important;
}

/* Date Management Modal styles */
.date-section-title {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: var(--text-color);
    margin: 1.5rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.date-section-title:first-of-type {
    margin-top: 0;
}

/* =========================================================================
   FILE EXCHANGE INLINE STYLES
   ========================================================================= */

/* Inline row - полностью прозрачная, без фона и рамок */
.fe-inline-row {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.fe-inline-row td {
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
}

.fe-inline-cell {
    padding: 0 !important;
    background: transparent !important;
}

/* Container for Master/Work section */
.fe-inline-container {
    margin: 4px 8px 4px 60px;
    padding: 8px 12px;
    border-radius: 8px;
    min-height: 40px;
}

.fe-inline-master {
    background: #e8f5e9;
    border: 1px solid #c8e6c9;
}

.fe-inline-work {
    background: #e3f2fd;
    border: 1px solid #bbdefb;
}

[data-theme='dark'] .fe-inline-master {
    background: rgba(76, 175, 80, 0.15);
    border-color: rgba(76, 175, 80, 0.3);
}

[data-theme='dark'] .fe-inline-work {
    background: rgba(33, 150, 243, 0.15);
    border-color: rgba(33, 150, 243, 0.3);
}

/* Label row */
.fe-inline-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

/* Add file button */
.fe-inline-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border: 1px solid var(--primary-color, #1976d2);
    border-radius: 4px;
    background: transparent;
    color: var(--primary-color, #1976d2);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.fe-inline-add-btn:hover {
    background: var(--primary-color, #1976d2);
    color: #fff;
}

.fe-inline-add-btn i {
    font-size: 14px;
}

/* Autosave button */
.fe-inline-autosave-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border: 1px solid var(--success-color, #4caf50);
    border-radius: 4px;
    background: transparent;
    color: var(--success-color, #4caf50);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 8px;
}

.fe-inline-autosave-btn:hover {
    background: var(--success-color, #4caf50);
    color: #fff;
}

.fe-inline-autosave-btn i {
    font-size: 14px;
}

.fe-inline-autosave-btn.autosave-active {
    background: var(--success-color, #4caf50);
    color: #fff;
    animation: autosave-pulse 2s infinite;
}

@keyframes autosave-pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Files container - вертикальный список */
.fe-inline-files {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Loading/empty/error states */
.fe-inline-loading,
.fe-inline-empty,
.fe-inline-error {
    font-size: 12px;
    color: var(--text-secondary, #999);
    font-style: italic;
}

.fe-inline-error {
    color: var(--color-error, #d32f2f);
}

/* File item - простая надпись */
.fe-inline-file {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    font-size: 13px;
}

.fe-inline-file-icon {
    flex-shrink: 0;
}

.fe-inline-file-name {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary, #333);
}

/* File actions */
.fe-inline-file-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}

.fe-inline-file:hover .fe-inline-file-actions {
    opacity: 1;
}

.fe-inline-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-secondary, #666);
    cursor: pointer;
    border-radius: 4px;
    transition:
        background 0.2s,
        color 0.2s;
}

.fe-inline-action:hover {
    background: var(--hover-bg, #e0e0e0);
    color: var(--text-primary, #333);
}

.fe-inline-action[data-action='delete']:hover {
    color: var(--color-error, #d32f2f);
}

.fe-inline-action i {
    font-size: 16px;
}

/* Expanded step row - убрать border у td */
.step-row.fe-expanded td {
    border-bottom: none;
}

/* Work строка - добавить border-bottom с отступом от таймлайна */
.fe-inline-row.fe-inline-work td {
    position: relative;
}

.fe-inline-row.fe-inline-work td::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 60px; /* ширина колонки таймлайна */
    right: 0;
    height: 1px;
    background: var(--border-color);
}
