/* Shared internal task panel. Loaded after the CRM shell and workspace styles. */
body {
    --my-task-width: 380px;
    --my-task-top: 60px;
}

.my-task-sidebar {
    inset: var(--my-task-top) 0 0 auto;
    width: var(--my-task-width);
    padding: 0;
    display: block;
    z-index: 940;
    background: #fff;
    border-left: 1px solid #e4e7ec;
}

.my-task-sidebar .my-task-panel {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.my-task-sidebar .my-task-header {
    flex: 0 0 auto;
    padding: 14px 16px 10px;
    border: 0;
    background: #fff;
}

.my-task-sidebar .my-task-header h2 { color: #101828; }
.my-task-sidebar .my-task-header span { color: #606f83; font-size: 12px; }

.my-task-sidebar .my-task-close {
    color: #475467;
    background: transparent;
    border-color: transparent;
}

.my-task-sidebar .my-task-close:hover { background: #f3f5f8; }
.my-task-sidebar :is(button, input, select, a, [tabindex]):focus-visible {
    outline: 2px solid #315d8e;
    outline-offset: 2px;
}

.my-task-sidebar .my-task-tabs {
    flex: 0 0 auto;
    padding: 0 12px;
    gap: 16px;
}

.my-task-sidebar .my-task-tabs button {
    min-height: 38px;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: transparent;
    color: #606f83;
}

.my-task-sidebar .my-task-tabs button.is-active {
    border-bottom-color: #00876b;
    color: #006f58;
}

.my-task-sidebar .my-task-tabs button.is-active span { background: #e7f5f0; color: #006f58; }

.my-task-sidebar .my-task-form {
    flex: 0 0 auto;
    grid-template-columns: minmax(0, 1fr) auto;
    background: #fff;
    padding: 12px;
}

.my-task-sidebar .my-task-title-field { grid-column: 1 / -1; }
.my-task-sidebar .my-task-assignee-field { grid-column: 1; }
.my-task-sidebar .my-task-form label { font-size: 12px; font-weight: 400; text-transform: none; }
.my-task-sidebar .my-task-form :is(input, select) { margin: 0; font-size: 13px; }
.my-task-sidebar .my-task-form button { background: #00876b; border-color: #00876b; }
.my-task-sidebar .my-task-form button:hover { background: #006f58; border-color: #006f58; }
.my-task-sidebar .my-task-error { flex: 0 0 auto; }

.my-task-results { flex: 1 1 auto; min-height: 0; display: flex; }
.my-task-sidebar .my-task-list { width: 100%; padding: 0; scrollbar-gutter: stable; }

.my-task-sidebar .my-task-row {
    padding: 12px;
    margin: 0;
    border: 0;
    border-bottom: 1px solid #e4e7ec;
    border-left: 3px solid transparent;
    border-radius: 0;
    background: #fff;
}

.my-task-sidebar .my-task-row:hover,
.my-task-sidebar .my-task-row:focus-within { background: #f7f8fa; }
.my-task-sidebar .my-task-row.is-current { background: #edf8f4; border-left-color: #00876b; }
.my-task-sidebar .my-task-title { font-size: 13px; line-height: 1.45; }
.my-task-sidebar .my-task-details { color: #606f83; line-height: 1.45; }
.my-task-sidebar .my-task-date,
.my-task-sidebar .my-task-meta { font-size: 12px; line-height: 1.45; color: #606f83; }
.my-task-sidebar .my-task-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; }
.my-task-sidebar .my-task-meta span { white-space: normal; overflow-wrap: anywhere; }
.my-task-sidebar .my-task-assignee-chip { max-width: none; border: 0; padding: 0; background: transparent; color: #606f83; font-weight: 400; font-size: 12px; }
.my-task-sidebar .my-task-source-link { font-size: 12px; font-weight: 500; color: #006f58; }
.my-task-sidebar .my-task-check input { accent-color: #00876b; }

.my-task-resizer {
    position: absolute;
    z-index: 1;
    left: -5px;
    top: 0;
    bottom: 0;
    width: 10px;
    cursor: col-resize;
    touch-action: none;
}

.my-task-resizer::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 4px;
    width: 3px;
    height: 28px;
    border-radius: 3px;
    background: #a0adba;
}

.my-task-resizer:hover::after,
.my-task-resizer:focus-visible::after { background: #00876b; }
body.is-resizing-my-tasks { cursor: col-resize; user-select: none; }
.my-task-trigger[aria-expanded="true"] { background: #e7f5f0; color: #006f58; }

@media (min-width: 1100px) {
    body.has-my-task-sidebar .crm-linear-ui > .main { padding-right: calc(16px + var(--my-task-width)); }
    body.has-my-task-sidebar .crm-linear-ui > .main > .topbar { margin-right: calc(-16px - var(--my-task-width)); }
    body.has-my-task-sidebar .crm-linear-ui .content { container-type: inline-size; container-name: task-workspace; }
}

/* Reflow by the actual space left beside Tasks, not just the browser width. */
@container task-workspace (max-width: 800px) {
    .crm-linear-ui .record-workspace,
    .crm-linear-ui .project-form-panel .project-tab-panel.record-workspace,
    .crm-linear-ui .support-compose-card { grid-template-columns: minmax(0, 1fr); }
    .crm-linear-ui .record-workspace > .record-workspace-main,
    .crm-linear-ui .record-workspace > .record-workspace-sidebar { grid-column: 1; grid-row: auto; }
    .crm-linear-ui .support-ticket-subject-block { grid-template-columns: minmax(0, 1fr); }
    .crm-linear-ui .support-ticket-subject-meta { justify-items: start; }
    .crm-linear-ui .filters.module-list-filters { flex-wrap: wrap; }
    .crm-linear-ui .filters.module-list-filters label,
    .crm-linear-ui .filters.module-list-filters label:first-of-type { flex: 1 1 180px; min-width: 0; max-width: 100%; }
    .crm-linear-ui .filters.module-list-filters :is(.list-view-quick-actions, .filter-quick-actions) { flex-wrap: wrap; white-space: normal; }
    .crm-linear-ui .filters.module-list-filters :is(.list-more-filters, .list-table-options)[open],
    .crm-linear-ui .filters.module-list-filters .project-filter-tools:has(details[open]) { flex: 1 1 100%; width: 100%; }
    .crm-linear-ui .filters.module-list-filters .list-more-filter-fields,
    .crm-linear-ui .filters.module-list-filters .list-table-option-fields {
        position: static;
        width: 100%;
        max-width: 100%;
        max-height: none;
        transform: none;
        flex-wrap: wrap;
        overflow: auto;
        margin-top: 8px;
    }
    .crm-linear-ui .filters.module-list-filters.customers-list-filters .list-more-filter-fields,
    .crm-linear-ui .filters.module-list-filters.projects-list-filters .list-more-filter-fields {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: 'status' 'fields' 'actions';
    }
    .crm-linear-ui .activity-history-page .activity-history-filter-form,
    .crm-linear-ui .activity-history-page .activity-history-filter-form:has(.activity-history-subject-field) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1099px) {
    body.has-my-task-sidebar { overflow: hidden; }
    .my-task-sidebar { inset: 0; width: 100%; height: 100vh; height: 100dvh; z-index: 1100; padding: 0; border: 0; }
    .my-task-sidebar .my-task-panel { width: 100%; height: 100%; max-height: none; min-height: 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
    .my-task-resizer { display: none; }
    .my-task-sidebar .my-task-close { flex-basis: 44px; width: 44px; min-height: 44px; }
    .my-task-sidebar .my-task-close::before,
    .my-task-sidebar .my-task-close::after { top: 20px; left: 14px; }
    .my-task-sidebar .my-task-form :is(input, select, button),
    .my-task-sidebar .my-task-tabs button { min-height: 44px; }
    .my-task-sidebar .my-task-form :is(input, select) { font-size: 16px; }
    .my-task-sidebar .my-task-check { width: 44px; height: 44px; margin: -10px; }
    .my-task-sidebar .my-task-source-link { min-height: 44px; align-items: center; margin-top: 0; }
}

@media print {
    body.has-my-task-sidebar { overflow: visible; }
    .my-task-sidebar { display: none !important; }
    body.has-my-task-sidebar .crm-linear-ui > .main { padding-right: 16px; }
    body.has-my-task-sidebar .crm-linear-ui > .main > .topbar { margin-right: -16px; }
}
