/* ============================================================
   TASK MANAGEMENT — Advanced Task System CSS
   Builder CRM — matches saas-theme.css design tokens
   ============================================================ */

/* ── Task Board Layout ──────────────────────────────────── */
.task-page-shell {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ── Status Tabs ────────────────────────────────────────── */
.task-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.task-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1.1rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    border: 2px solid rgba(148,163,184,0.3);
    background: rgba(255,255,255,0.7);
    color: var(--gray-600);
    transition: all 0.15s;
    backdrop-filter: blur(6px);
}

.task-tab:hover {
    background: rgba(255,255,255,0.92);
    color: var(--gray-800);
    border-color: var(--gray-300);
}

.task-tab.is-active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

.task-tab.is-overdue.is-active   { border-color:#ef4444; background:#fff5f5; color:#b91c1c; }
.task-tab.is-today.is-active     { border-color:#f97316; background:#fff7ed; color:#c2410c; }
.task-tab.is-upcoming.is-active  { border-color:#22c55e; background:#f0fdf4; color:#15803d; }
.task-tab.is-progress.is-active  { border-color:#f59e0b; background:#fffbeb; color:#92400e; }
.task-tab.is-done.is-active      { border-color:#9ca3af; background:#f9fafb; color:#4b5563; }

.task-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0 5px;
    background: rgba(148,163,184,0.25);
    color: var(--gray-600);
}

.task-tab.is-active .task-tab-badge           { background: var(--primary); color: #fff; }
.task-tab.is-overdue.is-active .task-tab-badge  { background: #ef4444; color: #fff; }
.task-tab.is-today.is-active .task-tab-badge    { background: #f97316; color: #fff; }
.task-tab.is-upcoming.is-active .task-tab-badge { background: #22c55e; color: #fff; }
.task-tab.is-progress.is-active .task-tab-badge { background: #f59e0b; color: #fff; }
.task-tab.is-done.is-active .task-tab-badge     { background: #9ca3af; color: #fff; }

/* ── Filter Bar ─────────────────────────────────────────── */
.task-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
    background: rgba(255,255,255,0.75);
    border: 1px solid rgba(148,163,184,0.28);
    border-radius: 10px;
    padding: 0.85rem 1.1rem;
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow-sm);
}

.task-filter-bar .form-control,
.task-filter-bar .form-select {
    min-width: 130px;
    max-width: 200px;
    font-size: 0.85rem;
    padding: 0.45rem 0.75rem;
}

/* ── View Toggle (List / Calendar) ─────────────────────── */
.view-toggle {
    display: inline-flex;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(148,163,184,0.35);
    background: rgba(255,255,255,0.6);
}

.view-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gray-600);
    background: transparent;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}

.view-toggle-btn:hover {
    background: rgba(79,70,229,0.07);
    color: var(--primary);
}

.view-toggle-btn.is-active {
    background: var(--primary);
    color: #fff;
}

/* ── Task Card ──────────────────────────────────────────── */
.task-card {
    background: rgba(255,255,255,0.88);
    border: 1px solid rgba(229,231,235,0.85);
    border-radius: 12px;
    padding: 0.95rem 1.1rem;
    margin-bottom: 0.55rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    border-left-width: 4px;
    transition: box-shadow 0.15s, transform 0.15s;
    backdrop-filter: blur(4px);
}

.task-card:hover {
    box-shadow: 0 4px 20px -6px rgba(79,70,229,0.18);
    transform: translateY(-1px);
}

.task-card--overdue  { border-left-color: #ef4444; }
.task-card--today    { border-left-color: #f97316; }
.task-card--warning  { border-left-color: #eab308; }
.task-card--upcoming { border-left-color: #22c55e; }
.task-card--no_date  { border-left-color: #6366f1; }
.task-card--done     { border-left-color: #9ca3af; opacity: 0.82; }

.task-card__icon {
    font-size: 1.35rem;
    flex-shrink: 0;
    margin-top: 2px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99,102,241,0.08);
    border-radius: 8px;
}

.task-card__body {
    flex: 1;
    min-width: 0;
}

.task-card__title {
    font-size: 0.93rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 0.28rem;
    line-height: 1.35;
}

.task-card__title a {
    color: inherit;
    text-decoration: none;
}

.task-card__title a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.task-card__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--gray-500);
    margin-bottom: 0.3rem;
}

.task-card__desc {
    font-size: 0.8rem;
    color: var(--gray-600);
    line-height: 1.5;
    margin-top: 0.3rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.task-card__actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex-shrink: 0;
    align-items: flex-end;
}

/* ── Priority Badge ─────────────────────────────────────── */
.priority-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.priority-badge--low    { background: #f1f5f9; color: #475569; }
.priority-badge--medium { background: #dbeafe; color: #1d4ed8; }
.priority-badge--high   { background: #fef3c7; color: #b45309; }
.priority-badge--urgent { background: #fee2e2; color: #b91c1c; animation: urgentPulse 2s ease-in-out infinite; }

@keyframes urgentPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
    50%       { box-shadow: 0 0 0 4px rgba(239,68,68,0.22); }
}

/* ── Status Badge ───────────────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
}

.status-badge--pending     { background: #eef2ff; color: #4f46e5; }
.status-badge--in_progress { background: #fffbeb; color: #b45309; }
.status-badge--done        { background: #d1fae5; color: #065f46; }
.status-badge--cancelled   { background: #f3f4f6; color: #6b7280; }

/* ── Urgency Badge ──────────────────────────────────────── */
.urgency-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.13rem 0.55rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
}

.urgency-badge--overdue  { background: #fee2e2; color: #b91c1c; }
.urgency-badge--today    { background: #ffedd5; color: #c2410c; }
.urgency-badge--warning  { background: #fef9c3; color: #854d0e; }
.urgency-badge--upcoming { background: #dcfce7; color: #15803d; }
.urgency-badge--no_date  { background: #eef2ff; color: #4f46e5; }
.urgency-badge--done     { background: #f3f4f6; color: #6b7280; }

/* ── Linked Entity Chip ─────────────────────────────────── */
.linked-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.18rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(99,102,241,0.08);
    color: var(--primary);
    text-decoration: none;
    border: 1px solid rgba(99,102,241,0.18);
    transition: all 0.15s;
}

.linked-chip:hover {
    background: rgba(99,102,241,0.15);
    color: var(--primary-hover);
}

/* ── Task Detail Page ───────────────────────────────────── */
.task-detail-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.25rem;
    align-items: start;
}

@media (max-width: 900px) {
    .task-detail-grid { grid-template-columns: 1fr; }
}

.task-detail-card {
    background: rgba(255,255,255,0.9);
    border: 1px solid rgba(229,231,235,0.85);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1.1rem;
    backdrop-filter: blur(6px);
}

.task-detail-card-header {
    padding: 0.75rem 1.1rem;
    background: rgba(249,250,251,0.9);
    border-bottom: 1px solid rgba(229,231,235,0.75);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.task-detail-card-body {
    padding: 1.1rem;
}

.task-detail-row {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.48rem 0;
    border-bottom: 1px solid rgba(243,244,246,0.9);
    font-size: 0.855rem;
}

.task-detail-row:last-child { border-bottom: none; }
.task-detail-label { color: var(--gray-500); flex-shrink: 0; }
.task-detail-value { color: var(--gray-900); font-weight: 500; text-align: right; word-break: break-word; }

/* ── Comment Thread ─────────────────────────────────────── */
.comment-thread {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.comment-item {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.comment-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.comment-bubble {
    flex: 1;
    background: rgba(249,250,251,0.9);
    border: 1px solid rgba(229,231,235,0.7);
    border-radius: 0 10px 10px 10px;
    padding: 0.6rem 0.85rem;
}

.comment-bubble.is-mine {
    background: rgba(238,242,255,0.85);
    border-color: rgba(99,102,241,0.18);
}

.comment-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.comment-meta strong {
    color: var(--gray-800);
    font-weight: 600;
}

.comment-text {
    font-size: 0.85rem;
    color: var(--gray-700);
    line-height: 1.55;
    white-space: pre-wrap;
}

.comment-form {
    display: flex;
    gap: 0.6rem;
    margin-top: 1rem;
    align-items: flex-end;
}

.comment-form textarea {
    flex: 1;
    resize: vertical;
    min-height: 72px;
    font-size: 0.855rem;
}

/* ── Calendar View ──────────────────────────────────────── */
#taskCalendar {
    background: rgba(255,255,255,0.88);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid rgba(229,231,235,0.7);
    backdrop-filter: blur(6px);
}

/* FullCalendar overrides */
.fc .fc-toolbar-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-900);
}

.fc .fc-button-primary {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    border-radius: 6px !important;
    font-size: 0.82rem !important;
    padding: 0.35rem 0.85rem !important;
}

.fc .fc-button-primary:hover {
    background: var(--primary-hover) !important;
}

.fc .fc-button-active {
    background: var(--primary-hover) !important;
}

.fc-event {
    border-radius: 5px !important;
    font-size: 0.78rem !important;
    padding: 1px 4px !important;
    cursor: pointer;
}

.fc-event:hover {
    opacity: 0.88;
}

.fc-daygrid-event-dot {
    border-color: inherit !important;
}

/* ── Notification Bell ──────────────────────────────────── */
.notif-bell-wrapper {
    position: relative;
}

.notif-bell-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.4rem;
    color: rgba(255,255,255,0.82);
    font-size: 1.2rem;
    line-height: 1;
    border-radius: 8px;
    transition: all 0.15s;
    display: flex;
    align-items: center;
}

.notif-bell-btn:hover {
    background: rgba(255,255,255,0.14);
    color: #fff;
}

.notif-unread-badge {
    position: absolute;
    top: -3px;
    right: -4px;
    min-width: 17px;
    height: 17px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--primary);
    line-height: 1;
}

/* Notification Dropdown */
.notif-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 340px;
    max-width: 95vw;
    background: rgba(255,255,255,0.98);
    border: 1px solid rgba(229,231,235,0.8);
    border-radius: 14px;
    box-shadow: 0 20px 48px -12px rgba(15,23,42,0.28), 0 8px 16px -8px rgba(79,70,229,0.14);
    z-index: 2000;
    overflow: hidden;
    display: none;
}

.notif-dropdown.is-open {
    display: block;
    animation: dropIn 0.18s ease-out;
}

@keyframes dropIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.notif-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.1rem;
    border-bottom: 1px solid rgba(229,231,235,0.7);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gray-900);
}

.notif-list {
    max-height: 380px;
    overflow-y: auto;
}

.notif-item {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid rgba(243,244,246,0.9);
    cursor: pointer;
    transition: background 0.12s;
    text-decoration: none;
    color: inherit;
}

.notif-item:last-child { border-bottom: none; }

.notif-item.is-unread {
    background: rgba(238,242,255,0.55);
}

.notif-item:hover {
    background: rgba(238,242,255,0.8);
}

.notif-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    background: rgba(99,102,241,0.12);
}

.notif-icon.type-task_assigned { background: rgba(99,102,241,0.12); }
.notif-icon.type-task_comment  { background: rgba(16,185,129,0.1); }
.notif-icon.type-task_done     { background: rgba(34,197,94,0.12); }
.notif-icon.type-chat_message  { background: rgba(59,130,246,0.12); }

.notif-body { flex: 1; min-width: 0; }

.notif-msg {
    font-size: 0.82rem;
    color: var(--gray-800);
    line-height: 1.4;
    margin-bottom: 0.2rem;
}

.notif-time {
    font-size: 0.72rem;
    color: var(--gray-500);
}

.notif-unread-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
    margin-top: 5px;
}

.notif-dropdown-footer {
    padding: 0.65rem 1.1rem;
    text-align: center;
    border-top: 1px solid rgba(229,231,235,0.7);
}

.notif-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--gray-400);
    font-size: 0.85rem;
}

/* ── Done Modal ─────────────────────────────────────────── */
.task-done-modal .modal-content {
    border-radius: 14px;
    border: none;
    box-shadow: 0 24px 48px -12px rgba(15,23,42,0.28);
}

/* ── Empty State ────────────────────────────────────────── */
.task-empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--gray-400);
}

.task-empty-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
    line-height: 1;
}

.task-empty-state h4 {
    color: var(--gray-600);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .task-card {
        flex-direction: column;
        gap: 0.75rem;
    }

    .task-card__actions {
        flex-direction: row;
        justify-content: flex-end;
        width: 100%;
    }

    .task-filter-bar .form-control,
    .task-filter-bar .form-select {
        min-width: 100px;
        max-width: 100%;
        flex: 1;
    }

    .notif-dropdown {
        width: calc(100vw - 2rem);
        right: -1rem;
    }
}
