/* =============================================================
   Task Widgets — embedded section + quick-add
   Loaded globally via header.php so it works in chat sidebar,
   customer profile modal, and any future host.
   Page-scoped tasks.css contains its own copy for the /tasks
   list/kanban; styles here are deliberately scoped to
   `.tasks-section` / `.task-quick-add` and won't conflict.
   ============================================================= */

.tasks-section {
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
    font-size: 13px;
}

.tasks-section .tasks-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 8px;
}

.tasks-section .tasks-section-header h4 {
    margin: 0;
    padding: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 0;
    line-height: 1.2;
}
.tasks-section .tasks-section-header h4 .ti {
    font-size: 15px;
    color: var(--text-secondary);
}

.tasks-section .tasks-section-view-all {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 2px 6px;
    border-radius: 6px;
    transition: background .15s, color .15s;
}
.tasks-section .tasks-section-view-all:hover {
    background: var(--bg-secondary, #f3f4f6);
    color: var(--text-primary);
    text-decoration: none;
}

/* ── Item rows ──────────────────────────────────────────────── */
.tasks-section .tasks-section-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 8px;
}
.tasks-section .tasks-section-item {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .12s;
    border: 1px solid transparent;
}
.tasks-section .tasks-section-item:hover {
    background: var(--bg-secondary, #f5f5f7);
    border-color: var(--border-color);
}
.tasks-section .tasks-section-item .status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 6px;
}
.tasks-section .tasks-section-item .status-dot.dot-ontime    { background: #10B981; }
.tasks-section .tasks-section-item .status-dot.dot-today     { background: #F59E0B; }
.tasks-section .tasks-section-item .status-dot.dot-overdue   { background: #EF4444; }
.tasks-section .tasks-section-item .status-dot.dot-done      { background: #9CA3AF; }
.tasks-section .tasks-section-item .status-dot.dot-cancelled { background: #6B7280; }

.tasks-section .tasks-section-item-body {
    flex: 1;
    min-width: 0;
}
.tasks-section .tasks-section-item-title {
    font-size: 12.5px;
    color: var(--text-primary);
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}
.tasks-section .tasks-section-item-due {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 1px;
}

.tasks-section .tasks-section-empty {
    text-align: center;
    color: var(--text-secondary);
    font-size: 11.5px;
    padding: 10px 0;
    opacity: .8;
}

/* ── Quick add: trigger button (opens the modal) ────────────── */
.task-widget-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    justify-content: center;
    padding: 7px 12px;
    background: var(--white, #ffffff);
    color: var(--brand-livechat, #31a793);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.task-widget-add-btn:hover {
    background: var(--brand-livechat, #31a793);
    border-color: var(--brand-livechat, #31a793);
    color: #fff;
}
.task-widget-add-btn .ti { font-size: 14px; }

/* "?" help icon next to a form label inside the widget modal. Mirrors the
   /tasks page styling but loaded globally so the chat-sidebar quick-add
   modal gets the same affordance. */
#taskWidgetModal .label-with-help {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
#taskWidgetModal .label-with-help .help-icon {
    font-size: 14px;
    color: var(--text-secondary);
    cursor: help;
    opacity: .7;
    transition: opacity .15s, color .15s;
}
#taskWidgetModal .label-with-help .help-icon:hover {
    opacity: 1;
    color: var(--brand-livechat, #31a793);
}

/* Bootstrap tooltips must beat .modal-overlay (z-index 10000). Default
   Bootstrap tooltip z-index is 1080 — without this override the tooltip
   renders behind the modal and looks like it isn't firing at all. */
.tooltip {
    z-index: 10110 !important;
}
.tooltip .tooltip-inner {
    max-width: 280px;
    text-align: left;
    font-size: 12px;
}

/* ── Quick add modal — sticky footer like the /tasks detail modal ─ */
#taskWidgetModal .modal-content { max-width: 560px; }
#taskWidgetModal .task-widget-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--white, #ffffff);
    border-bottom-left-radius: inherit;
    border-bottom-right-radius: inherit;
}
#taskWidgetModal .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
@media (max-width: 600px) {
    #taskWidgetModal .form-row { grid-template-columns: 1fr; }
}

/* ── Chat sidebar context: section title matches sibling sections ── */
.customer-sidebar-section .tasks-section .tasks-section-header h4 {
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: .04em;
    color: var(--text-secondary);
}
.customer-sidebar-section .tasks-section .tasks-section-header h4 .ti {
    font-size: 13px;
}

/* ── Customer profile modal context: little extra breathing room ── */
#customerTasksProfileSection {
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 480px) {
    .task-quick-add input[type="datetime-local"].qa-due { width: 110px; font-size: 10.5px; }
}

/* ── Dark mode polish ───────────────────────────────────────── */
[data-theme="dark"] .task-quick-add { background: rgba(255,255,255,.04); }
[data-theme="dark"] .task-quick-add input[type="datetime-local"].qa-due,
[data-theme="dark"] .task-quick-add button[type="submit"] {
    background: rgba(255,255,255,.06);
}
[data-theme="dark"] .tasks-section .tasks-section-item:hover {
    background: rgba(255,255,255,.04);
}
