/* ========================================================================
   FORMS / CRUD PAGES (Tasks, Areas, Representatives, Assign)
   ======================================================================== */

/* Category form: long bilingual help under image URL */
.category-image-url-field .category-image-url-help {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    max-width: 100%;
    margin-top: 0.35rem;
    line-height: 1.55;
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

.category-image-url-field .category-image-url-help span {
    display: block;
}

/* ---- Assign Tasks two-panel layout ---- */
.assign-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5);
}

.assign-task-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    margin-bottom: var(--space-3);
    cursor: pointer;
    transition: all var(--transition-fast);
    background: var(--surface-card);
}

.assign-task-item:hover,
.assign-task-item.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.assign-task-item .task-info {
    flex: 1;
    min-width: 0;
}

.assign-task-item .task-info h6 {
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--space-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.assign-task-item .task-info p {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin: 0;
}

.assign-form-card {
    position: sticky;
    top: calc(var(--navbar-height) + var(--space-6));
}

/* ---- Employee card in Representatives page ---- */
.employee-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--fs-sm);
    color: #fff;
    flex-shrink: 0;
}

.employee-avatar.a { background: linear-gradient(135deg, #6366F1, #8B5CF6); }
.employee-avatar.b { background: linear-gradient(135deg, #14B8A6, #06B6D4); }
.employee-avatar.c { background: linear-gradient(135deg, #F59E0B, #EF4444); }
.employee-avatar.d { background: linear-gradient(135deg, #EC4899, #8B5CF6); }
.employee-avatar.e { background: linear-gradient(135deg, #1B6FA8, #6366F1); }

.employee-cell {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.employee-cell .name {
    font-weight: 600;
    color: var(--text-primary);
}

.employee-cell .email {
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

/* ---- Task Detail Modal ---- */
.task-detail-row {
    display: flex;
    gap: var(--space-4);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--surface-border);
}

.task-detail-row:last-child {
    border-bottom: none;
}

.task-detail-label {
    width: 140px;
    flex-shrink: 0;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-secondary);
}

.task-detail-value {
    flex: 1;
    font-size: var(--fs-base);
    color: var(--text-primary);
}

/* ---- Task history timeline ---- */
.task-timeline {
    position: relative;
    padding-inline-start: var(--space-8);
}

.task-timeline::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--surface-border);
}

[dir="rtl"] .task-timeline::before {
    left: auto;
    right: 12px;
}

.timeline-item {
    position: relative;
    padding-bottom: var(--space-5);
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: calc(-1 * var(--space-8) + 8px);
    top: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--surface-card);
    z-index: 1;
}

[dir="rtl"] .timeline-item::before {
    left: auto;
    right: calc(-1 * var(--space-8) + 8px);
}

.timeline-item .timeline-date {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-bottom: var(--space-1);
}

.timeline-item .timeline-content {
    font-size: var(--fs-sm);
    color: var(--text-primary);
}

/* Product form: multi-select categories */
.product-categories-multiselect {
    min-height: 12rem;
    padding: var(--space-2);
}

.product-categories-multiselect option {
    padding: 0.35rem 0.5rem;
}

.product-related-multiselect {
    min-height: 10rem;
    padding: var(--space-2);
}

.product-related-multiselect option {
    padding: 0.35rem 0.5rem;
}

.product-spec-table input.form-control {
    font-size: var(--fs-sm);
}

.category-html-editor {
    min-height: 220px;
    background: var(--surface-primary, #fff);
}

.category-html-editor .ql-editor {
    min-height: 180px;
}

.category-html-editor .ql-editor img {
    max-width: 100%;
    height: auto;
}

.category-html-editor .ql-editor iframe,
.category-html-editor .ql-video {
    max-width: 100%;
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
}

/* ---- Offer form: toggle boolean fields ---- */
.offer-form-page .offer-bool-grid {
    margin-bottom: var(--space-2);
}

.offer-form-page .offer-bool-field {
    height: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    background: var(--surface-muted, #f8fafc);
}

.offer-form-page .offer-bool-field__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    min-height: 2rem;
}

.offer-form-page .offer-bool-field__label {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    line-height: 1.45;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.offer-form-page .offer-bool-field__actions {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

.offer-form-page .offer-bool-field__state {
    font-size: var(--fs-sm);
    font-weight: 600;
    min-width: 2rem;
    text-align: center;
    color: var(--text-muted);
}

.offer-form-page .offer-bool-field__state.is-yes {
    color: var(--success, #198754);
}

.offer-form-page .offer-toggle {
    position: relative;
    display: inline-block;
    width: 2.75rem;
    height: 1.5rem;
    flex-shrink: 0;
    margin: 0;
}

.offer-form-page .offer-toggle__input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
}

.offer-form-page .offer-toggle__slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: var(--surface-border, #cbd5e1);
    transition: background var(--transition-fast);
    pointer-events: none;
}

.offer-form-page .offer-toggle__slider::before {
    content: "";
    position: absolute;
    width: 1.15rem;
    height: 1.15rem;
    inset-block-start: 0.175rem;
    inset-inline-start: 0.175rem;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
    transition: transform var(--transition-fast);
}

.offer-form-page .offer-toggle__input:checked + .offer-toggle__slider {
    background: var(--primary, #1b6fa8);
}

.offer-form-page .offer-toggle__input:checked + .offer-toggle__slider::before {
    inset-inline-start: auto;
    inset-inline-end: 0.175rem;
}

.offer-form-page .offer-toggle__input:focus-visible + .offer-toggle__slider {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

@media (max-width: 576px) {
    .offer-form-page .offer-bool-field__row {
        flex-wrap: wrap;
        gap: var(--space-2);
    }

    .offer-form-page .offer-bool-field__actions {
        width: 100%;
        justify-content: flex-end;
    }

    [dir="rtl"] .offer-form-page .offer-bool-field__actions {
        justify-content: flex-start;
    }
}

/* ---- Responsive: forms & CRUD pages ---- */
@media (max-width: 992px) {
    .assign-form-card {
        position: static;
    }

    .product-related-shuttle.row {
        flex-direction: column;
    }

    .product-related-shuttle .col-auto {
        width: 100%;
        display: flex;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .product-form-page .page-header-actions,
    .page-header-actions {
        width: 100%;
    }

    .product-form-page .page-header-actions .btn-primary-custom,
    .product-form-page .page-header-actions .btn-secondary-custom {
        flex: 1 1 auto;
        justify-content: center;
        min-width: 0;
    }

    .form-section-card .content-card-body,
    .content-card .content-card-body {
        padding: var(--space-4);
    }

    .product-spec-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .image-preview-grid {
        justify-content: center;
    }
}

@media (max-width: 576px) {
    .assign-task-item {
        flex-wrap: wrap;
    }

    .task-detail-row {
        flex-direction: column;
        gap: var(--space-1);
    }

    .task-detail-label {
        width: 100%;
    }
}
